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 de...@apache.org on 2003/05/30 03:07:17 UTC

cvs commit: xml-batik/sources/org/apache/batik/gvt AbstractGraphicsNode.java CompositeGraphicsNode.java CompositeShapePainter.java FillShapePainter.java GraphicsNode.java MarkerShapePainter.java ProxyGraphicsNode.java RasterImageNode.java ShapeNode.java ShapePainter.java StrokeShapePainter.java TextNode.java

deweese     2003/05/29 18:07:16

  Modified:    sources/org/apache/batik/bridge PaintServer.java
                        SVGShapeElementBridge.java
               sources/org/apache/batik/extension/svg
                        MultiResGraphicsNode.java
               sources/org/apache/batik/gvt AbstractGraphicsNode.java
                        CompositeGraphicsNode.java
                        CompositeShapePainter.java FillShapePainter.java
                        GraphicsNode.java MarkerShapePainter.java
                        ProxyGraphicsNode.java RasterImageNode.java
                        ShapeNode.java ShapePainter.java
                        StrokeShapePainter.java TextNode.java
  Log:
  The pointer-events property is now handled correctly for elements
  without fill or stroke paint.
  
  Revision  Changes    Path
  1.10      +17 -21    xml-batik/sources/org/apache/batik/bridge/PaintServer.java
  
  Index: PaintServer.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/PaintServer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PaintServer.java	11 Apr 2003 13:54:44 -0000	1.9
  +++ PaintServer.java	30 May 2003 01:07:14 -0000	1.10
  @@ -132,34 +132,30 @@
                                                       ShapeNode node,
                                                       BridgeContext ctx) {
   
  -        Paint fillPaint = convertFillPaint(e, node, ctx);
  -        Paint strokePaint = convertStrokePaint(e, node, ctx);
  +        Paint  fillPaint   = convertFillPaint  (e, node, ctx);
  +        Paint  strokePaint = convertStrokePaint(e, node, ctx);
  +        Stroke stroke      = convertStroke     (e);
   
           Shape shape = node.getShape();
           if (shape == null) return null;
  -        if (fillPaint != null && strokePaint != null) {
  -            FillShapePainter fp = new FillShapePainter(shape);
  -            fp.setPaint(fillPaint);
   
  -            StrokeShapePainter sp = new StrokeShapePainter(shape);
  -            sp.setStroke(PaintServer.convertStroke(e));
  -            sp.setPaint(strokePaint);
  -            CompositeShapePainter cp = new CompositeShapePainter(shape);
  -            cp.addShapePainter(fp);
  -            cp.addShapePainter(sp);
  -            return cp;
  -        } else if (strokePaint != null) {
  -            StrokeShapePainter sp = new StrokeShapePainter(shape);
  -            sp.setStroke(PaintServer.convertStroke(e));
  -            sp.setPaint(strokePaint);
  -            return sp;
  -        } else if (fillPaint != null) {
  +        if (stroke == null) {
               FillShapePainter fp = new FillShapePainter(shape);
               fp.setPaint(fillPaint);
               return fp;
  -        } else {
  -            return null;
           }
  +
  +        FillShapePainter fp = new FillShapePainter(shape);
  +        fp.setPaint(fillPaint);
  +
  +        StrokeShapePainter sp = new StrokeShapePainter(shape);
  +        sp.setStroke(PaintServer.convertStroke(e));
  +        sp.setPaint(strokePaint);
  +
  +        CompositeShapePainter cp = new CompositeShapePainter(shape);
  +        cp.addShapePainter(fp);
  +        cp.addShapePainter(sp);
  +        return cp;
       }
   
       /////////////////////////////////////////////////////////////////////////
  
  
  
  1.21      +1 -3      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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- SVGShapeElementBridge.java	11 Apr 2003 13:54:54 -0000	1.20
  +++ SVGShapeElementBridge.java	30 May 2003 01:07:15 -0000	1.21
  @@ -132,8 +132,6 @@
       protected  void handleGeometryChanged() {
           super.handleGeometryChanged();
           ShapeNode shapeNode = (ShapeNode)node;
  -        ShapePainter painter = 
  -            PaintServer.convertFillAndStroke(e, shapeNode, ctx);
           shapeNode.setShapePainter(createShapePainter(ctx, e, shapeNode));
       }
   
  
  
  
  1.6       +5 -1      xml-batik/sources/org/apache/batik/extension/svg/MultiResGraphicsNode.java
  
  Index: MultiResGraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/extension/svg/MultiResGraphicsNode.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MultiResGraphicsNode.java	28 May 2003 14:40:57 -0000	1.5
  +++ MultiResGraphicsNode.java	30 May 2003 01:07:15 -0000	1.6
  @@ -179,6 +179,10 @@
           return bounds;
       }
   
  +    public Rectangle2D getSensitiveBounds(){
  +        return bounds;
  +    }
  +
       /**
        * Returns the outline of this node.
        */
  
  
  
  1.48      +41 -14    xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java
  
  Index: AbstractGraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- AbstractGraphicsNode.java	14 Apr 2003 10:53:34 -0000	1.47
  +++ AbstractGraphicsNode.java	30 May 2003 01:07:15 -0000	1.48
  @@ -773,9 +773,9 @@
               t.concatenate(transform);
           }
   
  -        // The painted region, before cliping, masking and compositing is either
  -        // the area painted by the primitive paint or the area painted by the
  -        // filter.
  +        // The painted region, before cliping, masking and compositing
  +        // is either the area painted by the primitive paint or the
  +        // area painted by the filter.
           Rectangle2D tBounds = null;
           if (filter == null) {
               // Use txf, not t
  @@ -827,9 +827,14 @@
       }
   
       /**
  -     * Returns the bounds of the area covered by this node, without taking any
  -     * of its rendering attribute into account. i.e., exclusive of any clipping,
  -     * masking, filtering or stroking, for example.
  +     * Returns the bounds of the area covered by this node, without
  +     * taking any of its rendering attribute into accoun. i.e.,
  +     * exclusive of any clipping, masking, filtering or stroking, for
  +     * example. The returned value is transformed by the concatenation
  +     * of the input transform and this node's transform.
  +     *
  +     * @param txf the affine transform with which this node's transform should
  +     *        be concatenated. Should not be null.
        */
       public Rectangle2D getTransformedGeometryBounds(AffineTransform txf) {
           Rectangle2D tpBounds = getGeometryBounds();
  @@ -846,13 +851,37 @@
       }
   
       /**
  +     * Returns the bounds of the sensitive area covered by this node,
  +     * This includes the stroked area but does not include the effects
  +     * of clipping, masking or filtering. The returned value is
  +     * transformed by the concatenation of the input transform and
  +     * this node's transform.
  +     *
  +     * @param txf the affine transform with which this node's
  +     * transform should be concatenated. Should not be null.
  +     */
  +    public Rectangle2D getTransformedSensitiveBounds(AffineTransform txf) {
  +        Rectangle2D sBounds = getSensitiveBounds();
  +        if (sBounds == null) {
  +            return null;
  +        }
  +        AffineTransform t = txf;
  +        if (transform != null) {
  +            t = new AffineTransform(txf);
  +            t.concatenate(transform);
  +        }
  +
  +        return t.createTransformedShape(sBounds).getBounds2D();
  +    }
  +
  +    /**
        * Returns true if the specified Point2D is inside the boundary of this
        * node, false otherwise.
        *
        * @param p the specified Point2D in the user space
        */
       public boolean contains(Point2D p) {
  -        Rectangle2D b = getBounds();
  +        Rectangle2D b = getSensitiveBounds();
           if (b == null || !b.contains(p)) {
               return false;
           }
  @@ -868,7 +897,6 @@
           case ALL:
               return true;
           case NONE:
  -            return false;
           default:
               return false;
           }
  @@ -881,11 +909,10 @@
        * @param r the specified Rectangle2D in the user node space
        */
       public boolean intersects(Rectangle2D r) {
  -        if (getBounds() != null ){
  -            return getBounds().intersects(r);
  -        } else {
  -            return false;
  -        }
  +        Rectangle2D b = getBounds();
  +        if (b == null) return false;
  +
  +        return b.intersects(r);
       }
   
       /**
  
  
  
  1.32      +80 -6     xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java
  
  Index: CompositeGraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- CompositeGraphicsNode.java	14 Apr 2003 10:53:35 -0000	1.31
  +++ CompositeGraphicsNode.java	30 May 2003 01:07:15 -0000	1.32
  @@ -66,6 +66,11 @@
       private Rectangle2D primitiveBounds;
   
       /**
  +     * Internal Cache: Sensitive bounds.
  +     */
  +    private Rectangle2D sensitiveBounds;
  +
  +    /**
        * Internal Cache: the outline.
        */
       private Shape outline;
  @@ -144,6 +149,7 @@
           super.invalidateGeometryCache();
           geometryBounds = null;
           primitiveBounds = null;
  +        sensitiveBounds = null;
           outline = null;
       }
   
  @@ -212,9 +218,10 @@
       }
   
       /**
  -     * Returns the bounds of the area covered by this node, without taking any
  -     * of its rendering attribute into account. i.e., exclusive of any clipping,
  -     * masking, filtering or stroking, for example.
  +     * Returns the bounds of the area covered by this node, without
  +     * taking any of its rendering attribute into account. i.e.,
  +     * exclusive of any clipping, masking, filtering or stroking, for
  +     * example.
        */
       public Rectangle2D getGeometryBounds() {
           if (geometryBounds == null) {
  @@ -278,13 +285,80 @@
       }
   
       /**
  +     * Returns the bounds of the sensitive area covered by this node,
  +     * This includes the stroked area but does not include the effects
  +     * of clipping, masking or filtering.
  +     */
  +    public Rectangle2D getSensitiveBounds() {
  +        if (sensitiveBounds != null)
  +            return sensitiveBounds;
  +
  +        // System.out.println("sensitiveBoundsBounds are null");
  +        int i=0;
  +        while(sensitiveBounds == null && i < count){
  +            sensitiveBounds = 
  +                children[i++].getTransformedSensitiveBounds(IDENTITY);
  +        }
  +
  +        Rectangle2D cgb = null;
  +        while (i<count) {
  +            cgb = children[i++].getTransformedSensitiveBounds(IDENTITY);
  +            if (cgb != null) {
  +                if (sensitiveBounds == null)
  +                    // another thread has set the geometry bounds to null,
  +                    // need to recall this function
  +                    return getSensitiveBounds();
  +                
  +                sensitiveBounds.add(cgb);
  +            }
  +        }
  +
  +        return sensitiveBounds;
  +    }
  +
  +    /**
  +     * Returns the bounds of the sensitive area covered by this node,
  +     * This includes the stroked area but does not include the effects
  +     * of clipping, masking or filtering. The returned value is
  +     * transformed by the concatenation of the input transform and
  +     * this node's transform.
  +     *
  +     * @param txf the affine transform with which this node's
  +     * transform should be concatenated. Should not be null.
  +     */
  +    public Rectangle2D getTransformedSensitiveBounds(AffineTransform txf) {
  +        AffineTransform t = txf;
  +        if (transform != null) {
  +            t = new AffineTransform(txf);
  +            t.concatenate(transform);
  +        }
  +	
  +        Rectangle2D sb = null;
  +        int i=0;
  +        while (sb == null && i < count) {
  +            sb = children[i++].getTransformedSensitiveBounds(t);
  +        }
  +	
  +        Rectangle2D csb = null;
  +        while (i < count) {
  +            csb = children[i++].getTransformedSensitiveBounds(t);
  +            if (csb != null) {
  +                sb.add(csb);
  +            }
  +        }
  +
  +        return sb;
  +    }
  +
  +    /**
        * Returns true if the specified Point2D is inside the boundary of this
        * node, false otherwise.
        *
        * @param p the specified Point2D in the user space
        */
       public boolean contains(Point2D p) {
  -        if (count > 0 && getBounds().contains(p)) {
  +        Rectangle2D bounds = getSensitiveBounds();
  +        if (count > 0 && bounds != null && bounds.contains(p)) {
               Point2D pt = null;
               Point2D cp = null; // Propagated to children
               for (int i=0; i < count; ++i) {
  @@ -312,7 +386,7 @@
        * @param p the specified Point2D in the user space
        */
       public GraphicsNode nodeHitAt(Point2D p) {
  -        Rectangle2D bounds = getBounds();
  +        Rectangle2D bounds = getSensitiveBounds();
           if (count > 0 && bounds != null && bounds.contains(p)) {
               // Go backward because the children are in rendering order
               Point2D pt = null;
  
  
  
  1.16      +51 -21    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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- CompositeShapePainter.java	11 Apr 2003 13:58:30 -0000	1.15
  +++ CompositeShapePainter.java	30 May 2003 01:07:15 -0000	1.16
  @@ -122,38 +122,68 @@
        * Returns the area painted by this shape painter.
        */
       public Shape getPaintedArea(){
  -        if (painters != null) {
  -            Area paintedArea = new Area();
  -            for (int i=0; i < count; ++i) {
  -                Shape s = painters[i].getPaintedArea();
  -                if (s != null) {
  -                    paintedArea.add(new Area(s));
  -                }
  -            }
  -            return paintedArea;
  -        } else {
  +        if (painters == null)
               return null;
  +        Area paintedArea = new Area();
  +        for (int i=0; i < count; ++i) {
  +            Shape s = painters[i].getPaintedArea();
  +            if (s != null) {
  +                paintedArea.add(new Area(s));
  +            }
           }
  +        return paintedArea;
       }
   
       /**
        * Returns the bounds of the area painted by this shape painter
        */
       public Rectangle2D getPaintedBounds2D(){
  -        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 {
  +        if (painters == null) 
               return null;
  +
  +        Rectangle2D bounds = null;
  +        for (int i=0; i < count; ++i) {
  +            Rectangle2D pb = painters[i].getPaintedBounds2D();
  +            if (pb == null) continue;
  +            if (bounds == null) bounds = (Rectangle2D)pb.clone();
  +            else                bounds.add(pb);
           }
  +        return bounds;
       }
   
  +
  +    /**
  +     * Returns the area covered by this shape painter (even if nothing
  +     * is painted there).
  +     */
  +    public Shape getSensitiveArea() {
  +        if (painters == null)
  +            return null;
  +        Area paintedArea = new Area();
  +        for (int i=0; i < count; ++i) {
  +            Shape s = painters[i].getSensitiveArea();
  +            if (s != null) {
  +                paintedArea.add(new Area(s));
  +            }
  +        }
  +        return paintedArea;
  +    }
  +
  +    /**
  +     * Returns the bounds of the area painted by this shape painter
  +     */
  +    public Rectangle2D getSensitiveBounds2D() {
  +        if (painters == null) 
  +            return null;
  +
  +        Rectangle2D bounds = null;
  +        for (int i=0; i < count; ++i) {
  +            Rectangle2D pb = painters[i].getSensitiveBounds2D();
  +            if (bounds == null) bounds = (Rectangle2D)pb.clone();
  +            else                bounds.add(pb);
  +        }
  +        return bounds;
  +    }
   
       /**
        * Sets the Shape this shape painter is associated with.
  
  
  
  1.11      +28 -9     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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- FillShapePainter.java	11 Apr 2003 13:58:30 -0000	1.10
  +++ FillShapePainter.java	30 May 2003 01:07:16 -0000	1.11
  @@ -39,10 +39,10 @@
        * Should not be null.  
        */
       public FillShapePainter(Shape shape) {
  -        if (shape == null) {
  -            throw new IllegalArgumentException();
  -        }
  -	this.shape = shape;
  +        if (shape == null)
  +            throw new IllegalArgumentException("Shape can not be null!");
  +
  +        this.shape = shape;
       }
   
       /**
  @@ -70,6 +70,8 @@
        * Returns the area painted by this shape painter.
        */
       public Shape getPaintedArea(){
  +        if (paint == null)
  +            return null;
           return shape;
       }
   
  @@ -77,11 +79,28 @@
        * Returns the bounds of the area painted by this shape painter
        */
       public Rectangle2D getPaintedBounds2D(){
  -	if (shape != null){
  +        if ((paint == null) || (shape == null))
  +            return  null;
  +
  +	    return shape.getBounds2D();
  +    }
  +
  +    /**
  +     * Returns the area covered by this shape painter (even if not painted).
  +     * 
  +     */
  +    public Shape getSensitiveArea(){
  +        return shape;
  +    }
  +
  +    /**
  +     * Returns the bounds of the area covered by this shape painte
  +     * (even if not painted).
  +     */
  +    public Rectangle2D getSensitiveBounds2D() {
  +        if (shape == null)
  +            return  null;
   	    return shape.getBounds2D();
  -	} else {
  -	    return null;
  -	}
       }
   
       /**
  
  
  
  1.36      +35 -12    xml-batik/sources/org/apache/batik/gvt/GraphicsNode.java
  
  Index: GraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/GraphicsNode.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- GraphicsNode.java	11 Apr 2003 13:58:30 -0000	1.35
  +++ GraphicsNode.java	30 May 2003 01:07:16 -0000	1.36
  @@ -361,13 +361,16 @@
       Rectangle2D getTransformedBounds(AffineTransform txf);
   
       /**
  -     * Returns the bounds of the area covered by this node's primitive paint.
  +     * Returns the bounds of the area covered by this node's primitive
  +     * paint.  This is the painted region of fill and stroke but does
  +     * not account for clipping, masking or filtering.
        */
       Rectangle2D getPrimitiveBounds();
   
       /**
  -     * Returns the bounds of this node's primitivePaint after applying the input
  -     * transform (if any), concatenated with this node's transform (if any).
  +     * Returns the bounds of this node's primitivePaint after applying
  +     * the input transform (if any), concatenated with this node's
  +     * transform (if any).
        *
        * @param txf the affine transform with which this node's transform should
        *        be concatenated. Should not be null.
  @@ -375,23 +378,43 @@
       Rectangle2D getTransformedPrimitiveBounds(AffineTransform txf);
   
       /**
  -     * Returns the bounds of the area covered by this node, without taking any
  -     * of its rendering attribute into account. i.e., exclusive of any clipping,
  -     * masking, filtering or stroking, for example.
  +     * Returns the bounds of the area covered by this node, without
  +     * taking any of its rendering attribute into account. i.e.,
  +     * exclusive of any clipping, masking, filtering or stroking, for
  +     * example.
        */
       Rectangle2D getGeometryBounds();
   
       /**
  -     * Returns the bounds of the area covered by this node, without taking any
  -     * of its rendering attribute into accoun. i.e., exclusive of any clipping,
  -     * masking, filtering or stroking, for example. The returned value is
  -     * transformed by the concatenation of the input transform and this node's
  -     * transform.
  +     * Returns the bounds of the area covered by this node, without
  +     * taking any of its rendering attribute into accoun. i.e.,
  +     * exclusive of any clipping, masking, filtering or stroking, for
  +     * example. The returned value is transformed by the concatenation
  +     * of the input transform and this node's transform.
        *
        * @param txf the affine transform with which this node's transform should
        *        be concatenated. Should not be null.
        */
       Rectangle2D getTransformedGeometryBounds(AffineTransform txf);
  +
  +    /**
  +     * Returns the bounds of the sensitive area covered by this node,
  +     * This includes the stroked area but does not include the effects
  +     * of clipping, masking or filtering.
  +     */
  +    Rectangle2D getSensitiveBounds();
  +
  +    /**
  +     * Returns the bounds of the sensitive area covered by this node,
  +     * This includes the stroked area but does not include the effects
  +     * of clipping, masking or filtering. The returned value is
  +     * transformed by the concatenation of the input transform and
  +     * this node's transform.
  +     *
  +     * @param txf the affine transform with which this node's
  +     * transform should be concatenated. Should not be null.
  +     */
  +    Rectangle2D getTransformedSensitiveBounds(AffineTransform txf);
   
       /**
        * Returns true if the specified Point2D is inside the boundary of this
  
  
  
  1.12      +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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- MarkerShapePainter.java	11 Apr 2003 13:58:30 -0000	1.11
  +++ MarkerShapePainter.java	30 May 2003 01:07:16 -0000	1.12
  @@ -137,6 +137,18 @@
       }
   
       /**
  +     * Returns the area covered by this shape painter (even if not painted).
  +     * This is always null for Markers.
  +     */
  +    public Shape getSensitiveArea() { return null; }
  +
  +    /**
  +     * Returns the bounds of the area covered by this shape painte
  +     * (even if not painted). This is always null for Markers.
  +     */
  +    public Rectangle2D getSensitiveBounds2D() { return null; }
  +
  +    /**
        * Sets the Shape this shape painter is associated with.
        *
        * @param shape new shape this painter should be associated with.
  
  
  
  1.9       +67 -14    xml-batik/sources/org/apache/batik/gvt/ProxyGraphicsNode.java
  
  Index: ProxyGraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/ProxyGraphicsNode.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ProxyGraphicsNode.java	11 Apr 2003 13:58:30 -0000	1.8
  +++ ProxyGraphicsNode.java	30 May 2003 01:07:16 -0000	1.9
  @@ -10,6 +10,7 @@
   
   import java.awt.Graphics2D;
   import java.awt.Shape;
  +import java.awt.geom.AffineTransform;
   import java.awt.geom.Rectangle2D;
   
   /**
  @@ -63,34 +64,86 @@
        * Returns the bounds of the area covered by this node's primitive paint.
        */
       public Rectangle2D getPrimitiveBounds() {
  -        if (source != null) {
  -            return source.getBounds();
  -        } else {
  +        if (source == null) 
  +            return null;
  +
  +        return source.getBounds();
  +    }
  +
  +    /**
  +     * Returns the bounds of this node's primitivePaint after applying
  +     * the input transform (if any), concatenated with this node's
  +     * transform (if any).
  +     *
  +     * @param txf the affine transform with which this node's transform should
  +     *        be concatenated. Should not be null.  */
  +    public Rectangle2D getTransformedPrimitiveBounds(AffineTransform txf) {
  +        if (source == null) 
               return null;
  +
  +        AffineTransform t = txf;
  +        if (transform != null) {
  +            t = new AffineTransform(txf);
  +            t.concatenate(transform);
           }
  +        return source.getTransformedPrimitiveBounds(t);
       }
   
       /**
  -     * Returns the bounds of the area covered by this node, without taking any
  -     * of its rendering attribute into account. i.e., exclusive of any clipping,
  -     * masking, filtering or stroking, for example.
  +     * Returns the bounds of the area covered by this node, without
  +     * taking any of its rendering attribute into account. i.e.,
  +     * exclusive of any clipping, masking, filtering or stroking, for
  +     * example.
        */
       public Rectangle2D getGeometryBounds() {
  -        if (source != null) {
  -            return source.getGeometryBounds();
  -        } else {
  +        if (source == null) 
               return null;
  +
  +        return source.getGeometryBounds();
  +    }
  +
  +    /**
  +     * Returns the bounds of the sensitive area covered by this node,
  +     * This includes the stroked area but does not include the effects
  +     * of clipping, masking or filtering. The returned value is
  +     * transformed by the concatenation of the input transform and
  +     * this node's transform.
  +     *
  +     * @param txf the affine transform with which this node's
  +     * transform should be concatenated. Should not be null.
  +     */
  +    public Rectangle2D getTransformedGeometryBounds(AffineTransform txf) {
  +        if (source == null) 
  +            return null;
  +
  +        AffineTransform t = txf;
  +        if (transform != null) {
  +            t = new AffineTransform(txf);
  +            t.concatenate(transform);
           }
  +        return source.getTransformedGeometryBounds(t);
  +    }
  +
  +
  +    /**
  +     * Returns the bounds of the sensitive area covered by this node,
  +     * This includes the stroked area but does not include the effects
  +     * of clipping, masking or filtering.
  +     */
  +    public Rectangle2D getSensitiveBounds() {
  +        if (source == null) 
  +            return null;
  +
  +        return source.getSensitiveBounds();
       }
   
       /**
        * Returns the outline of this node.
        */
       public Shape getOutline() {
  -        if (source != null) {
  -            return source.getOutline();
  -        } else {
  +        if (source == null) 
               return null;
  -        }
  +
  +        return source.getOutline();
       }
   }
  
  
  
  1.14      +10 -1     xml-batik/sources/org/apache/batik/gvt/RasterImageNode.java
  
  Index: RasterImageNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/RasterImageNode.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- RasterImageNode.java	11 Apr 2003 13:58:31 -0000	1.13
  +++ RasterImageNode.java	30 May 2003 01:07:16 -0000	1.14
  @@ -113,6 +113,15 @@
       }
   
       /**
  +     * Returns the bounds of the sensitive area covered by this node,
  +     * This includes the stroked area but does not include the effects
  +     * of clipping, masking or filtering.
  +     */
  +    public Rectangle2D getSensitiveBounds() {
  +        return image.getBounds2D();
  +    }
  +
  +    /**
        * Returns the outline of this node.
        */
       public Shape getOutline() {
  
  
  
  1.20      +75 -61    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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ShapeNode.java	11 Apr 2003 13:58:32 -0000	1.19
  +++ ShapeNode.java	30 May 2003 01:07:16 -0000	1.20
  @@ -42,6 +42,11 @@
       private Rectangle2D geometryBounds;
   
       /**
  +     * Internal Cache: Sensitive bounds
  +     */
  +    private Rectangle2D sensitiveBounds;
  +
  +    /**
        * Internal Cache: The painted area.
        */
       private Shape paintedArea;
  @@ -150,6 +155,7 @@
           super.invalidateGeometryCache();
           primitiveBounds = null;
           geometryBounds = null;
  +        sensitiveBounds = null;
           paintedArea = null;
           sensitiveArea = null;
       }
  @@ -161,38 +167,26 @@
        * @param p the specified Point2D in the user space
        */
       public boolean contains(Point2D p) {
  -        // <!> FIXME: should put this code in TextPaint somewhere,
  -        // as pointer-events support
  -        Rectangle2D b = getBounds();
  -        if (b == null || !b.contains(p)) {
  -            return false;
  -        }
  -        Shape s;
           switch(pointerEventType) {
           case VISIBLE_PAINTED:
           case VISIBLE_FILL:
           case VISIBLE_STROKE:
  -            s = getSensitiveArea();
  -            if (s != null) {
  -                return isVisible && s.contains(p);
  -            } else {
  -                return false;
  -            }
           case VISIBLE:
  -            return isVisible;
  +            if (!isVisible) return false;
  +            // Fall Through
           case PAINTED:
           case FILL:
           case STROKE:
  -            s = getSensitiveArea();
  -            if (s != null) {
  -                return s.contains(p);
  -            } else {
  +        case ALL: {
  +            Rectangle2D b = getSensitiveBounds();
  +            if (b == null || !b.contains(p))
                   return false;
  -            }
  -        case ALL:
  -            return true;
  +
  +            Shape s = getSensitiveArea();
  +            if (s == null)  return false;
  +            return s.contains(p);
  +        }
           case NONE:
  -            return false;
           default:
               return false;
           }
  @@ -237,51 +231,71 @@
       }
   
       /**
  +     * Returns the bounds of the sensitive area covered by this node,
  +     * This includes the stroked area but does not include the effects
  +     * of clipping, masking or filtering.
  +     */
  +    public Rectangle2D getSensitiveBounds() {
  +        if (sensitiveBounds != null)
  +            return sensitiveBounds;
  +
  +        Shape sensitive = getSensitiveArea();
  +        if (sensitive == null) return null;
  +        sensitiveBounds = sensitive.getBounds2D();
  +        return sensitiveBounds;
  +    }
  +
  +    /**
        * Returns the shape that represents the sensitive area of this graphics
        * node.
        */
       public Shape getSensitiveArea() {
  -        if (sensitiveArea == null) {
  -            // <!> 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 {
  -                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;
  -                    }
  +        if (sensitiveArea != null) 
  +            return sensitiveArea;
  +
  +        // <!> 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 {
  +            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;
                   }
               }
  -            switch(pointerEventType) {
  -            case VISIBLE_PAINTED:
  -            case PAINTED:
  -                sensitiveArea = shapePainter.getPaintedArea();
  -                break;
  -            case VISIBLE_FILL:
  -            case FILL:
  -                if (fillShapePainter != null) {
  -                    sensitiveArea = fillShapePainter.getPaintedArea();
  -                }
  -                break;
  -            case VISIBLE_STROKE:
  -            case STROKE:
  -                if (strokeShapePainter != null) {
  -                    sensitiveArea = strokeShapePainter.getPaintedArea();
  -                }
  -                break;
  -            case ALL:
  -            case NONE:
  -            default:
  -                // nothing to tdo
  +        }
  +
  +        switch(pointerEventType) {
  +        case VISIBLE_PAINTED:
  +        case PAINTED:
  +            sensitiveArea = shapePainter.getPaintedArea();
  +            break;
  +        case VISIBLE_FILL:
  +        case FILL:
  +            if (fillShapePainter != null) {
  +                sensitiveArea = fillShapePainter.getSensitiveArea();
  +            }
  +            break;
  +        case VISIBLE_STROKE:
  +        case STROKE:
  +            if (strokeShapePainter != null) {
  +                sensitiveArea = strokeShapePainter.getSensitiveArea();
               }
  +            break;
  +        case VISIBLE:
  +        case ALL:
  +            sensitiveArea = shapePainter.getSensitiveArea();
  +            break;
  +        case NONE:
  +        default:
  +            // nothing to tdo
           }
           return sensitiveArea;
       }
  
  
  
  1.12      +13 -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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ShapePainter.java	11 Apr 2003 13:58:32 -0000	1.11
  +++ ShapePainter.java	30 May 2003 01:07:16 -0000	1.12
  @@ -38,6 +38,18 @@
       Rectangle2D getPaintedBounds2D();
   
       /**
  +     * Returns the area covered by this shape painter (even if nothing
  +     * is painted there).
  +     */
  +    Shape getSensitiveArea();
  +
  +    /**
  +     * Returns the bounds of the area covered by this shape painter
  +     * (even if nothing is painted there).
  +     */
  +    Rectangle2D getSensitiveBounds2D();
  +
  +    /**
        * Sets the Shape this shape painter is associated with.
        *
        * @param shape new shape this painter should be associated with.
  
  
  
  1.12      +46 -12    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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StrokeShapePainter.java	11 Apr 2003 13:58:32 -0000	1.11
  +++ StrokeShapePainter.java	30 May 2003 01:07:16 -0000	1.12
  @@ -28,6 +28,11 @@
       protected Shape shape;
   
       /**
  +     * Stroked version of the shape.
  +     */
  +    protected Shape strokedShape;
  +
  +    /**
        * The stroke attribute used to draw the outline of the shape.
        */
       protected Stroke stroke;
  @@ -57,7 +62,8 @@
        * @param newStroke the stroke object used to draw the outline of the shape
        */
       public void setStroke(Stroke newStroke) {
  -        this.stroke = newStroke;
  +        this.stroke       = newStroke;
  +        this.strokedShape = null;
       }
   
       /**
  @@ -70,7 +76,8 @@
       }
   
       /**
  -     * Paints the outline of the specified shape using the specified Graphics2D.
  +     * Paints the outline of the specified shape using the specified 
  +     * Graphics2D.
        *
        * @param g2d the Graphics2D to use 
        */
  @@ -86,23 +93,49 @@
        * Returns the area painted by this shape painter.
        */
       public Shape getPaintedArea(){
  -        if (paint != null && stroke != null) {
  -            return stroke.createStrokedShape(shape);
  -        } else {
  +        if ((paint == null) || (stroke == null))
               return null;
  -        }
  +
  +        if (strokedShape == null)
  +            strokedShape = stroke.createStrokedShape(shape);
  +
  +        return strokedShape;
       }
   
       /**
        * Returns the bounds of the area painted by this shape painter
        */
  -    public Rectangle2D getPaintedBounds2D(){
  +    public Rectangle2D getPaintedBounds2D() {
           Shape painted = getPaintedArea();
  -        if (painted != null){
  -            return painted.getBounds2D();
  -        } else {
  +        if (painted == null)
               return null;
  -        }
  +
  +        return painted.getBounds2D();
  +    }
  +
  +    /**
  +     * Returns the area covered by this shape painter (even if not painted).
  +     */
  +    public Shape getSensitiveArea(){
  +        if (stroke == null)
  +            return null;
  +
  +        if (strokedShape == null)
  +            strokedShape = stroke.createStrokedShape(shape);
  +
  +        return strokedShape;
  +    }
  +
  +    /**
  +     * Returns the bounds of the area covered by this shape painte
  +     * (even if not painted).
  +     */
  +    public Rectangle2D getSensitiveBounds2D() {
  +        Shape sensitive = getSensitiveArea();
  +        if (sensitive == null)
  +            return null;
  +
  +        return sensitive.getBounds2D();
       }
   
   
  @@ -117,6 +150,7 @@
               throw new IllegalArgumentException();
           }
           this.shape = shape;
  +        this.strokedShape = null;
       }
   
       /**
  
  
  
  1.27      +14 -4     xml-batik/sources/org/apache/batik/gvt/TextNode.java
  
  Index: TextNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/TextNode.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- TextNode.java	11 Apr 2003 13:58:32 -0000	1.26
  +++ TextNode.java	30 May 2003 01:07:16 -0000	1.27
  @@ -218,9 +218,10 @@
       }
   
       /**
  -     * Returns the bounds of the area covered by this node, without taking any
  -     * of its rendering attribute into account. i.e., exclusive of any clipping,
  -     * masking, filtering or stroking, for example.
  +     * Returns the bounds of the area covered by this node, without
  +     * taking any of its rendering attribute into account. i.e.,
  +     * exclusive of any clipping, masking, filtering or stroking, for
  +     * example.
        */
       public Rectangle2D getGeometryBounds(){
           if (geometryBounds == null){
  @@ -229,6 +230,15 @@
               }
           }
           return geometryBounds;
  +    }
  +
  +    /**
  +     * Returns the bounds of the sensitive area covered by this node,
  +     * This includes the stroked area but does not include the effects
  +     * of clipping, masking or filtering.
  +     */
  +    public Rectangle2D getSensitiveBounds() {
  +        return getGeometryBounds();
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org


Re: cvs commit: xml-batik/sources/org/apache/batik/gvt AbstractGraphicsNode.java CompositeGraphicsNode.java CompositeShapePainter.java FillShapePainter.java GraphicsNode.java MarkerShapePainter.java ProxyGraphicsNode.java RasterImageNode.java ShapeNode.java ShapePainter.java StrokeShapePainter.java TextNode.java

Posted by "J.Pietschmann" <j3...@yahoo.de>.
deweese@apache.org wrote:

>   +++ MultiResGraphicsNode.java	30 May 2003 01:07:15 -0000	1.6
...
>   +    public Rectangle2D getSensitiveBounds(){
>   +        return bounds;
>   +    }

FOP GUMP fails because of this, both redesign and maintenance
branch:
[javac] /...ce/build/src/org/apache/fop/svg/PDFImageElementBridge.java:101:
  org.apache.fop.svg.PDFImageElementBridge.PDFJpegNode should be declared
  abstract; it does not define getSensitiveBounds() in
  org.apache.batik.gvt.GraphicsNode
[javac]     public static class PDFJpegNode extends AbstractGraphicsNode {

Any hint what we should add in getSensitiveBounds()?

J.Pietschmann



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org