Revision: 8109
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8109&view=rev
Author:   leejjoon
Date:     2010-02-03 19:42:00 +0000 (Wed, 03 Feb 2010)

Log Message:
-----------
minor refactoring of the ps backend

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/backends/backend_ps.py

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py      2010-02-03 
19:41:53 UTC (rev 8108)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py      2010-02-03 
19:42:00 UTC (rev 8109)
@@ -387,6 +387,16 @@
         """
         return True
 
+    def _get_image_h_w_bits_command(self, im):
+        if im.is_grayscale:
+            h, w, bits = self._gray(im)
+            imagecmd = "image"
+        else:
+            h, w, bits = self._rgb(im)
+            imagecmd = "false 3 colorimage"
+
+        return h, w, bits, imagecmd
+    
     def draw_image(self, gc, x, y, im, dx=None, dy=None, transform=None):
         """
         Draw the Image instance into the current axes; x is the
@@ -400,12 +410,7 @@
 
         im.flipud_out()
 
-        if im.is_grayscale:
-            h, w, bits = self._gray(im)
-            imagecmd = "image"
-        else:
-            h, w, bits = self._rgb(im)
-            imagecmd = "false 3 colorimage"
+        h, w, bits, imagecmd = self._get_image_h_w_bits_command(im)
         hexlines = '\n'.join(self._hex_lines(bits))
 
         if dx is None:
@@ -924,6 +929,8 @@
     return manager
 
 class FigureCanvasPS(FigureCanvasBase):
+    _renderer_class = RendererPS
+
     def draw(self):
         pass
 
@@ -1057,7 +1064,8 @@
 
         # mixed mode rendering
         _bbox_inches_restore = kwargs.pop("bbox_inches_restore", None)
-        ps_renderer = RendererPS(width, height, self._pswriter, imagedpi=dpi)
+        ps_renderer = self._renderer_class(width, height, self._pswriter,
+                                           imagedpi=dpi)
         renderer = MixedModeRenderer(self.figure,
             width, height, dpi, ps_renderer,
             bbox_inches_restore=_bbox_inches_restore)
@@ -1189,7 +1197,8 @@
 
         # mixed mode rendering
         _bbox_inches_restore = kwargs.pop("bbox_inches_restore", None)
-        ps_renderer = RendererPS(width, height, self._pswriter, imagedpi=dpi)
+        ps_renderer = self._renderer_class(width, height,
+                                           self._pswriter, imagedpi=dpi)
         renderer = MixedModeRenderer(self.figure,
             width, height, dpi, ps_renderer,
             bbox_inches_restore=_bbox_inches_restore)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to