aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-10-20 06:43:09 +0000
committerJeremias Maerki <jeremias@apache.org>2008-10-20 06:43:09 +0000
commit575187323ab8e636c4e04b4f77b5bda6a137d61d (patch)
treee9163b4d3994ff0f37bcac75d1ac17fa05fd1021 /src/java/org
parentc858dbc84a00d9600af01e3885579d845afd1922 (diff)
downloadxmlgraphics-fop-575187323ab8e636c4e04b4f77b5bda6a137d61d.tar.gz
xmlgraphics-fop-575187323ab8e636c4e04b4f77b5bda6a137d61d.zip
Fall back to PathIterator painting for all unrecognized shapes (like polylines and polygons)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@706128 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/fop/render/afp/AFPGraphics2D.java98
1 files changed, 48 insertions, 50 deletions
diff --git a/src/java/org/apache/fop/render/afp/AFPGraphics2D.java b/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
index 2699cfa6b..67c6fa6f5 100644
--- a/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
+++ b/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
@@ -33,7 +33,6 @@ import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;
-import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;
import java.awt.geom.PathIterator;
import java.awt.geom.Rectangle2D;
@@ -43,13 +42,10 @@ import java.awt.image.RenderedImage;
import java.awt.image.renderable.RenderableImage;
import java.io.IOException;
-import org.apache.batik.ext.awt.geom.ExtendedGeneralPath;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.afp.goca.GraphicsSetLineType;
-import org.apache.fop.render.afp.modca.GraphicsObject;
+
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageSize;
import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
@@ -59,6 +55,10 @@ import org.apache.xmlgraphics.java2d.StrokingTextHandler;
import org.apache.xmlgraphics.java2d.TextHandler;
import org.apache.xmlgraphics.ps.ImageEncodingHelper;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.render.afp.goca.GraphicsSetLineType;
+import org.apache.fop.render.afp.modca.GraphicsObject;
+
/**
* This is a concrete implementation of <tt>AbstractGraphics2D</tt> (and
* therefore of <tt>Graphics2D</tt>) which is able to generate GOCA byte
@@ -219,7 +219,49 @@ public class AFPGraphics2D extends AbstractGraphics2D {
PathIterator iter = shape.getPathIterator(trans);
double[] vals = new double[6];
int[] coords = null;
- if (shape instanceof GeneralPath || shape instanceof ExtendedGeneralPath) {
+ if (shape instanceof Line2D) {
+ iter.currentSegment(vals);
+ coords = new int[4];
+ coords[0] = (int) Math.round(vals[0]); //x1
+ coords[1] = (int) Math.round(vals[1]); //y1
+ iter.next();
+ iter.currentSegment(vals);
+ coords[2] = (int) Math.round(vals[0]); //x2
+ coords[3] = (int) Math.round(vals[1]); //y2
+ graphicsObj.addLine(coords);
+ } else if (shape instanceof Rectangle2D) {
+ iter.currentSegment(vals);
+ coords = new int[4];
+ coords[2] = (int) Math.round(vals[0]); //x1
+ coords[3] = (int) Math.round(vals[1]); //y1
+ iter.next();
+ iter.next();
+ iter.currentSegment(vals);
+ coords[0] = (int) Math.round(vals[0]); //x2
+ coords[1] = (int) Math.round(vals[1]); //y2
+ graphicsObj.addBox(coords);
+ } else if (shape instanceof Ellipse2D) {
+ Ellipse2D elip = (Ellipse2D) shape;
+ int resolution = info.getResolution();
+ final double factor = resolution / 100f;
+ graphicsObj.setArcParams(
+ (int)Math.round(elip.getWidth() * factor),
+ (int)Math.round(elip.getHeight() * factor),
+ 0,
+ 0
+ );
+ trans.transform(
+ new double[] {elip.getCenterX(), elip.getCenterY()}, 0,
+ vals, 0, 1);
+ final int mh = 1;
+ final int mhr = 0;
+ graphicsObj.addFullArc(
+ (int)Math.round(vals[0]),
+ (int)Math.round(vals[1]),
+ mh,
+ mhr
+ );
+ } else {
// graphics segment opening coordinates (x,y)
// current position coordinates (x,y)
for (int[] openingCoords = new int[2], currCoords = new int[2];
@@ -273,50 +315,6 @@ public class AFPGraphics2D extends AbstractGraphics2D {
currCoords[1] = coords[coords.length - 1];
}
}
- } else if (shape instanceof Line2D) {
- iter.currentSegment(vals);
- coords = new int[4];
- coords[0] = (int) Math.round(vals[0]); //x1
- coords[1] = (int) Math.round(vals[1]); //y1
- iter.next();
- iter.currentSegment(vals);
- coords[2] = (int) Math.round(vals[0]); //x2
- coords[3] = (int) Math.round(vals[1]); //y2
- graphicsObj.addLine(coords);
- } else if (shape instanceof Rectangle2D) {
- iter.currentSegment(vals);
- coords = new int[4];
- coords[2] = (int) Math.round(vals[0]); //x1
- coords[3] = (int) Math.round(vals[1]); //y1
- iter.next();
- iter.next();
- iter.currentSegment(vals);
- coords[0] = (int) Math.round(vals[0]); //x2
- coords[1] = (int) Math.round(vals[1]); //y2
- graphicsObj.addBox(coords);
- } else if (shape instanceof Ellipse2D) {
- Ellipse2D elip = (Ellipse2D) shape;
- int resolution = info.getResolution();
- final double factor = resolution / 100f;
- graphicsObj.setArcParams(
- (int)Math.round(elip.getWidth() * factor),
- (int)Math.round(elip.getHeight() * factor),
- 0,
- 0
- );
- trans.transform(
- new double[] {elip.getCenterX(), elip.getCenterY()}, 0,
- vals, 0, 1);
- final int mh = 1;
- final int mhr = 0;
- graphicsObj.addFullArc(
- (int)Math.round(vals[0]),
- (int)Math.round(vals[1]),
- mh,
- mhr
- );
- } else {
- log.error("Unrecognised shape: " + shape);
}
if (fill) {
graphicsObj.endArea();