Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/thirdparty/cairoplot-trunk/trunk/cairoplot/handlers/fixedsize.py
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/cairoplot-trunk/trunk/cairoplot/handlers/fixedsize.py')
-rwxr-xr-xthirdparty/cairoplot-trunk/trunk/cairoplot/handlers/fixedsize.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/thirdparty/cairoplot-trunk/trunk/cairoplot/handlers/fixedsize.py b/thirdparty/cairoplot-trunk/trunk/cairoplot/handlers/fixedsize.py
new file mode 100755
index 0000000..3c25fdf
--- /dev/null
+++ b/thirdparty/cairoplot-trunk/trunk/cairoplot/handlers/fixedsize.py
@@ -0,0 +1,30 @@
+
+import cairo
+import cairoplot
+from .handler import Handler as _Handler
+
+class FixedSizeHandler(_Handler):
+ """Base class for handlers with a fixed size."""
+
+ def __init__(self, width, height):
+ """Create with fixed width and height."""
+ self.dimensions = {}
+ self.dimensions[cairoplot.HORZ] = width
+ self.dimensions[cairoplot.VERT] = height
+
+ # sub-classes must create a surface
+ self.surface = None
+
+ def prepare(self, plot):
+ """Prepare plot to render by setting its dimensions."""
+ _Handler.prepare(self, plot)
+ plot.dimensions = self.dimensions
+ plot.context = cairo.Context(self.surface)
+
+ def commit(self, plot):
+ """Commit the plot (to a file)."""
+ _Handler.commit(self, plot)
+
+ # since pngs are different from other fixed size handlers,
+ # sub-classes are in charge of actual file writing
+