]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Renamed GenericGraphics2DImagePainter to a slightly more meaningful name of BatikGrap...
authorAdrian Cumiskey <acumiskey@apache.org>
Wed, 29 Oct 2008 11:21:32 +0000 (11:21 +0000)
committerAdrian Cumiskey <acumiskey@apache.org>
Wed, 29 Oct 2008 11:21:32 +0000 (11:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@708877 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/image/loader/batik/BatikGraphics2DImagePainter.java [new file with mode: 0644]
src/java/org/apache/fop/image/loader/batik/GenericGraphics2DImagePainter.java [deleted file]
src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java

diff --git a/src/java/org/apache/fop/image/loader/batik/BatikGraphics2DImagePainter.java b/src/java/org/apache/fop/image/loader/batik/BatikGraphics2DImagePainter.java
new file mode 100644 (file)
index 0000000..9830330
--- /dev/null
@@ -0,0 +1,95 @@
+package org.apache.fop.image.loader.batik;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.gvt.GraphicsNode;
+import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
+import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
+
+/**
+ * A generic graphics 2D image painter implementation
+ */
+public class BatikGraphics2DImagePainter implements Graphics2DImagePainter {
+
+    protected final ImageXMLDOM svg;
+    protected final BridgeContext ctx;
+    protected final GraphicsNode root;
+
+    /**
+     * Constructor
+     *
+     * @param svg the svg image dom
+     * @param ctx the bridge context
+     * @param root the graphics node root
+     */
+    public BatikGraphics2DImagePainter(ImageXMLDOM svg, BridgeContext ctx, GraphicsNode root) {
+        this.svg = svg;
+        this.ctx = ctx;
+        this.root = root;
+    }
+
+    /**
+     * Initialises the graphics 2d
+     *
+     * @param g2d the graphics 2d
+     * @param area the rectangle drawing area
+     */
+    protected void init(Graphics2D g2d, Rectangle2D area) {
+        // If no viewbox is defined in the svg file, a viewbox of 100x100 is
+        // assumed, as defined in SVGUserAgent.getViewportSize()
+        double tx = area.getX();
+        double ty = area.getY();
+        if (tx != 0 || ty != 0) {
+            g2d.translate(tx, ty);
+        }
+
+        float iw = (float) ctx.getDocumentSize().getWidth();
+        float ih = (float) ctx.getDocumentSize().getHeight();
+        float w = (float) area.getWidth();
+        float h = (float) area.getHeight();
+        float sx = w / iw;
+        float sy = h / ih;
+        if (sx != 1.0 || sy != 1.0) {
+            g2d.scale(sx, sy);
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void paint(Graphics2D g2d, Rectangle2D area) {
+        init(g2d, area);
+        root.paint(g2d);
+    }
+
+    /** {@inheritDoc} */
+    public Dimension getImageSize() {
+        return new Dimension(svg.getSize().getWidthMpt(), svg.getSize().getHeightMpt());
+    }
+
+    /**
+     * Returns the svg image dom
+     * @return the svg image dom
+     */
+    public ImageXMLDOM getImageXMLDOM() {
+        return svg;
+    }
+
+    /**
+     * Returns the bridge context
+     * @return the bridge context
+     */
+    public BridgeContext getBridgeContext() {
+        return ctx;
+    }
+
+    /**
+     * Returns the graphics root node
+     * @return the graphics root node
+     */
+    public GraphicsNode getRoot() {
+        return root;
+    }
+
+}
\ No newline at end of file
diff --git a/src/java/org/apache/fop/image/loader/batik/GenericGraphics2DImagePainter.java b/src/java/org/apache/fop/image/loader/batik/GenericGraphics2DImagePainter.java
deleted file mode 100644 (file)
index aa4d991..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-package org.apache.fop.image.loader.batik;
-
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.geom.Rectangle2D;
-
-import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.gvt.GraphicsNode;
-import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
-import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
-
-/**
- * A generic graphics 2D image painter implementation
- */
-public class GenericGraphics2DImagePainter implements Graphics2DImagePainter {
-
-    protected final ImageXMLDOM svg;
-    protected final BridgeContext ctx;
-    protected final GraphicsNode root;
-
-    /**
-     * Constructor
-     *
-     * @param svg the svg image dom
-     * @param ctx the bridge context
-     * @param root the graphics node root
-     */
-    public GenericGraphics2DImagePainter(ImageXMLDOM svg, BridgeContext ctx, GraphicsNode root) {
-        this.svg = svg;
-        this.ctx = ctx;
-        this.root = root;
-    }
-
-    /**
-     * Initialises the graphics 2d
-     *
-     * @param g2d the graphics 2d
-     * @param area the rectangle drawing area
-     */
-    protected void init(Graphics2D g2d, Rectangle2D area) {
-        // If no viewbox is defined in the svg file, a viewbox of 100x100 is
-        // assumed, as defined in SVGUserAgent.getViewportSize()
-        double tx = area.getX();
-        double ty = area.getY();
-        if (tx != 0 || ty != 0) {
-            g2d.translate(tx, ty);
-        }
-
-        float iw = (float) ctx.getDocumentSize().getWidth();
-        float ih = (float) ctx.getDocumentSize().getHeight();
-        float w = (float) area.getWidth();
-        float h = (float) area.getHeight();
-        float sx = w / iw;
-        float sy = h / ih;
-        if (sx != 1.0 || sy != 1.0) {
-            g2d.scale(sx, sy);
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void paint(Graphics2D g2d, Rectangle2D area) {
-        init(g2d, area);
-        root.paint(g2d);
-    }
-
-    /** {@inheritDoc} */
-    public Dimension getImageSize() {
-        return new Dimension(svg.getSize().getWidthMpt(), svg.getSize().getHeightMpt());
-    }
-
-    /**
-     * Returns the svg image dom
-     * @return the svg image dom
-     */
-    public ImageXMLDOM getImageXMLDOM() {
-        return svg;
-    }
-
-    /**
-     * Returns the bridge context
-     * @return the bridge context
-     */
-    public BridgeContext getBridgeContext() {
-        return ctx;
-    }
-
-    /**
-     * Returns the graphics root node
-     * @return the graphics root node
-     */
-    public GraphicsNode getRoot() {
-        return root;
-    }
-
-}
\ No newline at end of file
index a2c0128c2352766773673da77cc878b056a67093..40dc600be6aa5ce8b66525cec2697525b69740ca 100644 (file)
@@ -116,7 +116,7 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter {
      */
     protected Graphics2DImagePainter createPainter(
             final ImageXMLDOM svg, final BridgeContext ctx, final GraphicsNode root) {
-        return new GenericGraphics2DImagePainter(svg, ctx, root);
+        return new BatikGraphics2DImagePainter(svg, ctx, root);
     }
 
     /** {@inheritDoc} */
index 81d00bd1035eb14d5518e26620dfa409df23a289..da9a37b7668b196d8e08c54e06cb0bbac1715072 100644 (file)
@@ -36,7 +36,7 @@ import org.apache.fop.afp.AFPState;
 import org.apache.fop.afp.AFPTextElementBridge;
 import org.apache.fop.afp.AFPTextHandler;
 import org.apache.fop.afp.AFPTextPainter;
-import org.apache.fop.image.loader.batik.GenericGraphics2DImagePainter;
+import org.apache.fop.image.loader.batik.BatikGraphics2DImagePainter;
 import org.apache.fop.render.RendererContext;
 import org.apache.fop.svg.SVGUserAgent;
 import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
@@ -117,8 +117,8 @@ public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory {
 
         // set painter
         ImageGraphics2D imageG2D = (ImageGraphics2D)rendererImageInfo.getImage();
-        GenericGraphics2DImagePainter painter
-            = (GenericGraphics2DImagePainter)imageG2D.getGraphics2DImagePainter();
+        BatikGraphics2DImagePainter painter
+            = (BatikGraphics2DImagePainter)imageG2D.getGraphics2DImagePainter();
         painter = new AFPGraphics2DImagePainter(painter);
         imageG2D.setGraphics2DImagePainter(painter);
         graphicsObjectInfo.setPainter(painter);
@@ -131,13 +131,13 @@ public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory {
         return graphicsObjectInfo;
     }
 
-    private class AFPGraphics2DImagePainter extends GenericGraphics2DImagePainter {
+    private class AFPGraphics2DImagePainter extends BatikGraphics2DImagePainter {
         /**
          * Copy constructor
          *
          * @param painter a graphics 2D image painter
          */
-        public AFPGraphics2DImagePainter(GenericGraphics2DImagePainter painter) {
+        public AFPGraphics2DImagePainter(BatikGraphics2DImagePainter painter) {
             super(painter.getImageXMLDOM(), painter.getBridgeContext(), painter.getRoot());
         }