The clip(Shape) method wasn't implemented correctly. It simply called setClip(), but it really should intersect the current clip with the specified shape. I adapted this method from AbstractGraphics2D. This fixes all remaining Swing painting problems (at least for me).
2006-06-07 Roman Kennke <[EMAIL PROTECTED]>
PR 27833
* gnu/java/awt/peer/gtk/CairoGraphics2D.java
(clip(Shape)): Implemented correctly, so that the current shape
gets intersected by the parameter shape.
/Roman
--
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: gnu/java/awt/peer/gtk/CairoGraphics2D.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,v
retrieving revision 1.14
diff -u -1 -0 -r1.14 CairoGraphics2D.java
--- gnu/java/awt/peer/gtk/CairoGraphics2D.java 3 Jun 2006 22:47:03 -0000 1.14
+++ gnu/java/awt/peer/gtk/CairoGraphics2D.java 7 Jun 2006 19:11:13 -0000
@@ -58,20 +58,21 @@
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.Polygon;
import java.awt.TexturePaint;
import java.awt.Toolkit;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
import java.awt.geom.Arc2D;
+import java.awt.geom.Area;
import java.awt.geom.Line2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
@@ -521,24 +522,56 @@
public void shear(double shearX, double shearY)
{
transform(AffineTransform.getShearInstance(shearX, shearY));
}
///////////////////////// DRAWING STATE ///////////////////////////////////
public void clip(Shape s)
{
- if( s == null )
- setClip( originalClip );
+ // Do not touch clip when s == null.
+ if (s == null)
+ return;
- setClip(s);
+ // If the current clip is still null, initialize it.
+ if (clip == null)
+ clip = originalClip;
+
+ // This is so common, let's optimize this.
+ else if (clip instanceof Rectangle2D && s instanceof Rectangle2D)
+ {
+ Rectangle2D clipRect = (Rectangle2D) clip;
+ Rectangle2D r = (Rectangle2D) s;
+ Rectangle2D.intersect(clipRect, r, clipRect);
+ // Call setClip so that subclasses get notified.
+ setClip(clipRect);
+ }
+ else
+ {
+ Area current;
+ if (clip instanceof Area)
+ current = (Area) clip;
+ else
+ current = new Area(clip);
+
+ Area intersect;
+ if (s instanceof Area)
+ intersect = (Area) s;
+ else
+ intersect = new Area(s);
+
+ current.intersect(intersect);
+ clip = current;
+ // Call setClip so that the native side gets notified.
+ setClip(clip);
+ }
}
public Paint getPaint()
{
return paint;
}
public AffineTransform getTransform()
{
return (AffineTransform) transform.clone();
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
