]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Forgot to add.
authorAdrian Cumiskey <acumiskey@apache.org>
Tue, 4 Nov 2008 17:40:36 +0000 (17:40 +0000)
committerAdrian Cumiskey <acumiskey@apache.org>
Tue, 4 Nov 2008 17:40:36 +0000 (17:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@711324 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/AbstractGraphics2DImagePainter.java [new file with mode: 0644]

diff --git a/src/java/org/apache/fop/render/AbstractGraphics2DImagePainter.java b/src/java/org/apache/fop/render/AbstractGraphics2DImagePainter.java
new file mode 100644 (file)
index 0000000..4a3c7d9
--- /dev/null
@@ -0,0 +1,55 @@
+package org.apache.fop.render;
+
+import java.awt.Graphics2D;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.batik.gvt.GraphicsNode;
+import org.apache.xmlgraphics.java2d.Graphics2DPainterPreparator;
+
+/**
+ * An initializable graphics 2D image painter
+ */
+public abstract class AbstractGraphics2DImagePainter
+    implements org.apache.xmlgraphics.java2d.Graphics2DImagePainter {
+
+    private final GraphicsNode root;
+
+    protected Graphics2DPainterPreparator preparator;
+
+    /**
+     * Main constructor
+     *
+     * @param root a graphics node root
+     */
+    public AbstractGraphics2DImagePainter(GraphicsNode root) {
+        this.root = root;
+    }
+
+    /**
+     * Sets the graphics 2D painter preparator
+     *
+     * @param initializer the graphics 2D preparator
+     */
+    public void setPreparator(Graphics2DPainterPreparator preparator) {
+        this.preparator = preparator;
+    }
+
+    /**
+     * Returns the graphics 2D painter preparator
+     *
+     * @return the graphics 2D painter preparator
+     */
+    protected Graphics2DPainterPreparator getPreparator() {
+        return this.preparator;
+    }
+
+    /** {@inheritDoc} */
+    public void paint(Graphics2D g2d, Rectangle2D area) {
+        Graphics2DPainterPreparator preparator = getPreparator();
+        if (preparator != null) {
+            preparator.prepare(g2d, area);
+        }
+        root.paint(g2d);
+    }
+
+}