You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by rm...@apache.org on 2013/10/18 17:37:35 UTC
svn commit: r1533516 - in /xmlgraphics/commons/trunk:
src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java
test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java
Author: rmeyer
Date: Fri Oct 18 15:37:35 2013
New Revision: 1533516
URL: http://svn.apache.org/r1533516
Log:
FOP-2304: SVN line clipping not correct when outputting to Postscript
Modified:
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java
xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java?rev=1533516&r1=1533515&r2=1533516&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java Fri Oct 18 15:37:35 2013
@@ -36,6 +36,7 @@ import java.awt.Stroke;
import java.awt.TexturePaint;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
+import java.awt.geom.Line2D;
import java.awt.geom.PathIterator;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
@@ -490,6 +491,10 @@ public class PSGraphics2D extends Abstra
if (clip == null || s == null) {
return false;
}
+ if (s instanceof Line2D) {
+ //Line shapes don't work with intersections so always clip
+ return true;
+ }
Area as = new Area(s);
Area imclip = new Area(clip);
imclip.intersect(as);
Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java?rev=1533516&r1=1533515&r2=1533516&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2DTestCase.java Fri Oct 18 15:37:35 2013
@@ -20,22 +20,27 @@
package org.apache.xmlgraphics.java2d.ps;
import java.awt.Rectangle;
+import java.awt.Shape;
import java.awt.geom.AffineTransform;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
+import org.apache.xmlgraphics.java2d.GraphicContext;
+import org.apache.xmlgraphics.ps.PSGenerator;
+import org.apache.xmlgraphics.ps.PSState;
+
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import org.apache.xmlgraphics.java2d.GraphicContext;
-import org.apache.xmlgraphics.ps.PSGenerator;
-import org.apache.xmlgraphics.ps.PSState;
-
public class PSGraphics2DTestCase {
private PSGenerator gen;
@@ -62,4 +67,13 @@ public class PSGraphics2DTestCase {
gfx2d.draw(new Rectangle(10, 10, 100, 100));
verify(gen, times(1)).concatMatrix(transform);
}
+
+ @Test
+ public void testShouldBeClipped() {
+ Shape line = new Line2D.Float(10, 10, 50, 50);
+ Shape clipArea = new Rectangle2D.Float(20, 20, 100, 100);
+ assertTrue(gfx2d.shouldBeClipped(clipArea, line));
+ Shape rect = new Rectangle2D.Float(30, 30, 40, 40);
+ assertFalse(gfx2d.shouldBeClipped(clipArea, rect));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org