diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-08-30 19:32:05 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-08-30 19:32:05 +0000 |
commit | 302218f9cba73f4a5e52dd37b026bf6dddddbf40 (patch) | |
tree | 00bf29bfe972bedfe5a4d880d80cad51e536a964 | |
parent | f2f228dd3abcfbc56c6b70176676654ffbf50a0d (diff) | |
download | xmlgraphics-fop-302218f9cba73f4a5e52dd37b026bf6dddddbf40.tar.gz xmlgraphics-fop-302218f9cba73f4a5e52dd37b026bf6dddddbf40.zip |
Harmonization between the two Graphics2D implementations. Clipping is done after the transform. All path iterators use an identity transform which makes the PDF/PS code more readable and usually smaller.
Added missing support for non-zero winding rule in PSGraphics2D.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@264837 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/fop/render/ps/PSGraphics2D.java | 27 | ||||
-rw-r--r-- | src/java/org/apache/fop/svg/PDFGraphics2D.java | 28 |
2 files changed, 32 insertions, 23 deletions
diff --git a/src/java/org/apache/fop/render/ps/PSGraphics2D.java b/src/java/org/apache/fop/render/ps/PSGraphics2D.java index 1d4202454..4bfea700a 100644 --- a/src/java/org/apache/fop/render/ps/PSGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/PSGraphics2D.java @@ -278,9 +278,9 @@ public class PSGraphics2D extends AbstractGraphics2D { FopImage fopimg = new TempImage(width, height, result, null); AffineTransform at = getTransform(); gen.saveGraphicsState(); + gen.concatMatrix(at); Shape imclip = getClip(); writeClip(imclip); - gen.concatMatrix(at); PSImageUtils.renderBitmapImage(fopimg, x, y, width, height, gen); gen.restoreGraphicsState(); @@ -567,11 +567,11 @@ public class PSGraphics2D extends AbstractGraphics2D { boolean newTransform = gen.getCurrentState().checkTransform(trans) && !trans.isIdentity(); - Shape imclip = getClip(); - writeClip(imclip); if (newTransform) { gen.concatMatrix(trans); } + Shape imclip = getClip(); + writeClip(imclip); establishColor(getColor()); applyPaint(getPaint(), false); @@ -599,7 +599,7 @@ public class PSGraphics2D extends AbstractGraphics2D { preparePainting(); try { gen.writeln("newpath"); - PathIterator iter = s.getPathIterator(getTransform()); + PathIterator iter = s.getPathIterator(IDENTITY_TRANSFORM); processPathIterator(iter); // clip area gen.writeln("clip"); @@ -999,14 +999,23 @@ public class PSGraphics2D extends AbstractGraphics2D { preparePainting(); try { gen.saveGraphicsState(); + + AffineTransform trans = getTransform(); + boolean newTransform = gen.getCurrentState().checkTransform(trans) + && !trans.isIdentity(); + + if (newTransform) { + gen.concatMatrix(trans); + } Shape imclip = getClip(); writeClip(imclip); + establishColor(getColor()); applyPaint(getPaint(), true); gen.writeln("newpath"); - PathIterator iter = s.getPathIterator(getTransform()); + PathIterator iter = s.getPathIterator(IDENTITY_TRANSFORM); processPathIterator(iter); doDrawing(true, false, iter.getWindingRule() == PathIterator.WIND_EVEN_ODD); @@ -1020,7 +1029,7 @@ public class PSGraphics2D extends AbstractGraphics2D { * Commits a painting operation. * @param fill filling * @param stroke stroking - * @param nonzero ??? + * @param nonzero true if the non-zero winding rule should be used when filling * @exception IOException In case of an I/O problem */ protected void doDrawing(boolean fill, boolean stroke, boolean nonzero) @@ -1029,15 +1038,15 @@ public class PSGraphics2D extends AbstractGraphics2D { if (fill) { if (stroke) { if (!nonzero) { - gen.writeln("stroke"); + gen.writeln("gsave fill grestore stroke"); } else { - gen.writeln("stroke"); + gen.writeln("gsave eofill grestore stroke"); } } else { if (!nonzero) { gen.writeln("fill"); } else { - gen.writeln("fill"); + gen.writeln("eofill"); } } } else { diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index c989e290a..b28d7cba6 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -366,11 +366,11 @@ public class PDFGraphics2D extends AbstractGraphics2D { double[] matrix = new double[6]; at.getMatrix(matrix); currentStream.write("q\n"); - Shape imclip = getClip(); - writeClip(imclip); if (!at.isIdentity()) { concatMatrix(matrix); } + Shape imclip = getClip(); + writeClip(imclip); currentStream.write("" + width + " 0 0 " + (-height) + " " @@ -574,11 +574,11 @@ public class PDFGraphics2D extends AbstractGraphics2D { double[] matrix = new double[6]; at.getMatrix(matrix); currentStream.write("q\n"); - Shape imclip = getClip(); - writeClip(imclip); if (!at.isIdentity()) { concatMatrix(matrix); } + Shape imclip = getClip(); + writeClip(imclip); currentStream.write("" + width + " 0 0 " + (-height) + " " + x + " " + (y + height) + " cm\n" + "/Im" + imageInfo.getXNumber() + " Do\nQ\n"); @@ -659,12 +659,12 @@ public class PDFGraphics2D extends AbstractGraphics2D { if (newClip || newTransform) { currentStream.write("q\n"); graphicsState.push(); - if (newClip) { - writeClip(imclip); - } if (newTransform) { concatMatrix(tranvals); } + if (newClip) { + writeClip(imclip); + } } if (c.getAlpha() != 255) { @@ -1183,8 +1183,6 @@ public class PDFGraphics2D extends AbstractGraphics2D { currentStream.write("q\n"); - Shape imclip = getClip(); - writeClip(imclip); Color c = getColor(); applyColor(c, true); applyPaint(getPaint(), true); @@ -1199,8 +1197,6 @@ public class PDFGraphics2D extends AbstractGraphics2D { currentStream.write("/" + gstate.getName() + " gs\n"); } - currentStream.write("BT\n"); - Map kerning = null; boolean kerningAvailable = false; @@ -1231,6 +1227,10 @@ public class PDFGraphics2D extends AbstractGraphics2D { trans.getMatrix(vals); concatMatrix(vals); + Shape imclip = getClip(); + writeClip(imclip); + currentStream.write("BT\n"); + currentStream.write("1 0 0 -1 0 0 Tm [" + startText); int l = s.length(); @@ -1418,12 +1418,12 @@ public class PDFGraphics2D extends AbstractGraphics2D { if (newClip || newTransform) { currentStream.write("q\n"); graphicsState.push(); - if (newClip) { - writeClip(imclip); - } if (newTransform) { concatMatrix(tranvals); } + if (newClip) { + writeClip(imclip); + } } if (c.getAlpha() != 255) { |