deweese     2003/09/11 03:40:24

  Modified:    samples/tests/spec/scripting zeroSize.svg
               sources/org/apache/batik/bridge BridgeContext.java
                        SVGCircleElementBridge.java
                        SVGEllipseElementBridge.java
                        SVGImageElementBridge.java
                        SVGRectElementBridge.java
               sources/org/apache/batik/gvt RasterImageNode.java
                        ShapeNode.java
               sources/org/apache/batik/gvt/event AWTEventDispatcher.java
               test-references/samples/tests/spec/scripting zeroSize.png
  Log:
  1) Zero w/h image elements no longer cause problems with rendering.
  2) You can now get correct bbox information for zero w/h items
     (circle, ellipse, rect, image).
  3) Ammended zeroSize test to test both of these.
  
  Revision  Changes    Path
  1.3       +109 -2    xml-batik/samples/tests/spec/scripting/zeroSize.svg
  
  Index: zeroSize.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/samples/tests/spec/scripting/zeroSize.svg,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- zeroSize.svg      8 Aug 2003 11:39:33 -0000       1.2
  +++ zeroSize.svg      11 Sep 2003 10:40:23 -0000      1.3
  @@ -61,24 +61,87 @@
   
   <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>  
   
  -<svg id="body" width="450" height="500" viewBox="0 0 450 500">
  +<svg id="body" width="450" height="500" viewBox="0 0 450 500"
  +  onload="doShowBounds=false">
     <title>Resizing zero w/h items 'onload'</title>
     <text x="50%" y="45" class="title">Resizing zero w/h items 'onload'</text>
   
     <script type="text/ecmascript"><![CDATA[
  +    var svgns = "http://www.w3.org/2000/svg";;
  +    var root  = document.getRootElement();
  +    var doShowBounds = true;
  +    var stressTest   = false;
  +
       function resizeRect(id, w, h) {
         var rect = document.getElementById(id);
  +      var ow = rect.getAttribute("width");
  +      var oh = rect.getAttribute("height");
         rect.setAttribute("width",  w);
         rect.setAttribute("height", h);
  +      showBounds(rect);
  +      if (stressTest)
  +        setTimeout("resizeRect('"+id+"',"+ow+","+oh+")", 1000);
       }
  +
       function resizeCircle(id, r) {
         var circle = document.getElementById(id);
  +      var or = circle.getAttribute("r");
         circle.setAttribute("r",  r);
  +      showBounds(circle);
  +      if (stressTest)
  +        setTimeout("resizeCircle('"+id+"',"+or+")", 1000);
       }
       function resizeEllipse(id, rx, ry) {
         var ellipse = document.getElementById(id);
  +      var orx = ellipse.getAttribute("rx");
  +      var ory = ellipse.getAttribute("ry");
         ellipse.setAttribute("rx",  rx);
         ellipse.setAttribute("ry",  ry);
  +      showBounds(ellipse);
  +      if (stressTest)
  +        setTimeout("resizeEllipse('"+id+"',"+orx+","+ory+")", 1000);
  +    }
  +
  +    function showBounds(shape) {
  +      if (!doShowBounds) return;
  +      var bbox = shape.getBBox();
  +      var elem;
  +      if (bbox.width == 0) {
  +         if (bbox.height == 0) {
  +           elem = document.createElementNS(svgns, "circle");
  +           elem.setAttribute("cx", ""+bbox.x);
  +           elem.setAttribute("cy", ""+bbox.y);
  +           elem.setAttribute("r", "5");
  +           elem.setAttribute("stroke","none");
  +           elem.setAttribute("fill","lime");
  +           elem.setAttribute("fill-opacity", ".5");
  +           shape.parentNode.insertBefore(elem, shape.nextSibling);
  +           return;
  +         } else {
  +           elem = document.createElementNS(svgns, "line");
  +           elem.setAttribute("x1", ""+bbox.x);
  +           elem.setAttribute("y1", ""+bbox.y);
  +           elem.setAttribute("x2", ""+bbox.x);
  +           elem.setAttribute("y2", ""+(bbox.y+bbox.height));
  +         }
  +      } else if (bbox.height == 0) {
  +           elem = document.createElementNS(svgns, "line");
  +           elem.setAttribute("x1", ""+bbox.x);
  +           elem.setAttribute("y1", ""+bbox.y);
  +           elem.setAttribute("x2", ""+(bbox.x+bbox.width));
  +           elem.setAttribute("y2", ""+bbox.y);
  +      } else {
  +        elem = document.createElementNS(svgns, "rect");
  +        elem.setAttribute("x", ""+bbox.x);
  +        elem.setAttribute("y", ""+bbox.y);
  +        elem.setAttribute("width", ""+bbox.width);
  +        elem.setAttribute("height", ""+bbox.height);
  +      }
  +      elem.setAttribute("fill","none");
  +      elem.setAttribute("stroke-width", "5");
  +      elem.setAttribute("stroke", "lime");
  +      elem.setAttribute("stroke-opacity", ".5");
  +      shape.parentNode.insertBefore(elem, shape.nextSibling);
       }
       ]]></script>
   
  @@ -155,6 +218,50 @@
           onload="resizeEllipse('e4-2', '25', '0')"/>
          <ellipse id="e4-3" cx="395" cy="265" rx="25" ry="15" 
           onload="resizeEllipse('e4-3', '0', '15')"/>
  +    </g>
  +
  +    <g transform="translate(0,300)">
  +       <image id="i5-1" x="10" y="0" width="50" height="50" 
  +        xlink:href="../../resources/images/png2.png"
  +        onload="resizeRect('i5-1', '0', '0')"/>
  +       <image id="i5-2" x="70" y="0" width="50" height="50" 
  +        xlink:href="../../resources/images/png2.png"
  +        onload="resizeRect('i5-2', '50', '0')"/>
  +       <image id="i5-3" x="130" y="0" width="50" height="50" 
  +        xlink:href="../../resources/images/png2.png"
  +        onload="resizeRect('i5-3', '0', '50')"/>
  +
  +       <image id="i5-4" x="190" y="0" width="0" height="0" 
  +        xlink:href="../../resources/images/png2.png"
  +        onload="resizeRect('i5-4', '50', '50')"/>
  +       <image id="i5-5" x="250" y="0" width="50" height="0" 
  +        xlink:href="../../resources/images/png2.png"
  +        onload="resizeRect('i5-5', '50', '50')"/>
  +       <image id="i5-6" x="310" y="0" width="0" height="50" 
  +        xlink:href="../../resources/images/png2.png"
  +        onload="resizeRect('i5-6', '50', '50')"/>
  +    </g>
  +
  +    <g transform="translate(0,360)">
  +       <image id="i6-1" x="10" y="0" width="50" height="50" 
  +        xlink:href="../../resources/images/svg2.svg"
  +        onload="resizeRect('i6-1', '0', '0')"/>
  +       <image id="i6-2" x="70" y="0" width="50" height="50" 
  +        xlink:href="../../resources/images/svg2.svg"
  +        onload="resizeRect('i6-2', '50', '0')"/>
  +       <image id="i6-3" x="130" y="0" width="50" height="50" 
  +        xlink:href="../../resources/images/svg2.svg"
  +        onload="resizeRect('i6-3', '0', '50')"/>
  +
  +       <image id="i6-4" x="190" y="0" width="0" height="0" 
  +        xlink:href="../../resources/images/svg2.svg"
  +        onload="resizeRect('i6-4', '50', '50')"/>
  +       <image id="i6-5" x="250" y="0" width="50" height="0" 
  +        xlink:href="../../resources/images/svg2.svg"
  +        onload="resizeRect('i6-5', '50', '50')"/>
  +       <image id="i6-6" x="310" y="0" width="0" height="50" 
  +        xlink:href="../../resources/images/svg2.svg"
  +        onload="resizeRect('i6-6', '50', '50')"/>
       </g>
     </g>
   </svg>
  
  
  
  1.72      +3 -2      xml-batik/sources/org/apache/batik/bridge/BridgeContext.java
  
  Index: BridgeContext.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeContext.java,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- BridgeContext.java        14 Aug 2003 00:53:51 -0000      1.71
  +++ BridgeContext.java        11 Sep 2003 10:40:24 -0000      1.72
  @@ -1038,7 +1038,8 @@
           Iterator iter = interpreterMap.values().iterator();
           while (iter.hasNext()) {
               Interpreter interpreter = (Interpreter)iter.next();
  -            interpreter.dispose();
  +            if (interpreter != null)
  +                interpreter.dispose();
           }
           interpreterMap.clear();
   
  
  
  
  1.14      +12 -6     
xml-batik/sources/org/apache/batik/bridge/SVGCircleElementBridge.java
  
  Index: SVGCircleElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGCircleElementBridge.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SVGCircleElementBridge.java       7 Sep 2003 22:25:27 -0000       1.13
  +++ SVGCircleElementBridge.java       11 Sep 2003 10:40:24 -0000      1.14
  @@ -51,8 +51,10 @@
   package org.apache.batik.bridge;
   
   import java.awt.geom.Ellipse2D;
  +import java.awt.geom.Rectangle2D;
   
   import org.apache.batik.gvt.ShapeNode;
  +import org.apache.batik.gvt.ShapePainter;
   import org.w3c.dom.Element;
   import org.w3c.dom.events.MutationEvent;
   
  @@ -122,11 +124,6 @@
               throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
                                         new Object[] {SVG_R_ATTRIBUTE, s});
           }
  -     // A value of zero disables rendering of the element
  -     if (r == 0) {
  -            shapeNode.setShape(null);
  -         return;
  -     }
           float x = cx - r;
           float y = cy - r;
           float w = r * 2;
  @@ -149,5 +146,14 @@
           } else {
               super.handleDOMAttrModifiedEvent(evt);
           }
  +    }
  +
  +    protected ShapePainter createShapePainter(BridgeContext ctx,
  +                                              Element e,
  +                                              ShapeNode shapeNode) {
  +        Rectangle2D r2d = shapeNode.getShape().getBounds2D();
  +        if ((r2d.getWidth() == 0) || (r2d.getHeight() == 0))
  +            return null;
  +        return super.createShapePainter(ctx, e, shapeNode);
       }
   }
  
  
  
  1.14      +12 -7     
xml-batik/sources/org/apache/batik/bridge/SVGEllipseElementBridge.java
  
  Index: SVGEllipseElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGEllipseElementBridge.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SVGEllipseElementBridge.java      8 Aug 2003 11:38:51 -0000       1.13
  +++ SVGEllipseElementBridge.java      11 Sep 2003 10:40:24 -0000      1.14
  @@ -51,8 +51,10 @@
   package org.apache.batik.bridge;
   
   import java.awt.geom.Ellipse2D;
  +import java.awt.geom.Rectangle2D;
   
   import org.apache.batik.gvt.ShapeNode;
  +import org.apache.batik.gvt.ShapePainter;
   import org.w3c.dom.Element;
   import org.w3c.dom.events.MutationEvent;
   
  @@ -135,12 +137,6 @@
                                         new Object[] {SVG_RY_ATTRIBUTE, s});
           }
   
  -     // A value of zero disables rendering of the element
  -     if ((rx == 0) || (ry == 0)) {
  -            shapeNode.setShape(null);
  -         return;
  -     }
  -
           shapeNode.setShape(new Ellipse2D.Float(cx-rx, cy-ry, rx*2, ry*2));
       }
   
  @@ -161,5 +157,14 @@
           } else {
               super.handleDOMAttrModifiedEvent(evt);
           }
  +    }
  +
  +    protected ShapePainter createShapePainter(BridgeContext ctx,
  +                                              Element e,
  +                                              ShapeNode shapeNode) {
  +        Rectangle2D r2d = shapeNode.getShape().getBounds2D();
  +        if ((r2d.getWidth() == 0) || (r2d.getHeight() == 0))
  +            return null;
  +        return super.createShapePainter(ctx, e, shapeNode);
       }
   }
  
  
  
  1.61      +104 -65   
xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java
  
  Index: SVGImageElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- SVGImageElementBridge.java        27 Aug 2003 11:07:40 -0000      1.60
  +++ SVGImageElementBridge.java        11 Sep 2003 10:40:24 -0000      1.61
  @@ -76,6 +76,7 @@
   import org.apache.batik.gvt.GraphicsNode;
   import org.apache.batik.gvt.ImageNode;
   import org.apache.batik.gvt.RasterImageNode;
  +import org.apache.batik.gvt.ShapeNode;
   import org.apache.batik.util.ParsedURL;
   import org.apache.batik.util.MimeTypeConstants;
   import org.w3c.dom.Document;
  @@ -419,76 +420,101 @@
   
           if (attrName.equals(SVG_X_ATTRIBUTE) ||
               attrName.equals(SVG_Y_ATTRIBUTE) ||
  -            attrName.equals(SVG_WIDTH_ATTRIBUTE) ||
  -            attrName.equals(SVG_HEIGHT_ATTRIBUTE) ||
            attrName.equals(SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE)){
  -
  -            //retrieve the new bounds of the image tag
  -         Rectangle2D bounds = getImageBounds(ctx, e);
  -         GraphicsNode imageNode = ((ImageNode)node).getImage();
  -         float [] vb = null;
  -         if (imageNode instanceof RasterImageNode) {
  -                //Raster image
  -             Rectangle2D imgBounds = 
  -                    ((RasterImageNode)imageNode).getImageBounds();
  -             // create the implicit viewBox for the raster
  -             // image. The viewBox for a raster image is the size
  -             // of the image
  -             vb = new float[4];
  -             vb[0] = 0; // x
  -             vb[1] = 0; // y
  -             vb[2] = (float)imgBounds.getWidth(); // width
  -             vb[3] = (float)imgBounds.getHeight(); // height
  -         } else {
  -             if (imgDocument != null) {
  -                 Element svgElement = imgDocument.getRootElement();
  -                 String viewBox = svgElement.getAttributeNS
  -                        (null, SVG_VIEW_BOX_ATTRIBUTE);
  -                 vb = ViewBox.parseViewBoxAttribute(e, viewBox);
  -                }
  -            }
  -            if (imageNode != null) {
  -                // handles the 'preserveAspectRatio', 'overflow' and
  -                // 'clip' and sets the appropriate AffineTransform to
  -                // the image node
  -                initializeViewport(ctx, e, imageNode, vb, bounds);
  -            }
  -            
  +            updateImageBounds();
           } else if (( XLinkSupport.XLINK_NAMESPACE_URI.equals
                        (evtNode.getNamespaceURI()) ) 
                      && SVG_HREF_ATTRIBUTE.equals(evtNode.getLocalName()) ){
  -            //reference copy of the imgDocument
  -            SVGDocument oldSVGDoc = imgDocument;
  -
  -            //update of the reference of the image.
  -            GraphicsNode inode = buildImageGraphicsNode(ctx,e);
  -
  -            if (inode == null) {
  -                String uriStr = XLinkSupport.getXLinkHref(e);
  -                throw new BridgeException(e, ERR_URI_IMAGE_INVALID,
  -                                          new Object[] {uriStr});
  -            }
  -            ImageNode imgNode = (ImageNode)node;
  -            //HACK : see 'initializeDynamicSupport'
  -            if (imgNode.getImage() instanceof RasterImageNode) {
  -                // register the RasterImageNode instead
  -                ctx.unbind(e);
  -                ctx.bind(e, inode );
  +            rebuildImageNode();
  +     } else if(attrName.equals(SVG_WIDTH_ATTRIBUTE) ||
  +                  attrName.equals(SVG_HEIGHT_ATTRIBUTE)) {
  +            float oldV = 0, newV=0;
  +            String s = evt.getPrevValue();
  +            UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);
  +
  +            if (s.length() != 0) {
  +                oldV = UnitProcessor.svgHorizontalCoordinateToUserSpace
  +                    (s, attrName, uctx);
               }
  -            else{
  -                //it was an svg file referenced
  -                //dispose it
  -                if ( oldSVGDoc != null ){
  -                    disposeTree(oldSVGDoc);
  -                }
  +            s = evt.getNewValue();
  +            if (s.length() != 0) {
  +                newV = UnitProcessor.svgHorizontalCoordinateToUserSpace
  +                    (s, attrName, uctx);
               }
  -            imgNode.setImage(inode);
  +            if (oldV == newV) return;
               
  -     } else {
  -         super.handleDOMAttrModifiedEvent(evt);
  +            if ((oldV == 0) || (newV == 0))
  +                rebuildImageNode();
  +            else
  +                updateImageBounds();
  +        } else {
  +            super.handleDOMAttrModifiedEvent(evt);
        }
       }
   
  +    protected void updateImageBounds() {
  +        //retrieve the new bounds of the image tag
  +        Rectangle2D  bounds = getImageBounds(ctx, e);
  +        GraphicsNode imageNode = ((ImageNode)node).getImage();
  +        float [] vb = null;
  +        if (imageNode instanceof RasterImageNode) {
  +            //Raster image
  +            Rectangle2D imgBounds = 
  +                ((RasterImageNode)imageNode).getImageBounds();
  +            // create the implicit viewBox for the raster
  +            // image. The viewBox for a raster image is the size
  +            // of the image
  +            vb = new float[4];
  +            vb[0] = 0; // x
  +            vb[1] = 0; // y
  +            vb[2] = (float)imgBounds.getWidth(); // width
  +            vb[3] = (float)imgBounds.getHeight(); // height
  +        } else {
  +            if (imgDocument != null) {
  +                Element svgElement = imgDocument.getRootElement();
  +                String viewBox = svgElement.getAttributeNS
  +                    (null, SVG_VIEW_BOX_ATTRIBUTE);
  +                vb = ViewBox.parseViewBoxAttribute(e, viewBox);
  +            }
  +        }
  +        if (imageNode != null) {
  +            // handles the 'preserveAspectRatio', 'overflow' and
  +            // 'clip' and sets the appropriate AffineTransform to
  +            // the image node
  +            initializeViewport(ctx, e, imageNode, vb, bounds);
  +        }
  +            
  +    }
  +
  +    protected void rebuildImageNode() {
  +        //reference copy of the imgDocument
  +        SVGDocument oldSVGDoc = imgDocument;
  +
  +        //update of the reference of the image.
  +        GraphicsNode inode = buildImageGraphicsNode(ctx,e);
  +
  +        if (inode == null) {
  +            String uriStr = XLinkSupport.getXLinkHref(e);
  +            throw new BridgeException(e, ERR_URI_IMAGE_INVALID,
  +                                      new Object[] {uriStr});
  +        }
  +        ImageNode imgNode = (ImageNode)node;
  +        //HACK : see 'initializeDynamicSupport'
  +        if (imgNode.getImage() instanceof RasterImageNode) {
  +            // register the RasterImageNode instead
  +            ctx.unbind(e);
  +            ctx.bind(e, inode );
  +        }
  +        else{
  +            //it was an svg file referenced
  +            //dispose it
  +            if ( oldSVGDoc != null ){
  +                disposeTree(oldSVGDoc);
  +            }
  +        }
  +        imgNode.setImage(inode);
  +    }
  +
       /**
        * Invoked for each CSS property that has changed.
        */
  @@ -520,7 +546,14 @@
       protected static GraphicsNode createRasterImageNode(BridgeContext ctx,
                                                          Element       e,
                                                          Filter        img) {
  +        Rectangle2D bounds = getImageBounds(ctx, e);
  +        if ((bounds.getWidth() == 0) || (bounds.getHeight() == 0)) {
  +            ShapeNode sn = new ShapeNode();
  +            sn.setShape(bounds);
  +            return sn;
  +        }
           RasterImageNode node = new RasterImageNode();
  +
           Object           obj = img.getProperty
               (SVGBrokenLinkProvider.SVG_BROKEN_LINK_DOCUMENT_PROPERTY);
           if ((obj != null) && (obj instanceof SVGDocument)) {
  @@ -531,7 +564,6 @@
           }
           node.setImage(img);
           Rectangle2D imgBounds = img.getBounds2D();
  -        Rectangle2D bounds = getImageBounds(ctx, e);
   
           // create the implicit viewBox for the raster image. The viewBox for a
           // raster image is the size of the image
  @@ -560,6 +592,16 @@
                                                        SVGDocument imgDocument) {
   
           CompositeGraphicsNode result = new CompositeGraphicsNode();
  +        // handles the 'preserveAspectRatio', 'overflow' and 'clip' and 
  +        // sets the appropriate AffineTransform to the image node
  +        Rectangle2D bounds = getImageBounds(ctx, e);
  +
  +        if ((bounds.getWidth() == 0) || (bounds.getHeight() == 0)) {
  +            ShapeNode sn = new ShapeNode();
  +            sn.setShape(bounds);
  +            result.getChildren().add(sn);
  +            return result;
  +        }
   
           Rectangle2D r = CSSUtilities.convertEnableBackground(e);
           if (r != null) {
  @@ -587,9 +629,6 @@
               svgElement.getAttributeNS(null, SVG_VIEW_BOX_ATTRIBUTE);
           float [] vb = ViewBox.parseViewBoxAttribute(e, viewBox);
   
  -        // handles the 'preserveAspectRatio', 'overflow' and 'clip' and sets the
  -        // appropriate AffineTransform to the image node
  -        Rectangle2D bounds = getImageBounds(ctx, e);
           initializeViewport(ctx, e, result, vb, bounds);
   
           // add a listener on the outermost svg element of the SVG image.
  
  
  
  1.15      +14 -11    
xml-batik/sources/org/apache/batik/bridge/SVGRectElementBridge.java
  
  Index: SVGRectElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGRectElementBridge.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SVGRectElementBridge.java 8 Aug 2003 11:38:51 -0000       1.14
  +++ SVGRectElementBridge.java 11 Sep 2003 10:40:24 -0000      1.15
  @@ -55,6 +55,8 @@
   import java.awt.geom.RoundRectangle2D;
   
   import org.apache.batik.gvt.ShapeNode;
  +import org.apache.batik.gvt.ShapePainter;
  +
   import org.w3c.dom.Element;
   import org.w3c.dom.events.MutationEvent;
   
  @@ -125,11 +127,6 @@
               throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
                                         new Object[] {SVG_WIDTH_ATTRIBUTE, s});
           }
  -     // A value of zero disables rendering of the element
  -     if (w == 0) {
  -            shapeNode.setShape(null);
  -         return;
  -     }
   
           // 'height' attribute - required
           s = e.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
  @@ -141,11 +138,6 @@
               throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
                                         new Object[] {SVG_HEIGHT_ATTRIBUTE, s});
           }
  -     // A value of zero disables rendering of the element
  -     if (h == 0) {
  -            shapeNode.setShape(null);
  -         return;
  -     }
   
           // 'rx' attribute - default is 0
           s = e.getAttributeNS(null, SVG_RX_ATTRIBUTE);
  @@ -211,5 +203,16 @@
           } else {
               super.handleDOMAttrModifiedEvent(evt);
           }
  +    }
  +
  +
  +    protected ShapePainter createShapePainter(BridgeContext ctx,
  +                                              Element e,
  +                                              ShapeNode shapeNode) {
  +        Shape shape = shapeNode.getShape();
  +        Rectangle2D r2d = shape.getBounds2D();
  +        if ((r2d.getWidth() == 0) || (r2d.getHeight() == 0))
  +            return null;
  +        return super.createShapePainter(ctx, e, shapeNode);
       }
   }
  
  
  
  1.16      +11 -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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- RasterImageNode.java      8 Aug 2003 11:39:14 -0000       1.15
  +++ RasterImageNode.java      11 Sep 2003 10:40:24 -0000      1.16
  @@ -107,6 +107,8 @@
        * @return the bounds of this raster image node
        */
       public Rectangle2D getImageBounds() {
  +        if (image == null)
  +            return null;
           return (Rectangle2D) image.getBounds2D().clone();
       }
   
  @@ -142,6 +144,8 @@
        * Returns the bounds of the area covered by this node's primitive paint.
        */
       public Rectangle2D getPrimitiveBounds() {
  +        if (image == null)
  +            return null;
           return image.getBounds2D();
       }
   
  @@ -151,6 +155,8 @@
        * masking, filtering or stroking, for example.
        */
       public Rectangle2D getGeometryBounds() {
  +        if (image == null)
  +            return null;
           return image.getBounds2D();
       }
   
  @@ -160,6 +166,8 @@
        * of clipping, masking or filtering.
        */
       public Rectangle2D getSensitiveBounds() {
  +        if (image == null)
  +            return null;
           return image.getBounds2D();
       }
   
  @@ -167,6 +175,8 @@
        * Returns the outline of this node.
        */
       public Shape getOutline() {
  +        if (image == null)
  +            return null;
           return image.getBounds2D();
       }
   }
  
  
  
  1.23      +7 -6      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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- ShapeNode.java    8 Aug 2003 11:39:14 -0000       1.22
  +++ ShapeNode.java    11 Sep 2003 10:40:24 -0000      1.23
  @@ -257,12 +257,13 @@
        */
       public Rectangle2D getPrimitiveBounds() {
           if (primitiveBounds == null) {
  -            if ((shape == null) || (shapePainter == null)) {
  +            if (shape == null)
                   return null;
  -            }
  -            // paintedArea = shapePainter.getPaintedArea();
  -            // primitiveBounds = paintedArea.getBounds2D();
  -            primitiveBounds = shapePainter.getPaintedBounds2D();
  +
  +            if (shapePainter == null)
  +                primitiveBounds = shape.getBounds2D();
  +            else
  +                primitiveBounds = shapePainter.getPaintedBounds2D();
   
               // Make sure we haven't been interrupted
               if (Thread.currentThread().isInterrupted()) {
  
  
  
  1.20      +2 -2      
xml-batik/sources/org/apache/batik/gvt/event/AWTEventDispatcher.java
  
  Index: AWTEventDispatcher.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/gvt/event/AWTEventDispatcher.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- AWTEventDispatcher.java   22 Aug 2003 10:49:06 -0000      1.19
  +++ AWTEventDispatcher.java   11 Sep 2003 10:40:24 -0000      1.20
  @@ -431,7 +431,7 @@
           }
   
           GraphicsNode node = root.nodeHitAt(gnp);
  -
  +        
           // If the receiving node has changed, send a notification
           // check if we enter a new node
           Point screenPos;
  
  
  
  1.2       +44 -23    
xml-batik/test-references/samples/tests/spec/scripting/zeroSize.png
  
        <<Binary file>>
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to