From b8f51d3e86bcb3c4f4865f1c8e31ec72d7dcc08f Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Tue, 4 Nov 2008 17:40:36 +0000 Subject: [PATCH] Forgot to add. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@711324 13f79535-47bb-0310-9956-ffa450edef68 --- .../AbstractGraphics2DImagePainter.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/java/org/apache/fop/render/AbstractGraphics2DImagePainter.java diff --git a/src/java/org/apache/fop/render/AbstractGraphics2DImagePainter.java b/src/java/org/apache/fop/render/AbstractGraphics2DImagePainter.java new file mode 100644 index 000000000..4a3c7d954 --- /dev/null +++ b/src/java/org/apache/fop/render/AbstractGraphics2DImagePainter.java @@ -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); + } + +} -- 2.39.5