You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by vh...@apache.org on 2001/02/06 02:56:40 UTC

cvs commit: xml-batik/sources/org/apache/batik/gvt CompositeShapePainter.java FillShapePainter.java ShapeNode.java ShapePainter.java StrokeShapePainter.java DecoratedShapeNode.java

vhardy      01/02/05 17:56:39

  Modified:    sources/org/apache/batik/bridge CSSUtilities.java
                        SVGDecoratedShapeElementBridge.java
                        SVGShapeElementBridge.java
               sources/org/apache/batik/experiment
                        TextPathElementBridge.java
               sources/org/apache/batik/gvt CompositeShapePainter.java
                        FillShapePainter.java ShapeNode.java
                        ShapePainter.java StrokeShapePainter.java
  Removed:     sources/org/apache/batik/gvt DecoratedShapeNode.java
  Log:
  a. Markers are now rendered by a MarkerShapePainter instead of a DecoratedShapeNode,
     following the confirmation by the SVG WG that events do not need to be supported
     on markers. This is a simpler, more efficient design.
  
  b. Modification of the ShapePainter interface so that there is a 1:1 relationship
     between a ShapePainter and a Shape. That relation may be changed by the
     setShape method.
  
  c. Added a parameter to the getPaintedArea method in ShapePainter to propagate
     the GraphicsNodeRenderContext. This is consistent with what we do for other
     geometry computations and was necessary for the MarkerShapePainter implementation.
  
  Revision  Changes    Path
  1.9       +18 -13    xml-batik/sources/org/apache/batik/bridge/CSSUtilities.java
  
  Index: CSSUtilities.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/CSSUtilities.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CSSUtilities.java	2001/02/05 07:48:40	1.8
  +++ CSSUtilities.java	2001/02/06 01:56:35	1.9
  @@ -63,7 +63,7 @@
    * A collection of utility methods involving CSS.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: CSSUtilities.java,v 1.8 2001/02/05 07:48:40 hillion Exp $
  + * @version $Id: CSSUtilities.java,v 1.9 2001/02/06 01:56:35 vhardy Exp $
    */
   public class CSSUtilities implements SVGConstants {
   
  @@ -381,26 +381,28 @@
       /**
        * Returns the <tt>ShapePainter</tt> for the specified Element
        * using the specified context and css style declaration.
  +     * @param shape shape to be stroked and filled
        * @param svgElement the SVG Element
        * @param ctx the bridge context
        * @param decl the css style declaration
        * @param uctx the UnitProcessor context
        */
  -    public static ShapePainter convertStrokeAndFill(SVGElement svgElement,
  -                                                GraphicsNode node,
  -                                                BridgeContext ctx,
  -                                                CSSStyleDeclaration decl,
  -                                                UnitProcessor.Context uctx){
  +    public static ShapePainter convertStrokeAndFill(Shape shape, 
  +                                                    SVGElement svgElement,
  +                                                    GraphicsNode node,
  +                                                    BridgeContext ctx,
  +                                                    CSSStyleDeclaration decl,
  +                                                    UnitProcessor.Context uctx){
   
           // resolve fill
  -        ShapePainter fillPainter = convertFill(svgElement, node, ctx,
  +        ShapePainter fillPainter = convertFill(shape, svgElement, node, ctx,
                                                  decl, uctx);
           // resolve stroke
  -        ShapePainter strokePainter = convertStroke(svgElement, node, ctx,
  +        ShapePainter strokePainter = convertStroke(shape, svgElement, node, ctx,
                                                      decl, uctx);
           ShapePainter painter = null;
           if (fillPainter != null && strokePainter != null) {
  -            CompositeShapePainter comp = new CompositeShapePainter();
  +            CompositeShapePainter comp = new CompositeShapePainter(shape);
               comp.addShapePainter(fillPainter);
               comp.addShapePainter(strokePainter);
               painter = comp;
  @@ -416,12 +418,13 @@
        * Returns the <tt>ShapePainter</tt> used to draw the outline of
        * the specified Element using the specified context and css style
        * declaration.
  +     * @param shape shape to be stroked.
        * @param svgElement the SVG Element
        * @param ctx the bridge context
        * @param decl the css style declaration
        * @param uctx the UnitProcessor context
        */
  -    public static ShapePainter convertStroke(SVGElement svgElement,
  +    public static ShapePainter convertStroke(Shape shape, SVGElement svgElement,
                                                GraphicsNode node,
                                                BridgeContext ctx,
                                                CSSStyleDeclaration decl,
  @@ -429,7 +432,7 @@
   
           Stroke stroke = convertStrokeToBasicStroke(svgElement, ctx, decl, uctx);
           Paint paint = convertStrokeToPaint(svgElement, node, ctx, decl, uctx);
  -        StrokeShapePainter painter = new StrokeShapePainter();
  +        StrokeShapePainter painter = new StrokeShapePainter(shape);
           painter.setStroke(stroke);
           painter.setPaint(paint);
           return painter;
  @@ -568,12 +571,14 @@
       /**
        * Returns the <tt>ShapePainter</tt> used to fill the specified
        * Element using the specified context and css style declaration.
  +     * @param shape Shape to be filled
        * @param svgElement the SVG Element
        * @param ctx the bridge context
        * @param decl the css style declaration
        * @param uctx the UnitProcessor context
        */
  -    public static ShapePainter convertFill(SVGElement svgElement,
  +    public static ShapePainter convertFill(Shape shape,
  +                                           SVGElement svgElement,
                                              GraphicsNode node,
                                              BridgeContext ctx,
                                              CSSStyleDeclaration decl,
  @@ -586,7 +591,7 @@
                                                decl,
                                                uctx);
           if(fillPaint != null){
  -            painter = new FillShapePainter();
  +            painter = new FillShapePainter(shape);
               painter.setPaint(fillPaint);
           }
   
  
  
  
  1.4       +31 -40    xml-batik/sources/org/apache/batik/bridge/SVGDecoratedShapeElementBridge.java
  
  Index: SVGDecoratedShapeElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGDecoratedShapeElementBridge.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SVGDecoratedShapeElementBridge.java	2001/02/05 09:55:29	1.3
  +++ SVGDecoratedShapeElementBridge.java	2001/02/06 01:56:35	1.4
  @@ -19,7 +19,8 @@
   import org.apache.batik.bridge.BridgeMutationEvent;
   import org.apache.batik.bridge.GraphicsNodeBridge;
   import org.apache.batik.bridge.IllegalAttributeValueException;
  -import org.apache.batik.gvt.DecoratedShapeNode;
  +import org.apache.batik.gvt.CompositeShapePainter;
  +import org.apache.batik.gvt.MarkerShapePainter;
   import org.apache.batik.gvt.GraphicsNode;
   import org.apache.batik.gvt.GraphicsNodeRenderContext;
   import org.apache.batik.gvt.Marker;
  @@ -42,43 +43,19 @@
    * A factory for the SVG elements that represents a shape.
    *
    * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  - * @version $Id: SVGDecoratedShapeElementBridge.java,v 1.3 2001/02/05 09:55:29 hillion Exp $
  + * @version $Id: SVGDecoratedShapeElementBridge.java,v 1.4 2001/02/06 01:56:35 vhardy Exp $
    */
   public abstract class SVGDecoratedShapeElementBridge 
       extends SVGShapeElementBridge {
       
  -    public GraphicsNode createGraphicsNode(BridgeContext ctx, Element element){
  -        SVGElement svgElement = (SVGElement) element;
  -        CSSStyleDeclaration cssDecl
  -            = ctx.getViewCSS().getComputedStyle(element, null);
  -        UnitProcessor.Context uctx
  -            = new DefaultUnitProcessorContext(ctx,
  -                                              cssDecl);
  -
  -        DecoratedShapeNode node = new DecoratedShapeNode();
  -
  -        // Initialize the transform
  -        AffineTransform at =
  -            SVGUtilities.convertAffineTransform(element,
  -                                                ATTR_TRANSFORM);
  -        node.setTransform(at);
  -        // Initialize the shape of the ShapeNode
  -        buildShape(ctx, svgElement, node, cssDecl, uctx);
  -
  -        return node;
  -    }
  -
  -    public void buildGraphicsNode(GraphicsNode gn, 
  -                                  BridgeContext ctx,
  -                                  Element element) {
  -        DecoratedShapeNode node = (DecoratedShapeNode)gn;
  -
  -        SVGElement svgElement = (SVGElement) element;
  -        CSSStyleDeclaration cssDecl
  -            = ctx.getViewCSS().getComputedStyle(element, null);
  -        UnitProcessor.Context uctx
  -            = new DefaultUnitProcessorContext(ctx,
  -                                              cssDecl);
  +    protected ShapePainter convertPainter(SVGElement svgElement,
  +                                          ShapeNode node,
  +                                          CSSStyleDeclaration cssDecl,
  +                                          UnitProcessor.Context uctx,
  +                                          BridgeContext ctx){
  +        ShapePainter strokeAndFill =
  +            super.convertPainter(svgElement, node, cssDecl,
  +                                 uctx, ctx);
   
           //
           // Extract the marker properties
  @@ -90,22 +67,36 @@
               = CSSUtilities.convertMarker(svgElement,
                                            CSS_MARKER_START_PROPERTY,
                                            ctx, cssDecl, uctx);
  -        node.setStartMarker(startMarker);
  -        
           Marker endMarker 
               = CSSUtilities.convertMarker(svgElement,
                                            CSS_MARKER_END_PROPERTY,
                                            ctx, cssDecl, uctx);
  -        node.setEndMarker(endMarker);
  -        
           Marker middleMarker 
               = CSSUtilities.convertMarker(svgElement,
                                            CSS_MARKER_MID_PROPERTY,
                                            ctx, cssDecl, uctx);
           
  -        node.setMiddleMarker(middleMarker);
  +        ShapePainter painter = strokeAndFill;
   
  +        if(startMarker  != null  ||
  +           middleMarker != null  ||
  +           endMarker    != null) {
  +            MarkerShapePainter markerPainter = new MarkerShapePainter(node.getShape());
  +            markerPainter.setStartMarker(startMarker);
  +            markerPainter.setEndMarker(endMarker);
  +            markerPainter.setMiddleMarker(middleMarker);
  +            if(strokeAndFill != null){
  +                CompositeShapePainter compositePainter 
  +                    = new CompositeShapePainter(node.getShape());
  +                compositePainter.addShapePainter(strokeAndFill);
  +                compositePainter.addShapePainter(markerPainter);
  +                painter = compositePainter;
  +            }
  +            else{
  +                painter = markerPainter;
  +            }
  +        }
   
  -        super.buildGraphicsNode(gn, ctx, element);
  +        return painter;
       }
   }
  
  
  
  1.4       +15 -4     xml-batik/sources/org/apache/batik/bridge/SVGShapeElementBridge.java
  
  Index: SVGShapeElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGShapeElementBridge.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SVGShapeElementBridge.java	2001/02/01 13:45:46	1.3
  +++ SVGShapeElementBridge.java	2001/02/06 01:56:36	1.4
  @@ -41,7 +41,7 @@
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
    * @author <a href="mailto:cjolif@ilog.fr">Christophe Jolif</a>
  - * @version $Id: SVGShapeElementBridge.java,v 1.3 2001/02/01 13:45:46 tkormann Exp $
  + * @version $Id: SVGShapeElementBridge.java,v 1.4 2001/02/06 01:56:36 vhardy Exp $
    */
   public abstract class SVGShapeElementBridge implements GraphicsNodeBridge,
                                                          SVGConstants {
  @@ -77,9 +77,11 @@
                                                 cssDecl);
   
           // Initialize the style properties
  -        ShapePainter painter
  -            = CSSUtilities.convertStrokeAndFill(svgElement, node,
  -                                                ctx, cssDecl, uctx);
  +        ShapePainter painter = convertPainter(svgElement,
  +                                              node,
  +                                              cssDecl,
  +                                              uctx, ctx);
  +
           node.setShapePainter(painter);
   
           // Set node composite
  @@ -104,6 +106,15 @@
           // <!> TODO only when binding is enabled
           BridgeEventSupport.addDOMListener(ctx, element);
           ctx.bind(element, node);
  +    }
  +
  +    protected ShapePainter convertPainter(SVGElement svgElement,
  +                                          ShapeNode node,
  +                                          CSSStyleDeclaration cssDecl,
  +                                          UnitProcessor.Context uctx,
  +                                          BridgeContext ctx){
  +        return CSSUtilities.convertStrokeAndFill(node.getShape(), svgElement, node,
  +                                                 ctx, cssDecl, uctx);
       }
   
       public void update(BridgeMutationEvent evt) {
  
  
  
  1.7       +2 -2      xml-batik/sources/org/apache/batik/experiment/TextPathElementBridge.java
  
  Index: TextPathElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/experiment/TextPathElementBridge.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TextPathElementBridge.java	2001/02/01 13:45:49	1.6
  +++ TextPathElementBridge.java	2001/02/06 01:56:36	1.7
  @@ -69,7 +69,7 @@
    * A factory for the &lt;textPath&gt; SVG element.
    *
    * @author <a href="mailto:dean@w3.org">Dean Jackson</a>
  - * @version $Id: TextPathElementBridge.java,v 1.6 2001/02/01 13:45:49 tkormann Exp $
  + * @version $Id: TextPathElementBridge.java,v 1.7 2001/02/06 01:56:36 vhardy Exp $
    */
   public class TextPathElementBridge implements GraphicsNodeBridge, SVGConstants {
       protected final static Map fonts = new HashMap(11);
  @@ -418,7 +418,7 @@
   
           // Initialize the style properties
           ShapePainter painter
  -            = CSSUtilities.convertStrokeAndFill(svgElement, node,
  +            = CSSUtilities.convertStrokeAndFill(node.getShape(), svgElement, node,
                                                   ctx, cssDecl, uctx);
           node.setShapePainter(painter);
   
  
  
  
  1.4       +45 -10    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CompositeShapePainter.java	2001/01/26 15:39:52	1.3
  +++ CompositeShapePainter.java	2001/02/06 01:56:36	1.4
  @@ -20,9 +20,13 @@
    * A shape painter which consists of multiple shape painters.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: CompositeShapePainter.java,v 1.3 2001/01/26 15:39:52 tkormann Exp $
  + * @version $Id: CompositeShapePainter.java,v 1.4 2001/02/06 01:56:36 vhardy Exp $
    */
   public class CompositeShapePainter implements ShapePainter {
  +    /**
  +     * The shape associated with this painter
  +     */
  +    protected Shape shape;
   
       /** The enclosed <tt>ShapePainter</tt>s of this composite shape painter. */
       protected ShapePainter [] painters;
  @@ -32,7 +36,13 @@
       /**
        * Constructs a new empty <tt>CompositeShapePainter</tt>.
        */
  -    public CompositeShapePainter() {}
  +    public CompositeShapePainter(Shape shape) {
  +        if(shape == null){
  +            throw new IllegalArgumentException();
  +        }
  +
  +        this.shape = shape;
  +    }
   
       /**
        * Adds the specified shape painter.
  @@ -42,6 +52,11 @@
           if (shapePainter == null) {
               return;
           }
  +
  +        if(this.shape != shapePainter.getShape()){
  +            shapePainter.setShape(shape);
  +        }
  +
           if (painters == null) {
               painters = new ShapePainter[2];
           }
  @@ -55,32 +70,52 @@
   
       /**
        * Paints the specified shape using the specified Graphics2D and context.
  -     * @param shape the shape to paint
        * @param g2d the Graphics2D to use
        * @param ctx the render context to use
        */
  -    public void paint(Shape shape,
  -                      Graphics2D g2d,
  +    public void paint(Graphics2D g2d,
                         GraphicsNodeRenderContext ctx) {
           if (painters != null) {
               for (int i=0; i < count; ++i) {
  -                painters[i].paint(shape, g2d, ctx);
  +                painters[i].paint(g2d, ctx);
               }
           }
       }
   
       /**
  -     * Returns the area painted by this painter for a given input shape
  -     * @param shape the shape to paint
  +     * Returns the area painted by this painter 
        */
  -    public Shape getPaintedArea(Shape shape){
  +    public Shape getPaintedArea(GraphicsNodeRenderContext rc){
           // <!> FIX ME: Use of GeneralPath is a work around Area problems.
           GeneralPath paintedArea = new GeneralPath();
           if (painters != null) {
               for (int i=0; i < count; ++i) {
  -                paintedArea.append(painters[i].getPaintedArea(shape), false);
  +                paintedArea.append(painters[i].getPaintedArea(rc), false);
               }
           }
           return paintedArea;
  +    }
  +
  +    /**
  +     * Sets the Shape this painter is associated with.
  +     * @param shape new shape this painter should be associated with.
  +     *        should not be null.
  +     */
  +    public void setShape(Shape shape){
  +        if (painters != null) {
  +            for (int i=0; i < count; ++i) {
  +                painters[i].setShape(shape);
  +            }
  +        }
  +        this.shape = shape;
  +    }
  +
  +    /**
  +     * Gets the Shape this painter is associated with.
  +     *
  +     * @return shape associated with this Painter.
  +     */
  +    public Shape getShape(){
  +        return shape;
       }
   }
  
  
  
  1.4       +31 -6     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FillShapePainter.java	2001/01/26 15:39:52	1.3
  +++ FillShapePainter.java	2001/02/06 01:56:38	1.4
  @@ -16,9 +16,11 @@
    * A shape painter that can be used to fill a shape.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: FillShapePainter.java,v 1.3 2001/01/26 15:39:52 tkormann Exp $
  + * @version $Id: FillShapePainter.java,v 1.4 2001/02/06 01:56:38 vhardy Exp $
    */
   public class FillShapePainter implements ShapePainter {
  +    /** The Shape to be painted */
  +    protected Shape shape;
   
       /** The paint attribute used to fill the shape. */
       protected Paint paint;
  @@ -26,8 +28,14 @@
       /**
        * Constructs a new <tt>FillShapePainter</tt> that can be used to fill
        * a <tt>Shape</tt>.
  +     *
  +     * @param shape Shape to be painted by this painter. Should not be null
        */
  -    public FillShapePainter() {}
  +    public FillShapePainter(Shape shape) {
  +        if(shape == null){
  +            throw new IllegalArgumentException();
  +        }
  +    }
   
       /**
        * Sets the paint used to fill a shape.
  @@ -45,9 +53,8 @@
        * @param g2d the Graphics2D to use
        * @param ctx the render context to use
        */
  -     public void paint(Shape shape,
  -                       Graphics2D g2d,
  -                      GraphicsNodeRenderContext ctx) {
  +     public void paint(Graphics2D g2d,
  +                       GraphicsNodeRenderContext ctx) {
           if (paint != null) {
               g2d.setPaint(paint);
               g2d.fill(shape);
  @@ -58,8 +65,26 @@
        * Returns the area painted by this painter for a given input shape
        *
        * @param shape the shape to paint
  +     */
  +    public Shape getPaintedArea(GraphicsNodeRenderContext rc){
  +        return shape;
  +    }
  +
  +    /**
  +     * Sets the Shape this painter is associated with.
  +     * @param shape new shape this painter should be associated with.
  +     *        should not be null.
  +     */
  +    public void setShape(Shape shape){
  +        this.shape = shape;
  +    }
  +
  +    /**
  +     * Gets the Shape this painter is associated with.
  +     *
  +     * @return shape associated with this Painter.
        */
  -    public Shape getPaintedArea(Shape shape){
  +    public Shape getShape(){
           return shape;
       }
   }
  
  
  
  1.3       +9 -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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ShapeNode.java	2001/01/24 16:03:31	1.2
  +++ ShapeNode.java	2001/02/06 01:56:38	1.3
  @@ -20,7 +20,7 @@
    * A graphics node that represents a shape.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: ShapeNode.java,v 1.2 2001/01/24 16:03:31 tkormann Exp $
  + * @version $Id: ShapeNode.java,v 1.3 2001/02/06 01:56:38 vhardy Exp $
    */
   public class ShapeNode extends AbstractGraphicsNode {
   
  @@ -66,6 +66,9 @@
       public void setShape(Shape newShape) {
           invalidateGeometryCache();
           this.shape = newShape;
  +        if(this.shapePainter != null){
  +            this.shapePainter.setShape(newShape);
  +        }
       }
   
       /**
  @@ -84,6 +87,9 @@
       public void setShapePainter(ShapePainter newShapePainter) {
           invalidateGeometryCache();
           this.shapePainter = newShapePainter;
  +        if(shape != this.shapePainter.getShape()){
  +            shapePainter.setShape(shape);
  +        }
       }
   
       /**
  @@ -106,7 +112,7 @@
        */
       public void primitivePaint(Graphics2D g2d, GraphicsNodeRenderContext rc) {
           if (shapePainter != null) {
  -            shapePainter.paint(shape, g2d, rc);
  +            shapePainter.paint(g2d, rc);
           }
       }
   
  @@ -180,7 +186,7 @@
               if ((shape == null) || (shapePainter == null)) {
                   return null;
               }
  -            paintedArea = shapePainter.getPaintedArea(shape);
  +            paintedArea = shapePainter.getPaintedArea(rc);
               primitiveBounds = paintedArea.getBounds2D();
           }
           return primitiveBounds;
  
  
  
  1.5       +18 -6     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ShapePainter.java	2000/11/10 00:47:48	1.4
  +++ ShapePainter.java	2001/02/06 01:56:39	1.5
  @@ -15,22 +15,34 @@
    * Renders the shape of a <tt>ShapeNode</tt>.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: ShapePainter.java,v 1.4 2000/11/10 00:47:48 tkormann Exp $
  + * @version $Id: ShapePainter.java,v 1.5 2001/02/06 01:56:39 vhardy Exp $
    */
   public interface ShapePainter {
   
       /**
        * Paints the specified shape using the specified Graphics2D and context.
  -     * @param shape the shape to paint
        * @param g2d the Graphics2D to use
        * @param ctx the render context to use
        */
  -    void paint(Shape shape, Graphics2D g2d, GraphicsNodeRenderContext ctx);
  +    void paint(Graphics2D g2d, GraphicsNodeRenderContext ctx);
   
       /**
  -     * Returns the area painted by this painter for a given input shape
  +     * Returns the area painted by this painter
        *
  -     * @param shape the shape to paint
        */
  -    Shape getPaintedArea(Shape shape);
  +    Shape getPaintedArea(GraphicsNodeRenderContext rc);
  +
  +    /**
  +     * Sets the Shape this painter is associated with.
  +     * @param shape new shape this painter should be associated with.
  +     *        should not be null.
  +     */
  +    public void setShape(Shape shape);
  +
  +    /**
  +     * Gets the Shape this painter is associated with.
  +     *
  +     * @return shape associated with this Painter.
  +     */
  +    public Shape getShape();
   }
  
  
  
  1.4       +33 -5     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StrokeShapePainter.java	2001/01/26 15:39:53	1.3
  +++ StrokeShapePainter.java	2001/02/06 01:56:39	1.4
  @@ -17,9 +17,11 @@
    * A shape painter that can be used to draw the outline of a shape.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: StrokeShapePainter.java,v 1.3 2001/01/26 15:39:53 tkormann Exp $
  + * @version $Id: StrokeShapePainter.java,v 1.4 2001/02/06 01:56:39 vhardy Exp $
    */
   public class StrokeShapePainter implements ShapePainter {
  +    /** Shape painted by this painter */
  +    protected Shape shape;
   
       /**
        * The stroke attribute used to draw the outline of the shape.
  @@ -34,8 +36,16 @@
       /**
        * Constructs a new <tt>ShapePainter</tt> that can be used to draw
        * the outline of a <tt>Shape</tt>.
  +     * 
  +     * @param shape shape to be painted by this painter. Should not be null.
        */
  -    public StrokeShapePainter() {}
  +    public StrokeShapePainter(Shape shape) {
  +        if(shape == null){
  +            throw new IllegalArgumentException();
  +        }
  +
  +        this.shape = shape;
  +    }
   
       /**
        * Sets the stroke used to draw the outline of a shape.
  @@ -63,8 +73,7 @@
        * @param g2d the Graphics2D to use
        * @param ctx the render context to use
        */
  -    public void paint(Shape shape,
  -                      Graphics2D g2d,
  +    public void paint(Graphics2D g2d,
                         GraphicsNodeRenderContext ctx) {
           if (stroke != null && paint != null) {
               g2d.setPaint(paint);
  @@ -78,11 +87,30 @@
        *
        * @param shape the shape to paint
        */
  -    public Shape getPaintedArea(Shape shape){
  +    public Shape getPaintedArea(GraphicsNodeRenderContext rc){
           if(paint != null && stroke != null){
               return stroke.createStrokedShape(shape);
           } else {
               return shape;
           }
       }
  +
  +    /**
  +     * Sets the Shape this painter is associated with.
  +     * @param shape new shape this painter should be associated with.
  +     *        should not be null.
  +     */
  +    public void setShape(Shape shape){
  +        this.shape = shape;
  +    }
  +
  +    /**
  +     * Gets the Shape this painter is associated with.
  +     *
  +     * @return shape associated with this Painter.
  +     */
  +    public Shape getShape(){
  +        return shape;
  +    }
  +
   }