vhardy 02/02/06 05:18:33 Modified: sources/org/apache/batik/gvt CompositeShapePainter.java FillShapePainter.java MarkerShapePainter.java ShapeNode.java ShapePainter.java StrokeShapePainter.java Log: Added getPaintedBounds to the ShapePainter interface so that it is used in ShapeNode's getPrimitiveBounds instead of getPaintedArea. This is important because getPaintedArea is very costly on CompositeShapePainter (it uses the Area class). This should solve the performance degradation problem seen on large files. Revision Changes Path 1.12 +21 -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.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- CompositeShapePainter.java 3 Jan 2002 12:27:26 -0000 1.11 +++ CompositeShapePainter.java 6 Feb 2002 13:18:33 -0000 1.12 @@ -12,6 +12,7 @@ import java.awt.Shape; import java.awt.geom.Area; import java.awt.geom.GeneralPath; +import java.awt.geom.Rectangle2D; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -20,7 +21,7 @@ * A shape painter which consists of multiple shape painters. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: CompositeShapePainter.java,v 1.11 2002/01/03 12:27:26 tkormann Exp $ + * @version $Id: CompositeShapePainter.java,v 1.12 2002/02/06 13:18:33 vhardy Exp $ */ public class CompositeShapePainter implements ShapePainter { @@ -118,6 +119,25 @@ return null; } } + + /** + * Returns the bounds of the area painted by this shape painter + */ + public Rectangle2D getPaintedBounds(){ + if (painters != null) { + GeneralPath paintedArea = new GeneralPath(); + for (int i=0; i < count; ++i) { + Shape s = painters[i].getPaintedArea(); + if (s != null) { + paintedArea.append(s, false); + } + } + return paintedArea.getBounds2D(); + } else { + return null; + } + } + /** * Sets the Shape this shape painter is associated with. 1.8 +13 -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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- FillShapePainter.java 18 Sep 2001 21:18:59 -0000 1.7 +++ FillShapePainter.java 6 Feb 2002 13:18:33 -0000 1.8 @@ -11,12 +11,13 @@ import java.awt.Shape; import java.awt.Graphics2D; import java.awt.Paint; +import java.awt.geom.Rectangle2D; /** * A shape painter that can be used to fill a shape. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: FillShapePainter.java,v 1.7 2001/09/18 21:18:59 deweese Exp $ + * @version $Id: FillShapePainter.java,v 1.8 2002/02/06 13:18:33 vhardy Exp $ */ public class FillShapePainter implements ShapePainter { @@ -70,6 +71,17 @@ */ public Shape getPaintedArea(){ return shape; + } + + /** + * Returns the bounds of the area painted by this shape painter + */ + public Rectangle2D getPaintedBounds(){ + if (shape != null){ + return shape.getBounds2D(); + } else { + return null; + } } /** 1.6 +13 -1 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MarkerShapePainter.java 18 Sep 2001 21:19:00 -0000 1.5 +++ MarkerShapePainter.java 6 Feb 2002 13:18:33 -0000 1.6 @@ -23,7 +23,7 @@ * A shape painter that can be used to paint markers on a shape. * * @author <a href="[EMAIL PROTECTED]">Vincent Hardy</a> - * @version $Id: MarkerShapePainter.java,v 1.5 2001/09/18 21:19:00 deweese Exp $ + * @version $Id: MarkerShapePainter.java,v 1.6 2002/02/06 13:18:33 vhardy Exp $ */ public class MarkerShapePainter implements ShapePainter { @@ -114,6 +114,18 @@ buildMarkerGroup(); } return markerGroup.getBounds(); + } + + /** + * Returns the bounds of the area painted by this shape painter + */ + public Rectangle2D getPaintedBounds(){ + Shape shape = getPaintedArea(); + if (shape != null){ + return shape.getBounds2D(); + } else { + return null; + } } /** 1.14 +4 -3 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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- ShapeNode.java 23 Jan 2002 14:14:08 -0000 1.13 +++ ShapeNode.java 6 Feb 2002 13:18:33 -0000 1.14 @@ -20,7 +20,7 @@ * A graphics node that represents a shape. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: ShapeNode.java,v 1.13 2002/01/23 14:14:08 deweese Exp $ + * @version $Id: ShapeNode.java,v 1.14 2002/02/06 13:18:33 vhardy Exp $ */ public class ShapeNode extends AbstractGraphicsNode { @@ -219,8 +219,9 @@ if ((shape == null) || (shapePainter == null)) { return null; } - paintedArea = shapePainter.getPaintedArea(); - primitiveBounds = paintedArea.getBounds2D(); + // paintedArea = shapePainter.getPaintedArea(); + // primitiveBounds = paintedArea.getBounds2D(); + primitiveBounds = shapePainter.getPaintedBounds(); // Make sure we haven't been interrupted if (Thread.currentThread().isInterrupted()) { 1.9 +7 -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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ShapePainter.java 18 Sep 2001 21:19:00 -0000 1.8 +++ ShapePainter.java 6 Feb 2002 13:18:33 -0000 1.9 @@ -10,12 +10,13 @@ import java.awt.Shape; import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; /** * Renders the shape of a <tt>ShapeNode</tt>. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: ShapePainter.java,v 1.8 2001/09/18 21:19:00 deweese Exp $ + * @version $Id: ShapePainter.java,v 1.9 2002/02/06 13:18:33 vhardy Exp $ */ public interface ShapePainter { @@ -30,6 +31,11 @@ * Returns the area painted by this shape painter. */ Shape getPaintedArea(); + + /** + * Returns the bounds of the area painted by this shape painter + */ + Rectangle2D getPaintedBounds(); /** * Sets the Shape this shape painter is associated with. 1.9 +15 -1 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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- StrokeShapePainter.java 18 Sep 2001 21:19:00 -0000 1.8 +++ StrokeShapePainter.java 6 Feb 2002 13:18:33 -0000 1.9 @@ -12,12 +12,13 @@ import java.awt.Graphics2D; import java.awt.Stroke; import java.awt.Paint; +import java.awt.geom.Rectangle2D; /** * A shape painter that can be used to draw the outline of a shape. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: StrokeShapePainter.java,v 1.8 2001/09/18 21:19:00 deweese Exp $ + * @version $Id: StrokeShapePainter.java,v 1.9 2002/02/06 13:18:33 vhardy Exp $ */ public class StrokeShapePainter implements ShapePainter { @@ -91,6 +92,19 @@ return null; } } + + /** + * Returns the bounds of the area painted by this shape painter + */ + public Rectangle2D getPaintedBounds(){ + Shape painted = getPaintedArea(); + if (painted != null){ + return painted.getBounds2D(); + } else { + return null; + } + } + /** * Sets the Shape this shape painter is associated with.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]