]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Harmonization between the two Graphics2D implementations. Clipping is done after...
authorJeremias Maerki <jeremias@apache.org>
Tue, 30 Aug 2005 19:32:05 +0000 (19:32 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 30 Aug 2005 19:32:05 +0000 (19:32 +0000)
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

src/java/org/apache/fop/render/ps/PSGraphics2D.java
src/java/org/apache/fop/svg/PDFGraphics2D.java

index 1d4202454768c4781d8da7d0bd89e32eac131772..4bfea700a8bbc12c0b7f6415af06f70a36bee96a 100644 (file)
@@ -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 {
index c989e290a340103a252506b5b4cbd59678037c26..b28d7cba659617209fc590e2f2524ef76b449ae9 100644 (file)
@@ -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) {