cam         2004/07/31 20:08:50

  Modified:    sources/org/apache/batik/bridge
                        AbstractGraphicsNodeBridge.java
                        BaseScriptingEnvironment.java BridgeExtension.java
                        GVTBuilder.java SVGBridgeExtension.java
                        SVGPathElementBridge.java
                        SVGPolygonElementBridge.java
                        SVGPolylineElementBridge.java
                        SVGSVGElementBridge.java SVGTextElementBridge.java
                        SVGUtilities.java
               sources/org/apache/batik/dom/svg AbstractSVGList.java
                        SVGOMTextElement.java SVGStylableElement.java
               sources/org/apache/batik/extension/svg
                        BatikBridgeExtension.java
               sources/org/apache/batik/swing JSVGCanvas.java
  Log:
  1. GenericBridges are now handled more uniformly, so that extension
     elements which do not inherit from AbstractGraphicsNodeBridge and are
     not for title or desc elements will have their handleElement method
     called.
  2. Fixed tool tip handling bug.
     (http://issues.apache.org/eyebrowse/[EMAIL PROTECTED]&msgNo=1007)
  3. Changed BridgeExtension to allow extensions to specify if a particular
     extension element should cause the document to be dynamic.
  4. Fixed fill-rule bug. (#28679)
  5. Implemented getX() and getY() methods of text elements.
  6. Fixed NPE in SVGList if the list is empty.
  7. Fixed NPE in SVGTextElementBridge.getSubStringLength if there is no text.
     (#28702)
  
  Revision  Changes    Path
  1.34      +1 -4      
xml-batik/sources/org/apache/batik/bridge/AbstractGraphicsNodeBridge.java
  
  Index: AbstractGraphicsNodeBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/AbstractGraphicsNodeBridge.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- AbstractGraphicsNodeBridge.java   6 Oct 2003 00:56:00 -0000       1.33
  +++ AbstractGraphicsNodeBridge.java   1 Aug 2004 03:08:46 -0000       1.34
  @@ -166,9 +166,6 @@
           node.setPointerEventType(CSSUtilities.convertPointerEvents(e));
   
           initializeDynamicSupport(ctx, e, node);
  -
  -        // Handle children elements such as <title>
  -        SVGUtilities.bridgeChildren(ctx, e);
       }
   
       /**
  
  
  
  1.30      +17 -14    
xml-batik/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java
  
  Index: BaseScriptingEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- BaseScriptingEnvironment.java     24 Feb 2004 14:04:37 -0000      1.29
  +++ BaseScriptingEnvironment.java     1 Aug 2004 03:08:46 -0000       1.30
  @@ -57,6 +57,8 @@
   import java.net.MalformedURLException;
   import java.net.URL;
   import java.util.HashSet;
  +import java.util.Iterator;
  +import java.util.List;
   import java.util.Set;
   import java.util.jar.Manifest;
   
  @@ -144,14 +146,15 @@
        * Tells whether the given SVG element is dynamic.
        */
       public static boolean isDynamicElement(Element elt) {
  -        if (SVGConstants.SVG_NAMESPACE_URI.equals(elt.getNamespaceURI())) {
  -            String name = elt.getLocalName();
  -            if (name.equals(SVGConstants.SVG_SCRIPT_TAG)) {
  -                return true;
  -            }
  -            if (name.startsWith("animate") || name.equals("set")) {
  +        List bridgeExtensions = BridgeContext.getBridgeExtensions();
  +        Iterator i = bridgeExtensions.iterator();
  +        while (i.hasNext()) {
  +            BridgeExtension bridgeExtension = (BridgeExtension) i.next();
  +            if (bridgeExtension.isDynamicElement(elt)) {
                   return true;
               }
  +        }
  +        if (SVGConstants.SVG_NAMESPACE_URI.equals(elt.getNamespaceURI())) {
               if (elt.getAttributeNS
                   (null, SVGConstants.SVG_ONKEYUP_ATTRIBUTE).length() > 0) {
                   return true;
  @@ -208,14 +211,14 @@
                   (null, SVGConstants.SVG_ONMOUSEUP_ATTRIBUTE).length() > 0) {
                   return true;
               }
  +        }
   
  -            for (Node n = elt.getFirstChild();
  -                 n != null;
  -                 n = n.getNextSibling()) {
  -                if (n.getNodeType() == Node.ELEMENT_NODE) {
  -                    if (isDynamicElement((Element)n)) {
  -                        return true;
  -                    }
  +        for (Node n = elt.getFirstChild();
  +             n != null;
  +             n = n.getNextSibling()) {
  +            if (n.getNodeType() == Node.ELEMENT_NODE) {
  +                if (isDynamicElement((Element)n)) {
  +                    return true;
                   }
               }
           }
  
  
  
  1.4       +11 -0     xml-batik/sources/org/apache/batik/bridge/BridgeExtension.java
  
  Index: BridgeExtension.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeExtension.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BridgeExtension.java      8 Aug 2003 11:38:50 -0000       1.3
  +++ BridgeExtension.java      1 Aug 2004 03:08:46 -0000       1.4
  @@ -52,6 +52,8 @@
   
   import java.util.Iterator;
   
  +import org.w3c.dom.Element;
  +
   /**
    * This is a Service interface for classes that want to extend the
    * functionality of the Bridge, to support new tags in the rendering tree.
  @@ -109,4 +111,13 @@
        * @param ctx The BridgeContext instance to be updated
        */
       public void registerTags(BridgeContext ctx);
  +
  +    /**
  +     * Whether the presence of the specified element should cause
  +     * the document to be dynamic.  If this element isn't handled
  +     * by this BridgeExtension, just return false.
  +     *
  +     * @param e The element to check.
  +     */
  +    public boolean isDynamicElement(Element e);
   }
  
  
  
  1.27      +34 -4     xml-batik/sources/org/apache/batik/bridge/GVTBuilder.java
  
  Index: GVTBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/GVTBuilder.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- GVTBuilder.java   8 Aug 2003 11:38:50 -0000       1.26
  +++ GVTBuilder.java   1 Aug 2004 03:08:46 -0000       1.27
  @@ -143,7 +143,11 @@
       public GraphicsNode build(BridgeContext ctx, Element e) {
           // get the appropriate bridge according to the specified element
           Bridge bridge = ctx.getBridge(e);
  -        if (bridge == null || !(bridge instanceof GraphicsNodeBridge)) {
  +        if (bridge instanceof GenericBridge) {
  +            // If it is a GenericBridge just handle it and return.
  +            ((GenericBridge) bridge).handleElement(ctx, e);
  +            return null;
  +        } else if (bridge == null || !(bridge instanceof GraphicsNodeBridge)) {
               return null;
           }
           // create the associated graphics node
  @@ -156,6 +160,8 @@
           if (gn != null) {
               if (gnBridge.isComposite()) {
                   buildComposite(ctx, e, (CompositeGraphicsNode)gn);
  +            } else {
  +                handleGenericBridges(ctx, e);
               }
               gnBridge.buildGraphicsNode(ctx, e, gn);
           }
  @@ -207,7 +213,11 @@
           }
           // get the appropriate bridge according to the specified element
           Bridge bridge = ctx.getBridge(e);
  -        if (bridge == null || !(bridge instanceof GraphicsNodeBridge)) {
  +        if (bridge instanceof GenericBridge) {
  +            // If it is a GenericBridge just handle it and return.
  +            ((GenericBridge) bridge).handleElement(ctx, e);
  +            return;
  +        } else if (bridge == null || !(bridge instanceof GraphicsNodeBridge)) {
               return;
           }
           // check the display property
  @@ -224,6 +234,9 @@
                   // check if the element has children to build
                   if (gnBridge.isComposite()) {
                       buildComposite(ctx, e, (CompositeGraphicsNode)gn);
  +                } else {
  +                    // if not then still handle the GenericBridges
  +                    handleGenericBridges(ctx, e);
                   }
                   gnBridge.buildGraphicsNode(ctx, e, gn);
               }
  @@ -241,5 +254,22 @@
               throw ex;
           }
       }
  -}
   
  +    /**
  +     * Handles any GenericBridge elements which are children of the
  +     * specified element.
  +     * @param ctx the bridge context
  +     * @param e the element whose child elements should be handled
  +     */
  +    protected void handleGenericBridges(BridgeContext ctx, Element e) {
  +        for (Node n = e.getFirstChild(); n != null; n = n.getNextSibling()) {
  +            if (n instanceof Element) {
  +                Element e2 = (Element) n;
  +                Bridge b = ctx.getBridge(e2);
  +                if (b instanceof GenericBridge) {
  +                    ((GenericBridge) b).handleElement(ctx, e2);
  +                }
  +            }
  +        }
  +    }
  +}
  
  
  
  1.9       +24 -0     
xml-batik/sources/org/apache/batik/bridge/SVGBridgeExtension.java
  
  Index: SVGBridgeExtension.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGBridgeExtension.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SVGBridgeExtension.java   8 Aug 2003 11:38:51 -0000       1.8
  +++ SVGBridgeExtension.java   1 Aug 2004 03:08:46 -0000       1.9
  @@ -53,6 +53,9 @@
   import java.util.Collections;
   import java.util.Iterator;
   
  +import org.apache.batik.util.SVGConstants;
  +import org.w3c.dom.Element;
  +
   /**
    * This is a Service interface for classes that want to extend the
    * functionality of the Bridge, to support new tags in the rendering tree.
  @@ -191,5 +194,26 @@
           ctx.putBridge(new SVGUseElementBridge());
           ctx.putBridge(new SVGVKernElementBridge());
   
  +    }
  +
  +    /**
  +     * Whether the presence of the specified element should cause
  +     * the document to be dynamic.  If this element isn't handled
  +     * by this BridgeExtension, just return false.
  +     *
  +     * @param e The element to check.
  +     */
  +    public boolean isDynamicElement(Element e) {
  +        String ns = e.getNamespaceURI();
  +        if (!SVGConstants.SVG_NAMESPACE_URI.equals(ns)) {
  +            return false;
  +        }
  +        String ln = e.getLocalName();
  +        if (ln.equals(SVGConstants.SVG_SCRIPT_TAG)
  +                || ln.startsWith("animate")
  +                || ln.equals("set")) {
  +            return true;
  +        }
  +        return false;
       }
   }
  
  
  
  1.18      +14 -1     
xml-batik/sources/org/apache/batik/bridge/SVGPathElementBridge.java
  
  Index: SVGPathElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGPathElementBridge.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- SVGPathElementBridge.java 8 Aug 2003 11:38:51 -0000       1.17
  +++ SVGPathElementBridge.java 1 Aug 2004 03:08:46 -0000       1.18
  @@ -53,6 +53,8 @@
   import java.awt.Shape;
   import java.awt.geom.GeneralPath;
   
  +import org.apache.batik.css.engine.CSSEngineEvent;
  +import org.apache.batik.css.engine.SVGCSSEngine;
   import org.apache.batik.gvt.ShapeNode;
   import org.apache.batik.parser.AWTPathProducer;
   import org.apache.batik.parser.ParseException;
  @@ -142,6 +144,17 @@
               handleGeometryChanged();
           } else {
               super.handleDOMAttrModifiedEvent(evt);
  +        }
  +    }
  +
  +    protected void handleCSSPropertyChanged(int property) {
  +        switch(property) {
  +        case SVGCSSEngine.FILL_RULE_INDEX:
  +            buildShape(ctx, e, (ShapeNode) node);
  +            handleGeometryChanged();
  +            break;
  +        default:
  +            super.handleCSSPropertyChanged(property);
           }
       }
   }
  
  
  
  1.19      +14 -1     
xml-batik/sources/org/apache/batik/bridge/SVGPolygonElementBridge.java
  
  Index: SVGPolygonElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGPolygonElementBridge.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- SVGPolygonElementBridge.java      8 Aug 2003 11:38:51 -0000       1.18
  +++ SVGPolygonElementBridge.java      1 Aug 2004 03:08:46 -0000       1.19
  @@ -53,6 +53,8 @@
   import java.awt.Shape;
   import java.awt.geom.GeneralPath;
   
  +import org.apache.batik.css.engine.CSSEngineEvent;
  +import org.apache.batik.css.engine.SVGCSSEngine;
   import org.apache.batik.gvt.ShapeNode;
   import org.apache.batik.parser.AWTPolygonProducer;
   import org.apache.batik.parser.ParseException;
  @@ -141,6 +143,17 @@
               handleGeometryChanged();
           } else {
               super.handleDOMAttrModifiedEvent(evt);
  +        }
  +    }
  +
  +    protected void handleCSSPropertyChanged(int property) {
  +        switch(property) {
  +        case SVGCSSEngine.FILL_RULE_INDEX:
  +            buildShape(ctx, e, (ShapeNode) node);
  +            handleGeometryChanged();
  +            break;
  +        default:
  +            super.handleCSSPropertyChanged(property);
           }
       }
   }
  
  
  
  1.18      +14 -1     
xml-batik/sources/org/apache/batik/bridge/SVGPolylineElementBridge.java
  
  Index: SVGPolylineElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGPolylineElementBridge.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- SVGPolylineElementBridge.java     8 Aug 2003 11:38:51 -0000       1.17
  +++ SVGPolylineElementBridge.java     1 Aug 2004 03:08:46 -0000       1.18
  @@ -53,6 +53,8 @@
   import java.awt.Shape;
   import java.awt.geom.GeneralPath;
   
  +import org.apache.batik.css.engine.CSSEngineEvent;
  +import org.apache.batik.css.engine.SVGCSSEngine;
   import org.apache.batik.gvt.ShapeNode;
   import org.apache.batik.parser.AWTPolylineProducer;
   import org.apache.batik.parser.ParseException;
  @@ -141,6 +143,17 @@
               handleGeometryChanged();
           } else {
               super.handleDOMAttrModifiedEvent(evt);
  +        }
  +    }
  +
  +    protected void handleCSSPropertyChanged(int property) {
  +        switch(property) {
  +        case SVGCSSEngine.FILL_RULE_INDEX:
  +            buildShape(ctx, e, (ShapeNode) node);
  +            handleGeometryChanged();
  +            break;
  +        default:
  +            super.handleCSSPropertyChanged(property);
           }
       }
   }
  
  
  
  1.42      +1 -4      
xml-batik/sources/org/apache/batik/bridge/SVGSVGElementBridge.java
  
  Index: SVGSVGElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGSVGElementBridge.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- SVGSVGElementBridge.java  14 Dec 2003 15:14:57 -0000      1.41
  +++ SVGSVGElementBridge.java  1 Aug 2004 03:08:46 -0000       1.42
  @@ -253,9 +253,6 @@
   
           initializeDynamicSupport(ctx, e, node);
   
  -        // Handle children elements such as <title>
  -        //SVGUtilities.bridgeChildren(ctx, e);
  -        //super.buildGraphicsNode(ctx, e, node);
           ctx.closeViewport(e);
       }
   
  
  
  
  1.93      +5 -4      
xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java
  
  Index: SVGTextElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -r1.92 -r1.93
  --- SVGTextElementBridge.java 25 Jun 2004 01:41:51 -0000      1.92
  +++ SVGTextElementBridge.java 1 Aug 2004 03:08:46 -0000       1.93
  @@ -251,9 +251,6 @@
           node.setPointerEventType(CSSUtilities.convertPointerEvents(e));

   

           initializeDynamicSupport(ctx, e, node);

  -

  -        // Handle children elements such as <title>

  -        SVGUtilities.bridgeChildren(ctx, e);

       }

   

       /**

  @@ -2399,6 +2396,10 @@
       protected float getSubStringLength(Element element,

                                          int charnum, 

                                          int nchars){

  +        if (nchars == 0) {

  +            return 0;

  +        }

  +

           float length = 0;

   

           AttributedCharacterIterator aci;

  
  
  
  1.28      +1 -28     xml-batik/sources/org/apache/batik/bridge/SVGUtilities.java
  
  Index: SVGUtilities.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGUtilities.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- SVGUtilities.java 9 Aug 2003 16:58:37 -0000       1.27
  +++ SVGUtilities.java 1 Aug 2004 03:08:47 -0000       1.28
  @@ -1140,31 +1140,4 @@
               return new Rectangle2D.Double();
           }
       }
  -
  -    /**
  -     * Scans the children of the input <tt>e</tt> element and
  -     * invokes any registered bridge found for the children.
  -     *
  -     * @param ctx active BridgeContext
  -     * @param e element to be scanned
  -     */
  -    public static void bridgeChildren(BridgeContext ctx,
  -                                      Element elt){
  -        for (Node n = elt.getFirstChild();
  -             n != null;
  -             n = n.getNextSibling()) {
  -
  -            if ((n.getNodeType() != Node.ELEMENT_NODE)) {
  -                continue;
  -            }
  -
  -            Element e = (Element)n;
  -            Bridge bridge = ctx.getBridge(e);
  -            if (bridge == null || !(bridge instanceof GenericBridge)) {
  -                continue;
  -            }
  -
  -            ((GenericBridge)bridge).handleElement(ctx, e);
  -        }
  -    }
   }
  
  
  
  1.5       +2 -2      xml-batik/sources/org/apache/batik/dom/svg/AbstractSVGList.java
  
  Index: AbstractSVGList.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/AbstractSVGList.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractSVGList.java      8 Aug 2003 11:38:59 -0000       1.4
  +++ AbstractSVGList.java      1 Aug 2004 03:08:48 -0000       1.5
  @@ -265,7 +265,7 @@
           throws DOMException {
           revalidate();
   
  -        if ( index < 0 || index >= itemList.size() ){
  +        if ( index < 0 || itemList == null || index >= itemList.size() ){
               throw createDOMException(DOMException.INDEX_SIZE_ERR,
                       "AbstractSVGList.getItem.OutOfBoundsException",
                       null);
  
  
  
  1.12      +45 -1     xml-batik/sources/org/apache/batik/dom/svg/SVGOMTextElement.java
  
  Index: SVGOMTextElement.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGOMTextElement.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SVGOMTextElement.java     8 Aug 2003 11:39:00 -0000       1.11
  +++ SVGOMTextElement.java     1 Aug 2004 03:08:48 -0000       1.12
  @@ -51,7 +51,9 @@
   package org.apache.batik.dom.svg;
   
   import org.apache.batik.dom.AbstractDocument;
  +import org.apache.batik.util.SVGConstants;
   import org.w3c.dom.Node;
  +import org.w3c.dom.svg.SVGAnimatedLengthList;
   import org.w3c.dom.svg.SVGAnimatedTransformList;
   import org.w3c.dom.svg.SVGElement;
   import org.w3c.dom.svg.SVGException;
  @@ -69,6 +71,10 @@
       extends    SVGOMTextPositioningElement
       implements SVGTextElement {
   
  +    // Default values for attributes on a text element
  +    public static final String X_DEFAULT_VALUE = "0";
  +    public static final String Y_DEFAULT_VALUE = "0";
  +
       /**
        * Creates a new SVGOMTextElement object.
        */
  @@ -155,5 +161,43 @@
        */
       protected Node newNode() {
           return new SVGOMTextElement();
  +    }
  +
  +    // SVGTextPositioningElement support ////////////////////////////////////
  +
  +    /**
  +     * <b>DOM</b>: Implements [EMAIL PROTECTED]
  +     * org.w3c.dom.svg.SVGTextPositioningElement#getX()}.
  +     */
  +    public SVGAnimatedLengthList getX() {
  +        SVGOMAnimatedLengthList result = (SVGOMAnimatedLengthList)
  +            getLiveAttributeValue(null, SVGConstants.SVG_X_ATTRIBUTE);
  +        if (result == null) {
  +            result = new SVGOMAnimatedLengthList(this, null,
  +                                                 SVGConstants.SVG_X_ATTRIBUTE,
  +                                                 X_DEFAULT_VALUE,
  +                                                 
AbstractSVGLength.HORIZONTAL_LENGTH);
  +            putLiveAttributeValue(null,
  +                                  SVGConstants.SVG_X_ATTRIBUTE, result);
  +        }
  +        return result;
  +    }
  +
  +    /**
  +     * <b>DOM</b>: Implements [EMAIL PROTECTED]
  +     * org.w3c.dom.svg.SVGTextPositioningElement#getY()}.
  +     */
  +    public SVGAnimatedLengthList getY() {
  +        SVGOMAnimatedLengthList result = (SVGOMAnimatedLengthList)
  +            getLiveAttributeValue(null, SVGConstants.SVG_Y_ATTRIBUTE);
  +        if (result == null) {
  +            result = new SVGOMAnimatedLengthList(this, null,
  +                                                 SVGConstants.SVG_Y_ATTRIBUTE,
  +                                                 Y_DEFAULT_VALUE,
  +                                                 AbstractSVGLength.VERTICAL_LENGTH);
  +            putLiveAttributeValue(null,
  +                                  SVGConstants.SVG_Y_ATTRIBUTE, result);
  +        }
  +        return result;
       }
   }
  
  
  
  1.14      +2 -9      
xml-batik/sources/org/apache/batik/dom/svg/SVGStylableElement.java
  
  Index: SVGStylableElement.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGStylableElement.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SVGStylableElement.java   14 Dec 2003 18:01:11 -0000      1.13
  +++ SVGStylableElement.java   1 Aug 2004 03:08:48 -0000       1.14
  @@ -542,7 +542,7 @@
           extends CSSOMSVGStyleDeclaration
           implements LiveAttributeValue,
                      CSSOMSVGStyleDeclaration.ValueProvider,
  -                   CSSOMSVGStyleDeclaration.ModificationHandler, 
  +                   CSSOMSVGStyleDeclaration.ModificationHandler,
                      CSSEngine.MainPropertyReceiver {
           
           /**
  @@ -710,10 +710,3 @@
           }
       }
   }
  -
  -
  -
  -
  -
  -
  -
  
  
  
  1.8       +12 -0     
xml-batik/sources/org/apache/batik/extension/svg/BatikBridgeExtension.java
  
  Index: BatikBridgeExtension.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/extension/svg/BatikBridgeExtension.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BatikBridgeExtension.java 8 Aug 2003 11:39:10 -0000       1.7
  +++ BatikBridgeExtension.java 1 Aug 2004 03:08:48 -0000       1.8
  @@ -56,6 +56,7 @@
   
   import org.apache.batik.bridge.BridgeContext;
   import org.apache.batik.bridge.BridgeExtension;
  +import org.w3c.dom.Element;
   
   /**
    * This is a Service interface for classes that want to extend the
  @@ -142,5 +143,16 @@
           ctx.putBridge(new SolidColorBridge());
           ctx.putBridge(new ColorSwitchBridge());
           ctx.putBridge(new SVGFlowTextElementBridge());
  +    }
  +
  +    /**
  +     * Whether the presence of the specified element should cause
  +     * the document to be dynamic.  If this element isn't handled
  +     * by this BridgeExtension, just return false.
  +     *
  +     * @param e The element to check.
  +     */
  +    public boolean isDynamicElement(Element e) {
  +        return false;
       }
   }
  
  
  
  1.45      +55 -4     xml-batik/sources/org/apache/batik/swing/JSVGCanvas.java
  
  Index: JSVGCanvas.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/JSVGCanvas.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- JSVGCanvas.java   7 Sep 2003 22:25:28 -0000       1.44
  +++ JSVGCanvas.java   1 Aug 2004 03:08:48 -0000       1.45
  @@ -785,6 +785,16 @@
               = "JSVGCanvas.CanvasUserAgent.ToolTip.titleAndDesc";
   
           /**
  +         * The time of the last tool tip event.
  +         */
  +        protected long lastToolTipEventTimeStamp;
  +
  +        /**
  +         * The target for which the last tool tip event was fired.
  +         */
  +        protected EventTarget lastToolTipEventTarget;
  +
  +        /**
            * The handleElement method builds a tool tip from the
            * content of a &lt;title&gt; element, a &lt;desc&gt;
            * element or both. <br/>
  @@ -811,6 +821,12 @@
               if (!SVGConstants.SVG_NAMESPACE_URI.equals(elt.getNamespaceURI()))
                   return;
   
  +            // Don't handle tool tips for the root SVG element.
  +            if (elt.getParentNode() == 
  +                    elt.getOwnerDocument().getDocumentElement()) {
  +                return;
  +            }
  +
               if (elt.getLocalName().equals(SVGConstants.SVG_TITLE_TAG)) {
                   // If there is a <desc> peer, do nothing as the tooltip will
                   // be handled when handleElement is invoked for the <desc>
  @@ -941,12 +957,12 @@
   
               // On mouseover, set the tooltip to the title value
               target.addEventListener(SVGConstants.SVG_EVENT_MOUSEOVER,
  -                                    new ToolTipModifier(toolTip),
  +                                    new ToolTipModifier(toolTip, this),
                                       false);
   
               // On mouseout, remove the tooltip
               target.addEventListener(SVGConstants.SVG_EVENT_MOUSEOUT,
  -                                    new ToolTipModifier(null),
  +                                    new ToolTipModifier(null, this),
                                       false);
   
               if (locationListener == null) {
  @@ -985,6 +1001,23 @@
                   dialog.show(); // Safe to be called from any thread
               }
           }
  +
  +        /**
  +         * Sets the time and element of the last tool tip event handled.
  +         */
  +        public void setLastToolTipEvent(long t, EventTarget et) {
  +            lastToolTipEventTimeStamp = t;
  +            lastToolTipEventTarget = et;
  +        }
  +
  +        /**
  +         * Checks if the specified event time and element are the same
  +         * as the last tool tip event.
  +         */
  +        public boolean matchLastToolTipEvent(long t, EventTarget et) {
  +            return lastToolTipEventTimeStamp == t
  +                && lastToolTipEventTarget == et;
  +        }
       }
   
       // ----------------------------------------------------------------------
  @@ -1029,14 +1062,32 @@
           protected String toolTip;
   
           /**
  +         * The CanvasUserAgent used to track the last tool tip event.
  +         */
  +        protected CanvasUserAgent canvasUserAgent;
  +
  +        /**
            * @param toolTip value to which the JSVGCanvas should be
            *        set when the event occurs.
  +         * @param cua the CanvasUserAgent which will be used to track
  +         *        the last tool tip event.
            */
  -        public ToolTipModifier(String toolTip){
  +        public ToolTipModifier(String toolTip, CanvasUserAgent cua) {
               this.toolTip = toolTip;
  +            canvasUserAgent = cua;
           }
   
           public void handleEvent(Event evt){
  +            // Don't set the tool tip if another ToolTipModifier
  +            // has already handled this event (as it will have been
  +            // a higher priority tool tip).
  +            if (canvasUserAgent.matchLastToolTipEvent(evt.getTimeStamp(),
  +                                                     evt.getTarget())) {
  +                return;
  +            }
  +            canvasUserAgent.setLastToolTipEvent(evt.getTimeStamp(), 
  +                                                evt.getTarget());
  +
               EventQueue.invokeLater(new Runnable() {
                       public void run() {
                           setToolTipText(toolTip);
  
  
  

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

Reply via email to