deweese 2003/10/22 18:01:55 Modified: sources/org/apache/batik/gvt CompositeShapePainter.java FillShapePainter.java MarkerShapePainter.java ShapeNode.java ShapePainter.java StrokeShapePainter.java Log: 1) No longer builds area objects for sensitive regions, now passes hit test point to shape painters directly. Revision Changes Path 1.19 +27 -1 xml-batik/sources/org/apache/batik/gvt/CompositeShapePainter.java Index: CompositeShapePainter.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/CompositeShapePainter.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- CompositeShapePainter.java 9 Aug 2003 16:58:40 -0000 1.18 +++ CompositeShapePainter.java 23 Oct 2003 01:01:55 -0000 1.19 @@ -53,6 +53,7 @@ import java.awt.Graphics2D; import java.awt.Shape; import java.awt.geom.Area; +import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; /** @@ -192,6 +193,18 @@ return bounds; } + /** + * Returns true if pt is in the area painted by this shape painter + */ + public boolean inPaintedArea(Point2D pt){ + if (painters == null) + return false; + for (int i=0; i < count; ++i) { + if (painters[i].inPaintedArea(pt)) + return true; + } + return false; + } /** * Returns the area covered by this shape painter (even if nothing @@ -224,6 +237,19 @@ else bounds.add(pb); } return bounds; + } + + /** + * Returns true if pt is in the area painted by this shape painter + */ + public boolean inSensitiveArea(Point2D pt){ + if (painters == null) + return false; + for (int i=0; i < count; ++i) { + if (painters[i].inSensitiveArea(pt)) + return true; + } + return false; } /** 1.14 +21 -1 xml-batik/sources/org/apache/batik/gvt/FillShapePainter.java Index: FillShapePainter.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/FillShapePainter.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- FillShapePainter.java 21 Oct 2003 01:17:11 -0000 1.13 +++ FillShapePainter.java 23 Oct 2003 01:01:55 -0000 1.14 @@ -54,6 +54,7 @@ import java.awt.Paint; import java.awt.Shape; import java.awt.geom.Rectangle2D; +import java.awt.geom.Point2D; /** * A shape painter that can be used to fill a shape. @@ -128,6 +129,16 @@ } /** + * Returns true if pt is in the area painted by this shape painter + */ + public boolean inPaintedArea(Point2D pt){ + if ((paint == null) || (shape == null)) + return false; + + return shape.contains(pt); + } + + /** * Returns the area covered by this shape painter (even if not painted). * */ @@ -143,6 +154,15 @@ if (shape == null) return null; return shape.getBounds2D(); + } + + /** + * Returns true if pt is in the area painted by this shape painter + */ + public boolean inSensitiveArea(Point2D pt){ + if (shape == null) + return false; + return shape.contains(pt); } /** 1.15 +23 -7 xml-batik/sources/org/apache/batik/gvt/MarkerShapePainter.java Index: MarkerShapePainter.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/MarkerShapePainter.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- MarkerShapePainter.java 9 Aug 2003 16:58:40 -0000 1.14 +++ MarkerShapePainter.java 23 Oct 2003 01:01:55 -0000 1.15 @@ -170,12 +170,21 @@ * Returns the bounds of the area painted by this shape painter */ public Rectangle2D getPaintedBounds2D(){ - Shape shape = getPaintedArea(); - if (shape != null){ - return shape.getBounds2D(); - } else { - return null; - } + if (markerGroup == null) { + buildMarkerGroup(); + } + return markerGroup.getPrimitiveBounds(); + } + + /** + * Returns true if pt is in the area painted by this shape painter + */ + public boolean inPaintedArea(Point2D pt){ + if (markerGroup == null) { + buildMarkerGroup(); + } + GraphicsNode gn = markerGroup.nodeHitAt(pt); + return (gn != null); } /** @@ -189,6 +198,13 @@ * (even if not painted). This is always null for Markers. */ public Rectangle2D getSensitiveBounds2D() { return null; } + + /** + * Returns true if pt is in the sensitive area. + * This is always false for Markers. + */ + public boolean inSensitiveArea(Point2D pt) { return false; } + /** * Sets the Shape this shape painter is associated with. 1.25 +52 -4 xml-batik/sources/org/apache/batik/gvt/ShapeNode.java Index: ShapeNode.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/ShapeNode.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- ShapeNode.java 21 Oct 2003 01:17:11 -0000 1.24 +++ ShapeNode.java 23 Oct 2003 01:01:55 -0000 1.25 @@ -226,9 +226,7 @@ if (b == null || !b.contains(p)) return false; - Shape s = getSensitiveArea(); - if (s == null) return false; - return s.contains(p); + return inSensitiveArea(p); } case NONE: default: @@ -273,6 +271,56 @@ } } return primitiveBounds; + } + + public boolean inSensitiveArea(Point2D pt) { + if (shapePainter == null) + return false; + + // <!> NOT REALLY NICE CODE BUT NO OTHER WAY + ShapePainter strokeShapePainter = null; + ShapePainter fillShapePainter = null; + if (shapePainter instanceof StrokeShapePainter) { + strokeShapePainter = shapePainter; + } else if (shapePainter instanceof FillShapePainter) { + fillShapePainter = shapePainter; + } else if (shapePainter instanceof CompositeShapePainter) { + CompositeShapePainter cp = (CompositeShapePainter)shapePainter; + + for (int i=0; i < cp.getShapePainterCount(); ++i) { + ShapePainter sp = cp.getShapePainter(i); + if (sp instanceof StrokeShapePainter) { + strokeShapePainter = sp; + } else if (sp instanceof FillShapePainter) { + fillShapePainter = sp; + } + } + } else { + return false; // Don't know what we have... + } + + switch(pointerEventType) { + case VISIBLE_PAINTED: + case PAINTED: + return shapePainter.inPaintedArea(pt); + case VISIBLE: + case ALL: + return shapePainter.inSensitiveArea(pt); + case VISIBLE_FILL: + case FILL: + if (fillShapePainter != null) + return fillShapePainter.inSensitiveArea(pt); + break; + case VISIBLE_STROKE: + case STROKE: + if (strokeShapePainter != null) + return strokeShapePainter.inSensitiveArea(pt); + break; + case NONE: + default: + // nothing to tdo + } + return false; } /** 1.14 +12 -1 xml-batik/sources/org/apache/batik/gvt/ShapePainter.java Index: ShapePainter.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/ShapePainter.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- ShapePainter.java 8 Aug 2003 11:39:14 -0000 1.13 +++ ShapePainter.java 23 Oct 2003 01:01:55 -0000 1.14 @@ -53,6 +53,7 @@ import java.awt.Graphics2D; import java.awt.Shape; import java.awt.geom.Rectangle2D; +import java.awt.geom.Point2D; /** * Renders the shape of a <tt>ShapeNode</tt>. @@ -80,6 +81,11 @@ Rectangle2D getPaintedBounds2D(); /** + * Returns true if <tt>pt</tt> is in the painted area. + */ + boolean inPaintedArea(Point2D pt); + + /** * Returns the area covered by this shape painter (even if nothing * is painted there). */ @@ -90,6 +96,11 @@ * (even if nothing is painted there). */ Rectangle2D getSensitiveBounds2D(); + + /** + * Returns true if <tt>pt</tt> is in the sensitive area. + */ + boolean inSensitiveArea(Point2D pt); /** * Sets the Shape this shape painter is associated with. 1.14 +24 -3 xml-batik/sources/org/apache/batik/gvt/StrokeShapePainter.java Index: StrokeShapePainter.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/StrokeShapePainter.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- StrokeShapePainter.java 8 Aug 2003 11:39:14 -0000 1.13 +++ StrokeShapePainter.java 23 Oct 2003 01:01:55 -0000 1.14 @@ -55,6 +55,7 @@ import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Rectangle2D; +import java.awt.geom.Point2D; /** * A shape painter that can be used to draw the outline of a shape. @@ -156,6 +157,16 @@ } /** + * Returns the bounds of the area covered by this shape painter + */ + public boolean inPaintedArea(Point2D pt){ + Shape painted = getPaintedArea(); + if (painted == null) + return false; + return painted.contains(pt); + } + + /** * Returns the area covered by this shape painter (even if not painted). */ public Shape getSensitiveArea(){ @@ -169,7 +180,7 @@ } /** - * Returns the bounds of the area covered by this shape painte + * Returns the bounds of the area covered by this shape painter * (even if not painted). */ public Rectangle2D getSensitiveBounds2D() { @@ -180,7 +191,17 @@ return sensitive.getBounds2D(); } - + /** + * Returns the bounds of the area covered by this shape painter + * (even if not painted). + */ + public boolean inSensitiveArea(Point2D pt){ + Shape sensitive = getSensitiveArea(); + if (sensitive == null) + return false; + return sensitive.contains(pt); + } + /** * Sets the Shape this shape painter is associated with. *
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]