You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2006/06/21 09:18:44 UTC

svn commit: r415933 [4/9] - in /xmlgraphics/batik/branches/anim: resources/org/apache/batik/dom/svg/resources/ sources/org/apache/batik/anim/ sources/org/apache/batik/anim/timing/ sources/org/apache/batik/anim/values/ sources/org/apache/batik/bridge/ s...

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGImageElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGImageElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGImageElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGImageElementBridge.java Wed Jun 21 00:18:34 2006
@@ -34,8 +34,11 @@
 import org.apache.batik.dom.AbstractNode;
 import org.apache.batik.dom.events.DOMMouseEvent;
 import org.apache.batik.dom.events.NodeEventTarget;
+import org.apache.batik.dom.svg.AnimatedLiveAttributeValue;
+import org.apache.batik.dom.svg.LiveAttributeException;
 import org.apache.batik.dom.svg.SVGOMDocument;
 import org.apache.batik.dom.svg.SVGOMElement;
+import org.apache.batik.dom.svg.SVGOMImageElement;
 import org.apache.batik.dom.util.XLinkSupport;
 import org.apache.batik.ext.awt.color.ICCColorSpaceExt;
 import org.apache.batik.ext.awt.image.renderable.ClipRable8Bit;
@@ -108,6 +111,8 @@
             return null;
         }
 
+        associateSVGContext(ctx, e, imageNode);
+
         hitCheckChildren = false;
         GraphicsNode node = buildImageGraphicsNode(ctx,e);
 
@@ -168,8 +173,7 @@
 
     protected GraphicsNode createImageGraphicsNode(BridgeContext ctx, 
                                                    Element e,
-                                                   ParsedURL purl)
-    {
+                                                   ParsedURL purl) {
         Rectangle2D bounds = getImageBounds(ctx, e);
         if ((bounds.getWidth() == 0) || (bounds.getHeight() == 0)) {
             ShapeNode sn = new ShapeNode();
@@ -402,6 +406,38 @@
     // BridgeUpdateHandler implementation //////////////////////////////////
 
     /**
+     * Invoked when the animated value of an animatable attribute has changed.
+     */
+    public void handleAnimatedAttributeChanged
+            (AnimatedLiveAttributeValue alav) {
+        if (alav.getNamespaceURI() == null) {
+            String ln = alav.getLocalName();
+            if (ln.equals(SVG_X_ATTRIBUTE)
+                    || ln.equals(SVG_Y_ATTRIBUTE)) {
+                updateImageBounds();
+                return;
+            } else if (ln.equals(SVG_WIDTH_ATTRIBUTE)
+                    || ln.equals(SVG_HEIGHT_ATTRIBUTE)) {
+                SVGOMImageElement ie = (SVGOMImageElement) e;
+                ImageNode imageNode = (ImageNode) node;
+                float val;
+                if (ln.charAt(0) == 'w') {
+                    val = ie.getWidth().getAnimVal().getValue();
+                } else {
+                    val = ie.getHeight().getAnimVal().getValue();
+                }
+                if (val == 0 || imageNode.getImage() instanceof ShapeNode) {
+                    rebuildImageNode();
+                } else {
+                    updateImageBounds();
+                }
+                return;
+            }
+        }
+        super.handleAnimatedAttributeChanged(alav);
+    }
+
+    /**
      * Invoked when an MutationEvent of type 'DOMAttrModified' is fired.
      */
     public void handleDOMAttrModifiedEvent(MutationEvent evt) {
@@ -409,43 +445,19 @@
         String attrName = evt.getAttrName();
         Node evtNode = evt.getRelatedNode();
 
-        if (attrName.equals(SVG_X_ATTRIBUTE) ||
-            attrName.equals(SVG_Y_ATTRIBUTE) ||
-	    attrName.equals(SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE)){
+        if (attrName.equals(SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE)) {
             updateImageBounds();
-        } else if (( XLinkSupport.XLINK_NAMESPACE_URI.equals
-                     (evtNode.getNamespaceURI()) ) 
-                   && SVG_HREF_ATTRIBUTE.equals(evtNode.getLocalName()) ){
+        } else if (XLINK_NAMESPACE_URI.equals(evtNode.getNamespaceURI())
+                && XLINK_HREF_ATTRIBUTE.equals(evtNode.getLocalName())) {
             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);
-            }
-            s = evt.getNewValue();
-            if (s.length() != 0) {
-                newV = UnitProcessor.svgHorizontalCoordinateToUserSpace
-                    (s, attrName, uctx);
-            }
-            if (oldV == newV) return;
-            
-            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);
+        Rectangle2D bounds = getImageBounds(ctx, e);
         GraphicsNode imageNode = ((ImageNode)node).getImage();
         float [] vb = null;
         if (imageNode instanceof RasterImageNode) {
@@ -923,50 +935,31 @@
      * @param ctx the bridge context
      * @param element the image element
      */
-    protected static
-        Rectangle2D getImageBounds(BridgeContext ctx, Element element) {
+    protected static Rectangle2D getImageBounds(BridgeContext ctx,
+                                                Element element) {
+        try {
+            SVGOMImageElement ie = (SVGOMImageElement) element;
 
-        UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, element);
+            // 'x' attribute - default is 0
+            float x = ie.getX().getAnimVal().getValue();
 
-        // 'x' attribute - default is 0
-        String s = element.getAttributeNS(null, SVG_X_ATTRIBUTE);
-        float x = 0;
-        if (s.length() != 0) {
-            x = UnitProcessor.svgHorizontalCoordinateToUserSpace
-                (s, SVG_X_ATTRIBUTE, uctx);
-        }
-
-        // 'y' attribute - default is 0
-        s = element.getAttributeNS(null, SVG_Y_ATTRIBUTE);
-        float y = 0;
-        if (s.length() != 0) {
-            y = UnitProcessor.svgVerticalCoordinateToUserSpace
-                (s, SVG_Y_ATTRIBUTE, uctx);
-        }
-
-        // 'width' attribute - required
-        s = element.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
-        float w;
-        if (s.length() == 0) {
-            throw new BridgeException(element, ERR_ATTRIBUTE_MISSING,
-                                      new Object[] {SVG_WIDTH_ATTRIBUTE});
-        } else {
-            w = UnitProcessor.svgHorizontalLengthToUserSpace
-                (s, SVG_WIDTH_ATTRIBUTE, uctx);
-        }
+            // 'y' attribute - default is 0
+            float y = ie.getY().getAnimVal().getValue();
 
-        // 'height' attribute - required
-        s = element.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
-        float h;
-        if (s.length() == 0) {
-            throw new BridgeException(element, ERR_ATTRIBUTE_MISSING,
-                                      new Object[] {SVG_HEIGHT_ATTRIBUTE});
-        } else {
-            h = UnitProcessor.svgVerticalLengthToUserSpace
-                (s, SVG_HEIGHT_ATTRIBUTE, uctx);
+            // 'width' attribute - required
+            float w = ie.getWidth().getAnimVal().getValue();
+
+            // 'height' attribute - required
+            float h = ie.getHeight().getAnimVal().getValue();
+
+            return new Rectangle2D.Float(x, y, w, h);
+        } catch (LiveAttributeException ex) {
+            throw new BridgeException
+                (ex.getElement(),
+                 ex.isMissing() ? ERR_ATTRIBUTE_MISSING
+                                : ERR_ATTRIBUTE_VALUE_MALFORMED,
+                 new Object[] { ex.getAttributeName(), ex.getValue() });
         }
-
-        return new Rectangle2D.Float(x, y, w, h);
     }
 
     GraphicsNode createBrokenImageNode

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGLineElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGLineElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGLineElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGLineElementBridge.java Wed Jun 21 00:18:34 2006
@@ -19,8 +19,12 @@
 
 import java.awt.geom.Line2D;
 
+import org.apache.batik.dom.svg.AnimatedLiveAttributeValue;
+import org.apache.batik.dom.svg.LiveAttributeException;
+import org.apache.batik.dom.svg.SVGOMLineElement;
 import org.apache.batik.gvt.ShapeNode;
 import org.apache.batik.gvt.ShapePainter;
+
 import org.w3c.dom.Element;
 import org.w3c.dom.events.MutationEvent;
 
@@ -87,60 +91,49 @@
                               Element e,
                               ShapeNode shapeNode) {
 
-        UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);
-        String s;
-
-        // 'x1' attribute - default is 0
-        s = e.getAttributeNS(null, SVG_X1_ATTRIBUTE);
-        float x1 = 0;
-        if (s.length() != 0) {
-            x1 = UnitProcessor.svgHorizontalCoordinateToUserSpace
-                (s, SVG_X1_ATTRIBUTE, uctx);
-        }
+        try {
+            SVGOMLineElement le = (SVGOMLineElement) e;
 
-        // 'y1' attribute - default is 0
-        s = e.getAttributeNS(null, SVG_Y1_ATTRIBUTE);
-        float y1 = 0;
-        if (s.length() != 0) {
-            y1 = UnitProcessor.svgVerticalCoordinateToUserSpace
-                (s, SVG_Y1_ATTRIBUTE, uctx);
-        }
+            // 'x1' attribute - default is 0
+            float x1 = le.getX1().getAnimVal().getValue();
 
-        // 'x2' attribute - default is 0
-        s = e.getAttributeNS(null, SVG_X2_ATTRIBUTE);
-        float x2 = 0;
-        if (s.length() != 0) {
-            x2 = UnitProcessor.svgHorizontalCoordinateToUserSpace
-                (s, SVG_X2_ATTRIBUTE, uctx);
-        }
+            // 'y1' attribute - default is 0
+            float y1 = le.getY1().getAnimVal().getValue();
 
-        // 'y2' attribute - default is 0
-        s = e.getAttributeNS(null, SVG_Y2_ATTRIBUTE);
-        float y2 = 0;
-        if (s.length() != 0) {
-            y2 = UnitProcessor.svgVerticalCoordinateToUserSpace
-                (s, SVG_Y2_ATTRIBUTE, uctx);
+            // 'x2' attribute - default is 0
+            float x2 = le.getX2().getAnimVal().getValue();
+
+            // 'y2' attribute - default is 0
+            float y2 = le.getY2().getAnimVal().getValue();
+
+            shapeNode.setShape(new Line2D.Float(x1, y1, x2, y2));
+        } catch (LiveAttributeException ex) {
+            throw new BridgeException
+                (ex.getElement(),
+                 ex.isMissing() ? ERR_ATTRIBUTE_MISSING
+                                : ERR_ATTRIBUTE_VALUE_MALFORMED,
+                 new Object[] { ex.getAttributeName(), ex.getValue() });
         }
-
-        shapeNode.setShape(new Line2D.Float(x1, y1, x2, y2));
     }
 
     // BridgeUpdateHandler implementation //////////////////////////////////
 
     /**
-     * Invoked when an MutationEvent of type 'DOMAttrModified' is fired.
+     * Invoked when the animated value of an animatable attribute has changed.
      */
-    public void handleDOMAttrModifiedEvent(MutationEvent evt) {
-        String attrName = evt.getAttrName();
-        if (attrName.equals(SVG_X1_ATTRIBUTE) ||
-            attrName.equals(SVG_Y1_ATTRIBUTE) ||
-            attrName.equals(SVG_X2_ATTRIBUTE) ||
-            attrName.equals(SVG_Y2_ATTRIBUTE)) {
-
-            buildShape(ctx, e, (ShapeNode)node);
-            handleGeometryChanged();
-        } else {
-            super.handleDOMAttrModifiedEvent(evt);
+    public void handleAnimatedAttributeChanged
+            (AnimatedLiveAttributeValue alav) {
+        if (alav.getNamespaceURI() == null) {
+            String ln = alav.getLocalName();
+            if (ln.equals(SVG_X1_ATTRIBUTE)
+                    || ln.equals(SVG_Y1_ATTRIBUTE)
+                    || ln.equals(SVG_X2_ATTRIBUTE)
+                    || ln.equals(SVG_Y2_ATTRIBUTE)) {
+                buildShape(ctx, e, (ShapeNode)node);
+                handleGeometryChanged();
+                return;
+            }
         }
+        super.handleAnimatedAttributeChanged(alav);
     }
 }

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGRectElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGRectElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGRectElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGRectElementBridge.java Wed Jun 21 00:18:34 2006
@@ -21,6 +21,9 @@
 import java.awt.geom.Rectangle2D;
 import java.awt.geom.RoundRectangle2D;
 
+import org.apache.batik.dom.svg.AnimatedLiveAttributeValue;
+import org.apache.batik.dom.svg.LiveAttributeException;
+import org.apache.batik.dom.svg.SVGOMRectElement;
 import org.apache.batik.gvt.ShapeNode;
 import org.apache.batik.gvt.ShapePainter;
 
@@ -65,113 +68,71 @@
                               Element e,
                               ShapeNode shapeNode) {
 
-        UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);
-        String s;
+        try {
+            SVGOMRectElement re = (SVGOMRectElement) e;
 
-        // 'x' attribute - default is 0
-        s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
-        float x = 0;
-        if (s.length() != 0) {
-            x = UnitProcessor.svgHorizontalCoordinateToUserSpace
-                (s, SVG_X_ATTRIBUTE, uctx);
-        }
+            // 'x' attribute - default is 0
+            float x = re.getX().getAnimVal().getValue();
 
-        // 'y' attribute - default is 0
-        s = e.getAttributeNS(null, SVG_Y_ATTRIBUTE);
-        float y = 0;
-        if (s.length() != 0) {
-            y = UnitProcessor.svgVerticalCoordinateToUserSpace
-                (s, SVG_Y_ATTRIBUTE, uctx);
-        }
+            // 'y' attribute - default is 0
+            float y = re.getY().getAnimVal().getValue();
 
-        // 'width' attribute - required
-        s = e.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
-        float w;
-        if (s.length() != 0) {
-            w = UnitProcessor.svgHorizontalLengthToUserSpace
-                (s, SVG_WIDTH_ATTRIBUTE, uctx);
-        } else {
-            throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
-                                      new Object[] {SVG_WIDTH_ATTRIBUTE, s});
-        }
+            // 'width' attribute - required
+            float w = re.getWidth().getAnimVal().getValue();
 
-        // 'height' attribute - required
-        s = e.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
-        float h;
-        if (s.length() != 0) {
-            h = UnitProcessor.svgVerticalLengthToUserSpace
-                (s, SVG_HEIGHT_ATTRIBUTE, uctx);
-        } else {
-            throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
-                                      new Object[] {SVG_HEIGHT_ATTRIBUTE, s});
-        }
+            // 'height' attribute - required
+            float h = re.getHeight().getAnimVal().getValue();
 
-        // 'rx' attribute - default is 0
-        s = e.getAttributeNS(null, SVG_RX_ATTRIBUTE);
-        boolean rxs = (s.length() != 0);
-        float rx = 0;
-        if (rxs) {
-            rx = UnitProcessor.svgHorizontalLengthToUserSpace
-                (s, SVG_RX_ATTRIBUTE, uctx);
-        }
-        rx = (rx > w / 2) ? w / 2 : rx;
+            // 'rx' attribute - default is 0
+            float rx = re.getRx().getAnimVal().getValue();
+            if (rx > w / 2) {
+                rx = w / 2;
+            }
 
-        // 'ry' attribute - default is 0
-        s = e.getAttributeNS(null, SVG_RY_ATTRIBUTE);
-        boolean rys = (s.length() != 0);
-        float ry = 0;
-        if (rys) {
-            ry = UnitProcessor.svgVerticalLengthToUserSpace
-                (s, SVG_RY_ATTRIBUTE, uctx);
-        }
-        ry = (ry > h / 2) ? h / 2 : ry;
+            // 'ry' attribute - default is ry
+            float ry = re.getRy().getAnimVal().getValue();
+            if (ry > h / 2) {
+                ry = h / 2;
+            }
 
-        Shape shape = null;
-        if (rxs && rys) {
+            Shape shape;
             if (rx == 0 || ry == 0) {
                 shape = new Rectangle2D.Float(x, y, w, h);
             } else {
                 shape = new RoundRectangle2D.Float(x, y, w, h, rx*2, ry*2);
             }
-        } else if (rxs) {
-            if (rx == 0) {
-                shape = new Rectangle2D.Float(x, y, w, h);
-            } else {
-                shape = new RoundRectangle2D.Float(x, y, w, h, rx*2, rx*2);
-            }
-        } else if (rys) {
-            if (ry == 0) {
-                shape = new Rectangle2D.Float(x, y, w, h);
-            } else {
-                shape = new RoundRectangle2D.Float(x, y, w, h, ry*2, ry*2);
-            }
-        } else {
-            shape = new Rectangle2D.Float(x, y, w, h);
+            shapeNode.setShape(shape);
+        } catch (LiveAttributeException ex) {
+            throw new BridgeException
+                (ex.getElement(),
+                 ex.isMissing() ? ERR_ATTRIBUTE_MISSING
+                                : ERR_ATTRIBUTE_VALUE_MALFORMED,
+                 new Object[] { ex.getAttributeName(), ex.getValue() });
         }
-        shapeNode.setShape(shape);
     }
 
     // BridgeUpdateHandler implementation //////////////////////////////////
 
     /**
-     * Invoked when an MutationEvent of type 'DOMAttrModified' is fired.
+     * Invoked when the animated value of an animatable attribute has changed.
      */
-    public void handleDOMAttrModifiedEvent(MutationEvent evt) {
-        String attrName = evt.getAttrName();
-        if (attrName.equals(SVG_X_ATTRIBUTE) ||
-            attrName.equals(SVG_Y_ATTRIBUTE) ||
-            attrName.equals(SVG_WIDTH_ATTRIBUTE) ||
-            attrName.equals(SVG_HEIGHT_ATTRIBUTE) ||
-            attrName.equals(SVG_RX_ATTRIBUTE) ||
-            attrName.equals(SVG_RY_ATTRIBUTE)) {
-
-            buildShape(ctx, e, (ShapeNode)node);
-            handleGeometryChanged();
-        } else {
-            super.handleDOMAttrModifiedEvent(evt);
+    public void handleAnimatedAttributeChanged
+            (AnimatedLiveAttributeValue alav) {
+        if (alav.getNamespaceURI() == null) {
+            String ln = alav.getLocalName();
+            if (ln.equals(SVG_X_ATTRIBUTE)
+                    || ln.equals(SVG_Y_ATTRIBUTE)
+                    || ln.equals(SVG_WIDTH_ATTRIBUTE)
+                    || ln.equals(SVG_HEIGHT_ATTRIBUTE)
+                    || ln.equals(SVG_RX_ATTRIBUTE)
+                    || ln.equals(SVG_RY_ATTRIBUTE)) {
+                buildShape(ctx, e, (ShapeNode)node);
+                handleGeometryChanged();
+                return;
+            }
         }
+        super.handleAnimatedAttributeChanged(alav);
     }
-
 
     protected ShapePainter createShapePainter(BridgeContext ctx,
                                               Element e,

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSVGElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSVGElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSVGElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSVGElementBridge.java Wed Jun 21 00:18:34 2006
@@ -29,8 +29,11 @@
 import java.util.List;
 import java.util.Set;
 
+import org.apache.batik.dom.svg.AnimatedLiveAttributeValue;
+import org.apache.batik.dom.svg.LiveAttributeException;
 import org.apache.batik.dom.svg.SVGContext;
 import org.apache.batik.dom.svg.SVGOMElement;
+import org.apache.batik.dom.svg.SVGOMSVGElement;
 import org.apache.batik.dom.svg.SVGSVGContext;
 import org.apache.batik.ext.awt.image.renderable.ClipRable8Bit;
 import org.apache.batik.ext.awt.image.renderable.Filter;
@@ -92,130 +95,122 @@
      * @return a graphics node that represents the specified element
      */
     public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
-	// 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
-	if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) {
-	    return null;
-	}
+        // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
+        if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) {
+            return null;
+        }
 
         CanvasGraphicsNode cgn;
         cgn = (CanvasGraphicsNode)instantiateGraphicsNode();
 
-        UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);
-        String s;
+        associateSVGContext(ctx, e, cgn);
 
-        // In some cases we converted document fragments which didn't
-        // have a parent SVG element, this check makes sure only the
-        // real root of the SVG Document tries to do negotiation with
-        // the UA.
-        SVGDocument doc = (SVGDocument)e.getOwnerDocument();
-        boolean isOutermost = (doc.getRootElement() == e);
-        float x = 0;
-        float y = 0;
-        // x and y have no meaning on the outermost 'svg' element
-        if (!isOutermost) {
-            // 'x' attribute - default is 0
-            s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
-            if (s.length() != 0) {
-                x = UnitProcessor.svgHorizontalCoordinateToUserSpace
-                    (s, SVG_X_ATTRIBUTE, uctx);
-            }
-            // 'y' attribute - default is 0
-            s = e.getAttributeNS(null, SVG_Y_ATTRIBUTE);
-            if (s.length() != 0) {
-                y = UnitProcessor.svgVerticalCoordinateToUserSpace
-                    (s, SVG_Y_ATTRIBUTE, uctx);
-            }
-        }
+        try {
+            // In some cases we converted document fragments which didn't
+            // have a parent SVG element, this check makes sure only the
+            // real root of the SVG Document tries to do negotiation with
+            // the UA.
+            SVGDocument doc = (SVGDocument)e.getOwnerDocument();
+            SVGOMSVGElement se = (SVGOMSVGElement) e;
+            boolean isOutermost = (doc.getRootElement() == e);
+            float x = 0;
+            float y = 0;
+            // x and y have no meaning on the outermost 'svg' element
+            if (!isOutermost) {
+                // 'x' attribute - default is 0
+                x = se.getX().getAnimVal().getValue();
 
-        // 'width' attribute - default is 100%
-        s = e.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
-        if (s.length() == 0) {
-            s = SVG_SVG_WIDTH_DEFAULT_VALUE;
-        }
-        float w = UnitProcessor.svgHorizontalLengthToUserSpace
-            (s, SVG_WIDTH_ATTRIBUTE, uctx);
+                // 'y' attribute - default is 0
+                y = se.getY().getAnimVal().getValue();
+            }
 
-        // 'height' attribute - default is 100%
-        s = e.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
-        if (s.length() == 0) {
-            s = SVG_SVG_HEIGHT_DEFAULT_VALUE;
-        }
-        float h = UnitProcessor.svgVerticalLengthToUserSpace
-            (s, SVG_HEIGHT_ATTRIBUTE, uctx);
+            // 'width' attribute - default is 100%
+            float w = se.getWidth().getAnimVal().getValue();
 
-        // 'visibility'
-        cgn.setVisible(CSSUtilities.convertVisibility(e));
+            // 'height' attribute - default is 100%
+            float h = se.getHeight().getAnimVal().getValue();
 
-        // 'viewBox' and "preserveAspectRatio' attributes
-        AffineTransform viewingTransform =
-            ViewBox.getPreserveAspectRatioTransform(e, w, h);
+            // 'visibility'
+            cgn.setVisible(CSSUtilities.convertVisibility(e));
 
-        float actualWidth = w;
-        float actualHeight = h;
-        try {
-            AffineTransform vtInv = viewingTransform.createInverse();
-            actualWidth = (float) (w*vtInv.getScaleX());
-            actualHeight = (float) (h*vtInv.getScaleY());
-        } catch (NoninvertibleTransformException ex) {}
-
-        AffineTransform positionTransform =
-            AffineTransform.getTranslateInstance(x, y);
-        // The outermost preserveAspectRatio matrix is set by the user
-        // agent, so we don't need to set the transform for outermost svg
-        if (!isOutermost) {
-            // X & Y are ignored on outermost SVG.
-            cgn.setPositionTransform(positionTransform);
-        } else if (doc == ctx.getDocument()) {
-            // <!> FIXME: hack to compute the original document's size
-            ctx.setDocumentSize(new Dimension((int)(w+0.5f), (int)(h+0.5f)));
-        }
-        // Set the viewing transform, this is often updated when the
-        // component prepares for rendering.
-        cgn.setViewingTransform(viewingTransform);
-
-        // 'overflow' and 'clip'
-        Shape clip = null;
-        if (CSSUtilities.convertOverflow(e)) { // overflow:hidden
-            float [] offsets = CSSUtilities.convertClip(e);
-            if (offsets == null) { // clip:auto
-                clip = new Rectangle2D.Float(x, y, w, h);
-            } else { // clip:rect(<x> <y> <w> <h>)
-                // offsets[0] = top
-                // offsets[1] = right
-                // offsets[2] = bottom
-                // offsets[3] = left
-                clip = new Rectangle2D.Float(x+offsets[3],
-                                             y+offsets[0],
-                                             w-offsets[1]-offsets[3],
-                                             h-offsets[2]-offsets[0]);
-            }
-        }
+            // 'viewBox' and "preserveAspectRatio' attributes
+            AffineTransform viewingTransform =
+                ViewBox.getPreserveAspectRatioTransform(e, w, h);
 
-        if (clip != null) {
+            float actualWidth = w;
+            float actualHeight = h;
             try {
-                AffineTransform at = new AffineTransform(positionTransform);
-                at.concatenate(viewingTransform);
-                at = at.createInverse(); // clip in user space
-                clip = at.createTransformedShape(clip);
-                Filter filter = cgn.getGraphicsNodeRable(true);
-                cgn.setClip(new ClipRable8Bit(filter, clip));
+                AffineTransform vtInv = viewingTransform.createInverse();
+                actualWidth = (float) (w*vtInv.getScaleX());
+                actualHeight = (float) (h*vtInv.getScaleY());
             } catch (NoninvertibleTransformException ex) {}
-        }
-        RenderingHints hints = null;
-        hints = CSSUtilities.convertColorRendering(e, hints);
-        if (hints != null)
-            cgn.setRenderingHints(hints);
-
-        // 'enable-background'
-        Rectangle2D r = CSSUtilities.convertEnableBackground(e);
-        if (r != null) {
-            cgn.setBackgroundEnable(r);
-        }
 
-        ctx.openViewport
-            (e, new SVGSVGElementViewport(actualWidth,
-                                          actualHeight));
-        return cgn;
+            AffineTransform positionTransform =
+                AffineTransform.getTranslateInstance(x, y);
+            // The outermost preserveAspectRatio matrix is set by the user
+            // agent, so we don't need to set the transform for outermost svg
+            if (!isOutermost) {
+                // X & Y are ignored on outermost SVG.
+                cgn.setPositionTransform(positionTransform);
+            } else if (doc == ctx.getDocument()) {
+                // <!> FIXME: hack to compute the original document's size
+                ctx.setDocumentSize(new Dimension((int) (w + 0.5f),
+                                                  (int) (h + 0.5f)));
+            }
+            // Set the viewing transform, this is often updated when the
+            // component prepares for rendering.
+            cgn.setViewingTransform(viewingTransform);
+
+            // 'overflow' and 'clip'
+            Shape clip = null;
+            if (CSSUtilities.convertOverflow(e)) { // overflow:hidden
+                float [] offsets = CSSUtilities.convertClip(e);
+                if (offsets == null) { // clip:auto
+                    clip = new Rectangle2D.Float(x, y, w, h);
+                } else { // clip:rect(<x> <y> <w> <h>)
+                    // offsets[0] = top
+                    // offsets[1] = right
+                    // offsets[2] = bottom
+                    // offsets[3] = left
+                    clip = new Rectangle2D.Float(x+offsets[3],
+                                                 y+offsets[0],
+                                                 w-offsets[1]-offsets[3],
+                                                 h-offsets[2]-offsets[0]);
+                }
+            }
+
+            if (clip != null) {
+                try {
+                    AffineTransform at = new AffineTransform(positionTransform);
+                    at.concatenate(viewingTransform);
+                    at = at.createInverse(); // clip in user space
+                    clip = at.createTransformedShape(clip);
+                    Filter filter = cgn.getGraphicsNodeRable(true);
+                    cgn.setClip(new ClipRable8Bit(filter, clip));
+                } catch (NoninvertibleTransformException ex) {}
+            }
+            RenderingHints hints = null;
+            hints = CSSUtilities.convertColorRendering(e, hints);
+            if (hints != null)
+                cgn.setRenderingHints(hints);
+
+            // 'enable-background'
+            Rectangle2D r = CSSUtilities.convertEnableBackground(e);
+            if (r != null) {
+                cgn.setBackgroundEnable(r);
+            }
+
+            ctx.openViewport
+                (e, new SVGSVGElementViewport(actualWidth,
+                                              actualHeight));
+            return cgn;
+        } catch (LiveAttributeException ex) {
+            throw new BridgeException
+                (ex.getElement(),
+                 ex.isMissing() ? ERR_ATTRIBUTE_MISSING
+                                : ERR_ATTRIBUTE_VALUE_MALFORMED,
+                 new Object[] { ex.getAttributeName(), ex.getValue() });
+        }
     }
 
     /**
@@ -255,143 +250,155 @@
     }
 
     /**
+     * Invoked when the animated value of an animatable attribute has changed.
+     */
+    public void handleAnimatedAttributeChanged
+            (AnimatedLiveAttributeValue alav) {
+        try {
+            boolean rebuild = false;
+            if (alav.getNamespaceURI() == null) {
+                String ln = alav.getLocalName();
+                if (ln.equals(SVG_WIDTH_ATTRIBUTE)
+                        || ln.equals(SVG_HEIGHT_ATTRIBUTE)) {
+                    rebuild = true;
+                } else if (ln.equals(SVG_X_ATTRIBUTE)
+                        || ln.equals(SVG_Y_ATTRIBUTE)) {
+                    SVGDocument doc = (SVGDocument)e.getOwnerDocument();
+                    SVGOMSVGElement se = (SVGOMSVGElement) e;
+                    // X & Y are ignored on outermost SVG.
+                    boolean isOutermost = doc.getRootElement() == e;
+                    if (!isOutermost) {
+                        // 'x' attribute - default is 0
+                        float x = se.getX().getAnimVal().getValue();
+
+                        // 'y' attribute - default is 0
+                        float y = se.getY().getAnimVal().getValue();
+
+                        AffineTransform positionTransform =
+                            AffineTransform.getTranslateInstance(x, y);
+                        CanvasGraphicsNode cgn;
+                        cgn = (CanvasGraphicsNode)node;
+
+                        cgn.setPositionTransform(positionTransform);
+                        return;
+                    }
+                }
+
+                if (rebuild) {
+                    CompositeGraphicsNode gn = node.getParent();
+                    gn.remove(node);
+                    disposeTree(e, false);
+
+                    handleElementAdded(gn, e.getParentNode(), e);
+                    return;
+                }
+            }
+        } catch (LiveAttributeException ex) {
+            throw new BridgeException
+                (ex.getElement(),
+                 ex.isMissing() ? ERR_ATTRIBUTE_MISSING
+                                : ERR_ATTRIBUTE_VALUE_MALFORMED,
+                 new Object[] { ex.getAttributeName(),
+                                ex.getValue() });
+        }
+        super.handleAnimatedAttributeChanged(alav);
+    }
+
+    /**
      * Invoked when an MutationEvent of type 'DOMAttrModified' is fired.
      */
     public void handleDOMAttrModifiedEvent(MutationEvent evt) {
-        // Don't call 'super' because there is no 'transform'
-        // attribute on <svg>
-        String attrName = evt.getAttrName();
-        boolean rebuild = false;
-        if (attrName.equals(SVG_WIDTH_ATTRIBUTE) ||
-            attrName.equals(SVG_HEIGHT_ATTRIBUTE) ) {
-            rebuild = true;
-        } else if (attrName.equals(SVG_X_ATTRIBUTE) ||
-                   attrName.equals(SVG_Y_ATTRIBUTE)) {
-            SVGDocument doc = (SVGDocument)e.getOwnerDocument();
-            boolean isOutermost = (doc.getRootElement() == e);
-            if (!isOutermost) {
+        try {
+            // Don't call 'super' because there is no 'transform'
+            // attribute on <svg>
+            String attrName = evt.getAttrName();
+            boolean rebuild = false;
+            if (attrName.equals(SVG_VIEW_BOX_ATTRIBUTE) ||
+                       attrName.equals(SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE)) {
+                SVGDocument doc = (SVGDocument)e.getOwnerDocument();
+                SVGOMSVGElement se = (SVGOMSVGElement) e;
+                boolean isOutermost = doc.getRootElement() == e;
+
                 // X & Y are ignored on outermost SVG.
                 float x = 0;
                 float y = 0;
-                UnitProcessor.Context uctx;
-                uctx = UnitProcessor.createContext(ctx, e);
-                // 'x' attribute - default is 0
-                String s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
-                if (s.length() != 0) {
-                    x = UnitProcessor.svgHorizontalCoordinateToUserSpace
-                        (s, SVG_X_ATTRIBUTE, uctx);
-                }
-                // 'y' attribute - default is 0
-                s = e.getAttributeNS(null, SVG_Y_ATTRIBUTE);
-                if (s.length() != 0) {
-                    y = UnitProcessor.svgVerticalCoordinateToUserSpace
-                        (s, SVG_Y_ATTRIBUTE, uctx);
-                }
+                if (!isOutermost) {
+                    // 'x' attribute - default is 0
+                    x = se.getX().getAnimVal().getValue();
 
-                AffineTransform positionTransform =
-                    AffineTransform.getTranslateInstance(x, y);
+                    // 'y' attribute - default is 0
+                    y = se.getY().getAnimVal().getValue();
+                }
+                
+                // 'width' attribute - default is 100%
+                float w = se.getWidth().getAnimVal().getValue();
+                
+                // 'height' attribute - default is 100%
+                float h = se.getHeight().getAnimVal().getValue();
+                
                 CanvasGraphicsNode cgn;
                 cgn = (CanvasGraphicsNode)node;
-
-                cgn.setPositionTransform(positionTransform);
-            }
-        } else if (attrName.equals(SVG_VIEW_BOX_ATTRIBUTE) ||
-                   attrName.equals(SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE)) {
-            SVGDocument doc = (SVGDocument)e.getOwnerDocument();
-            boolean isOutermost = (doc.getRootElement() == e);
-
-            String s;
-            UnitProcessor.Context uctx;
-            uctx = UnitProcessor.createContext(ctx, e);
-            // X & Y are ignored on outermost SVG.
-            float x = 0;
-            float y = 0;
-            if (!isOutermost) {
-                // 'x' attribute - default is 0
-                s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
-                if (s.length() != 0) {
-                    x = UnitProcessor.svgHorizontalCoordinateToUserSpace
-                        (s, SVG_X_ATTRIBUTE, uctx);
-                }
-                // 'y' attribute - default is 0
-                s = e.getAttributeNS(null, SVG_Y_ATTRIBUTE);
-                if (s.length() != 0) {
-                    y = UnitProcessor.svgVerticalCoordinateToUserSpace
-                        (s, SVG_Y_ATTRIBUTE, uctx);
-                }
-            }
-            
-            // 'width' attribute - default is 100%
-            s = e.getAttributeNS(null, SVG_WIDTH_ATTRIBUTE);
-            if (s.length() == 0) {
-                s = SVG_SVG_WIDTH_DEFAULT_VALUE;
-            }
-            float w = UnitProcessor.svgHorizontalLengthToUserSpace
-                (s, SVG_WIDTH_ATTRIBUTE, uctx);
-            
-            // 'height' attribute - default is 100%
-            s = e.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
-            if (s.length() == 0) {
-                s = SVG_SVG_HEIGHT_DEFAULT_VALUE;
-            }
-            float h = UnitProcessor.svgVerticalLengthToUserSpace
-                (s, SVG_HEIGHT_ATTRIBUTE, uctx);
-            
-            CanvasGraphicsNode cgn;
-            cgn = (CanvasGraphicsNode)node;
-            
-            // 'viewBox' and "preserveAspectRatio' attributes
-            AffineTransform newVT =
-                ViewBox.getPreserveAspectRatioTransform(e, w, h);
-            AffineTransform oldVT = cgn.getViewingTransform();
-            if ((newVT.getScaleX() != oldVT.getScaleX()) ||
-                (newVT.getScaleY() != oldVT.getScaleY()) ||
-                (newVT.getShearX() != oldVT.getShearX()) ||
-                (newVT.getShearY() != oldVT.getShearY()))
-                rebuild = true;
-            else {
-                // Only differs in translate.
-                cgn.setViewingTransform(newVT);
                 
-                // 'overflow' and 'clip'
-                Shape clip = null;
-                if (CSSUtilities.convertOverflow(e)) { // overflow:hidden
-                    float [] offsets = CSSUtilities.convertClip(e);
-                    if (offsets == null) { // clip:auto
-                        clip = new Rectangle2D.Float(x, y, w, h);
-                    } else { // clip:rect(<x> <y> <w> <h>)
-                        // offsets[0] = top
-                        // offsets[1] = right
-                        // offsets[2] = bottom
-                        // offsets[3] = left
-                        clip = new Rectangle2D.Float(x+offsets[3],
-                                                     y+offsets[0],
-                                                     w-offsets[1]-offsets[3],
-                                                     h-offsets[2]-offsets[0]);
+                // 'viewBox' and "preserveAspectRatio' attributes
+                AffineTransform newVT =
+                    ViewBox.getPreserveAspectRatioTransform(e, w, h);
+                AffineTransform oldVT = cgn.getViewingTransform();
+                if ((newVT.getScaleX() != oldVT.getScaleX()) ||
+                    (newVT.getScaleY() != oldVT.getScaleY()) ||
+                    (newVT.getShearX() != oldVT.getShearX()) ||
+                    (newVT.getShearY() != oldVT.getShearY()))
+                    rebuild = true;
+                else {
+                    // Only differs in translate.
+                    cgn.setViewingTransform(newVT);
+                    
+                    // 'overflow' and 'clip'
+                    Shape clip = null;
+                    if (CSSUtilities.convertOverflow(e)) { // overflow:hidden
+                        float [] offsets = CSSUtilities.convertClip(e);
+                        if (offsets == null) { // clip:auto
+                            clip = new Rectangle2D.Float(x, y, w, h);
+                        } else { // clip:rect(<x> <y> <w> <h>)
+                            // offsets[0] = top
+                            // offsets[1] = right
+                            // offsets[2] = bottom
+                            // offsets[3] = left
+                            clip = new Rectangle2D.Float(x+offsets[3],
+                                                         y+offsets[0],
+                                                         w-offsets[1]-offsets[3],
+                                                         h-offsets[2]-offsets[0]);
+                        }
+                    }
+                    
+                    if (clip != null) {
+                        try {
+                            AffineTransform at;
+                            at = cgn.getPositionTransform();
+                            at = new AffineTransform(at);
+                            at.concatenate(newVT);
+                            at = at.createInverse(); // clip in user space
+                            clip = at.createTransformedShape(clip);
+                            Filter filter = cgn.getGraphicsNodeRable(true);
+                            cgn.setClip(new ClipRable8Bit(filter, clip));
+                        } catch (NoninvertibleTransformException ex) {}
                     }
-                }
-                
-                if (clip != null) {
-                    try {
-                        AffineTransform at;
-                        at = cgn.getPositionTransform();
-                        at = new AffineTransform(at);
-                        at.concatenate(newVT);
-                        at = at.createInverse(); // clip in user space
-                        clip = at.createTransformedShape(clip);
-                        Filter filter = cgn.getGraphicsNodeRable(true);
-                        cgn.setClip(new ClipRable8Bit(filter, clip));
-                    } catch (NoninvertibleTransformException ex) {}
                 }
             }
-        }
 
-        if (rebuild) {
-            CompositeGraphicsNode gn = node.getParent();
-            gn.remove(node);
-            disposeTree(e);
+            if (rebuild) {
+                CompositeGraphicsNode gn = node.getParent();
+                gn.remove(node);
+                disposeTree(e, false);
 
-            handleElementAdded(gn, e.getParentNode(), e);
+                handleElementAdded(gn, e.getParentNode(), e);
+            }
+        } catch (LiveAttributeException ex) {
+            throw new BridgeException
+                (ex.getElement(),
+                 ex.isMissing() ? ERR_ATTRIBUTE_MISSING
+                                : ERR_ATTRIBUTE_VALUE_MALFORMED,
+                 new Object[] { ex.getAttributeName(),
+                                ex.getValue() });
         }
     }
 

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSetElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSetElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSetElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSetElementBridge.java Wed Jun 21 00:18:34 2006
@@ -1,3 +1,20 @@
+/*
+
+   Copyright 2006  The Apache Software Foundation 
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
 package org.apache.batik.bridge;
 
 import org.apache.batik.anim.AbstractAnimation;
@@ -7,6 +24,9 @@
 
 /**
  * A bridge class for the 'set' animation element.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
  */
 public class SVGSetElementBridge extends SVGAnimationElementBridge {
 

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGShapeElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGShapeElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGShapeElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGShapeElementBridge.java Wed Jun 21 00:18:34 2006
@@ -49,9 +49,12 @@
      */
     public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
         ShapeNode shapeNode = (ShapeNode)super.createGraphicsNode(ctx, e);
-	if (shapeNode == null) {
-	    return null;
-	}
+        if (shapeNode == null) {
+            return null;
+        }
+
+        associateSVGContext(ctx, e, shapeNode);
+
         // delegates to subclasses the shape construction
         buildShape(ctx, e, shapeNode);
 

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGTextElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGTextElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGTextElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGTextElementBridge.java Wed Jun 21 00:18:34 2006
@@ -46,6 +46,7 @@
 import org.apache.batik.css.engine.value.ListValue;
 import org.apache.batik.css.engine.value.Value;
 import org.apache.batik.dom.events.NodeEventTarget;
+import org.apache.batik.dom.svg.AnimatedLiveAttributeValue;
 import org.apache.batik.dom.svg.SVGContext;
 import org.apache.batik.dom.svg.SVGOMElement;
 import org.apache.batik.dom.svg.SVGTextContent;
@@ -72,6 +73,7 @@
 import org.w3c.dom.events.Event;
 import org.w3c.dom.events.EventListener;
 import org.w3c.dom.events.MutationEvent;
+import org.w3c.dom.svg.SVGLength;
 
 /**
  * Bridge class for the &lt;text> element.
@@ -142,6 +144,18 @@
         if (node == null)
             return null;
 
+        associateSVGContext(ctx, e, node);
+
+        // traverse the children to add context on 
+        // <tspan>, <tref> and <textPath>
+        Node child = getFirstChild(e);
+        while (child != null) {
+            if (child.getNodeType() == Node.ELEMENT_NODE) {
+                addContextToChild(ctx,(Element)child);
+            }
+            child = getNextSibling(child);
+        }
+
         // specify the text painter to use
         if (ctx.getTextPainter() != null)
             node.setTextPainter(ctx.getTextPainter());
@@ -334,19 +348,9 @@
                                             GraphicsNode node) {
         super.initializeDynamicSupport(ctx, e, node);
 
-        if (!ctx.isDynamic())
-            return;             // Only add the listeners if we are dynamic
-
-        addTextEventListeners(ctx, (NodeEventTarget) e);
-
-        // traverse the children to add context on 
-        // <tspan>, <tref> and <textPath>
-        Node child = getFirstChild(e);
-        while (child != null) {
-            if (child.getNodeType() == Node.ELEMENT_NODE) {
-                addContextToChild(ctx,(Element)child);
-            }
-            child = getNextSibling(child);
+        if (ctx.isDynamic()) {
+            // Only add the listeners if we are dynamic.
+            addTextEventListeners(ctx, (NodeEventTarget) e);
         }
     }
 
@@ -1982,6 +1986,18 @@
             return CSSUtilities.getComputedStyle
                 (e, SVGCSSEngine.FONT_SIZE_INDEX).getFloatValue();
         }
+        
+        public float svgToUserSpace(float v, int type, int pcInterp) {
+            if (pcInterp == PERCENTAGE_FONT_SIZE
+                    && type == SVGLength.SVG_LENGTHTYPE_PERCENTAGE) {
+                // XXX
+                return 0f;
+            } else {
+                return UnitProcessor.svgToUserSpace(v, (short) type,
+                                                    (short) (3 - pcInterp),
+                                                    unitContext);
+            }
+        }
     }
 
     /**
@@ -2007,6 +2023,7 @@
 
             super(ctx,parent,e);
         }
+
         /**
          * Invoked when an MutationEvent of type 'DOMAttrModified' is fired.
          */
@@ -2045,6 +2062,14 @@
         }
 
         /**
+         * Invoked when the animated value of an animatable attribute has
+         * changed.
+         */
+        public void handleAnimatedAttributeChanged
+                (AnimatedLiveAttributeValue alav) {
+        }
+
+        /**
          * Disposes this BridgeUpdateHandler and releases all resources.
          */
         public void dispose(){
@@ -2055,7 +2080,7 @@
 
     protected class AbstractTextChildTextContent 
         extends AbstractTextChildBridgeUpdateHandler
-        implements SVGTextContent{
+        implements SVGTextContent {
 
         /**
          * Initialize the AbstractTextChildBridgeUpdateHandler implementation.

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGUseElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGUseElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGUseElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGUseElementBridge.java Wed Jun 21 00:18:34 2006
@@ -46,6 +46,7 @@
  * @version $Id$
  */
 public class SVGUseElementBridge extends AbstractGraphicsNodeBridge {
+
     /**
      * Used to handle mutation of the referenced content. This is
      * only used in dynamic context and only for reference to local
@@ -53,7 +54,10 @@
      */
     protected ReferencedElementMutationListener l;
 
-    protected BridgeContext subCtx=null;
+    /**
+     * The bridge context for the referenced document.
+     */
+    protected BridgeContext subCtx;
 
     /**
      * Constructs a new bridge for the &lt;use> element.
@@ -178,6 +182,7 @@
 
         if (gn == null) {
             gn = new CompositeGraphicsNode();
+            associateSVGContext(ctx, e, node);
         } else {
             int s = gn.size();
             for (int i=0; i<s; i++)
@@ -439,18 +444,17 @@
         String attrName = evt.getAttrName();
         Node evtNode = evt.getRelatedNode();
 
-        if ((evtNode.getNamespaceURI() == null) &&
-            (attrName.equals(SVG_X_ATTRIBUTE) ||
-             attrName.equals(SVG_Y_ATTRIBUTE) ||
-             attrName.equals(SVG_TRANSFORM_ATTRIBUTE))) {
+        if (evtNode.getNamespaceURI() == null
+                && (attrName.equals(SVG_X_ATTRIBUTE)
+                    || attrName.equals(SVG_Y_ATTRIBUTE)
+                    || attrName.equals(SVG_TRANSFORM_ATTRIBUTE))) {
             node.setTransform(computeTransform(e, ctx));
             handleGeometryChanged();
-        } else if (((evtNode.getNamespaceURI() == null) && 
-                   (attrName.equals(SVG_WIDTH_ATTRIBUTE) ||
-                    attrName.equals(SVG_HEIGHT_ATTRIBUTE))) ||
-                   (( XLinkSupport.XLINK_NAMESPACE_URI.equals
-                     (evtNode.getNamespaceURI()) ) &&  
-                    SVG_HREF_ATTRIBUTE.equals(evtNode.getLocalName()))) {
+        } else if (evtNode.getNamespaceURI() == null
+                && (attrName.equals(SVG_WIDTH_ATTRIBUTE)
+                    || attrName.equals(SVG_HEIGHT_ATTRIBUTE))
+                || XLINK_NAMESPACE_URI.equals(evtNode.getNamespaceURI())
+                    && XLINK_HREF_ATTRIBUTE.equals(evtNode.getLocalName())) {
             buildCompositeGraphicsNode(ctx, e, (CompositeGraphicsNode)node);
         }
     }

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/BindableElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/BindableElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/BindableElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/BindableElementBridge.java Wed Jun 21 00:18:34 2006
@@ -115,6 +115,7 @@
 
         if (gn == null) {
             gn = new CompositeGraphicsNode();
+            associateSVGContext(ctx, e, gn);
         } else {
             int s = gn.size();
             for (int i = 0; i < s; i++) {

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java Wed Jun 21 00:18:34 2006
@@ -217,6 +217,8 @@
 
         cgn.add(tn);
 
+        associateSVGContext(ctx, e, cgn);
+
         return cgn;
     }
 

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/SVGMultiImageElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/SVGMultiImageElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/SVGMultiImageElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/SVGMultiImageElementBridge.java Wed Jun 21 00:18:34 2006
@@ -116,6 +116,8 @@
             return null;
         }
 
+        associateSVGContext(ctx, e, imgNode);
+
         Rectangle2D b = getImageBounds(ctx, e);
 
         // 'transform'
@@ -231,18 +233,10 @@
     protected void initializeDynamicSupport(BridgeContext ctx,
                                             Element e,
                                             GraphicsNode node) {
-        if (!ctx.isInteractive())
-            return;
-
-        // HACK due to the way images are represented in GVT
-        ImageNode imgNode = (ImageNode)node;
-        ctx.bind(e, imgNode.getImage());
-
-        if (ctx.isDynamic()) {
-            this.e = e;
-            this.node = node;
-            this.ctx = ctx;
-            ((SVGOMElement)e).setSVGContext(this);
+        if (ctx.isInteractive()) {
+            // HACK due to the way images are represented in GVT
+            ImageNode imgNode = (ImageNode)node;
+            ctx.bind(e, imgNode.getImage());
         }
     }
 
@@ -295,8 +289,8 @@
         Document doc = e.getOwnerDocument();
         Element imgElem = doc.createElementNS(SVG_NAMESPACE_URI, 
                                               SVG_IMAGE_TAG);
-        imgElem.setAttributeNS(XLinkSupport.XLINK_NAMESPACE_URI, 
-                               "href", purl.toString());
+        imgElem.setAttributeNS(XLINK_NAMESPACE_URI, 
+                               XLINK_HREF_ATTRIBUTE, purl.toString());
         // move the attributes from <subImageRef> to the <image> element
         NamedNodeMap attrs = e.getAttributes();
         int len = attrs.getLength();

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/XBLContentElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/XBLContentElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/XBLContentElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/XBLContentElementBridge.java Wed Jun 21 00:18:34 2006
@@ -109,6 +109,7 @@
 
         if (cgn == null) {
             cgn = new CompositeGraphicsNode();
+            associateSVGContext(ctx, e, cgn);
         } else {
             int s = cgn.size();
             for (int i = 0; i < s; i++) {

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/XBLShadowTreeElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/XBLShadowTreeElementBridge.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/XBLShadowTreeElementBridge.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/svg12/XBLShadowTreeElementBridge.java Wed Jun 21 00:18:34 2006
@@ -77,7 +77,11 @@
             return null;
         }
 
-        return new CompositeGraphicsNode();
+        CompositeGraphicsNode cgn = new CompositeGraphicsNode();
+
+        associateSVGContext(ctx, e, cgn);
+
+        return cgn;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/CSSEngine.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/CSSEngine.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/CSSEngine.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/CSSEngine.java Wed Jun 21 00:18:34 2006
@@ -1958,10 +1958,8 @@
         style.putComputed(n, false);
     }
 
-
     /**
      * Invalidates all the properties of the given node.
-     * 
      */
     protected void invalidateProperties(Node node, 
                                         int [] properties, 

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/ValueManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/ValueManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/ValueManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/ValueManager.java Wed Jun 21 00:18:34 2006
@@ -55,7 +55,8 @@
 
     /**
      * Returns the type of value this manager handles.  This should be
-     * one of the constants defined in {@link org.apache.batik.util.SVGTypes}.
+     * one of the TYPE_* constants defined in
+     * {@link org.apache.batik.util.SVGTypes}.
      */
     int getPropertyType();
 

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/ClipManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/ClipManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/ClipManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/ClipManager.java Wed Jun 21 00:18:34 2006
@@ -56,7 +56,7 @@
      * Implements {@link ValueManager#isAdditiveProperty()}.
      */
     public boolean isAdditiveProperty() {
-        return true;
+        return false;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/CursorManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/CursorManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/CursorManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/CursorManager.java Wed Jun 21 00:18:34 2006
@@ -100,7 +100,7 @@
      * Implements {@link ValueManager#isAdditiveProperty()}.
      */
     public boolean isAdditiveProperty() {
-        return true;
+        return false;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/FontSizeAdjustManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/FontSizeAdjustManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/FontSizeAdjustManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/FontSizeAdjustManager.java Wed Jun 21 00:18:34 2006
@@ -63,7 +63,7 @@
      * Implements {@link ValueManager#getPropertyType()}.
      */
     public int getPropertyType() {
-        return SVGTypes.TYPE_NUMBER_OR_IDENT;
+        return SVGTypes.TYPE_FONT_SIZE_ADJUST_VALUE;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/FontSizeManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/FontSizeManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/FontSizeManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/css2/FontSizeManager.java Wed Jun 21 00:18:34 2006
@@ -109,7 +109,7 @@
      * Implements {@link ValueManager#getPropertyType()}.
      */
     public int getPropertyType() {
-        return SVGTypes.TYPE_LENGTH_OR_IDENT;
+        return SVGTypes.TYPE_FONT_SIZE_VALUE;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/BaselineShiftManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/BaselineShiftManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/BaselineShiftManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/BaselineShiftManager.java Wed Jun 21 00:18:34 2006
@@ -78,7 +78,7 @@
      * Implements {@link ValueManager#getPropertyType()}.
      */
     public int getPropertyType() {
-        return SVGTypes.TYPE_LENGTH_OR_IDENT;
+        return SVGTypes.TYPE_BASELINE_SHIFT_VALUE;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/GlyphOrientationManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/GlyphOrientationManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/GlyphOrientationManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/GlyphOrientationManager.java Wed Jun 21 00:18:34 2006
@@ -62,7 +62,7 @@
      * Implements {@link ValueManager#getPropertyType()}.
      */
     public int getPropertyType() {
-        return SVGTypes.TYPE_ANGLE_OR_IDENT;
+        return SVGTypes.TYPE_ANGLE;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/KerningManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/KerningManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/KerningManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/KerningManager.java Wed Jun 21 00:18:34 2006
@@ -68,7 +68,7 @@
      * Implements {@link ValueManager#getPropertyType()}.
      */
     public int getPropertyType() {
-        return SVGTypes.TYPE_LENGTH_OR_IDENT;
+        return SVGTypes.TYPE_KERNING_VALUE;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/OpacityManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/OpacityManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/OpacityManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/OpacityManager.java Wed Jun 21 00:18:34 2006
@@ -79,7 +79,7 @@
      * Implements {@link ValueManager#getPropertyType()}.
      */
     public int getPropertyType() {
-        return SVGTypes.TYPE_NUMBER_OR_IDENT;
+        return SVGTypes.TYPE_NUMBER_OR_INHERIT;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/SpacingManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/SpacingManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/SpacingManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/SpacingManager.java Wed Jun 21 00:18:34 2006
@@ -74,7 +74,7 @@
      * Implements {@link ValueManager#getPropertyType()}.
      */
     public int getPropertyType() {
-        return SVGTypes.TYPE_LENGTH_OR_IDENT;
+        return SVGTypes.TYPE_SPACING_VALUE;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeDashoffsetManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeDashoffsetManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeDashoffsetManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeDashoffsetManager.java Wed Jun 21 00:18:34 2006
@@ -60,7 +60,7 @@
      * Implements {@link ValueManager#getPropertyType()}.
      */
     public int getPropertyType() {
-        return SVGTypes.TYPE_LENGTH_OR_IDENT;
+        return SVGTypes.TYPE_LENGTH_OR_INHERIT;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeMiterlimitManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeMiterlimitManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeMiterlimitManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeMiterlimitManager.java Wed Jun 21 00:18:34 2006
@@ -62,7 +62,7 @@
      * Implements {@link ValueManager#getPropertyType()}.
      */
     public int getPropertyType() {
-        return SVGTypes.TYPE_NUMBER_OR_IDENT;
+        return SVGTypes.TYPE_NUMBER_OR_INHERIT;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeWidthManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeWidthManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeWidthManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeWidthManager.java Wed Jun 21 00:18:34 2006
@@ -60,7 +60,7 @@
      * Implements {@link ValueManager#getPropertyType()}.
      */
     public int getPropertyType() {
-        return SVGTypes.TYPE_LENGTH_OR_IDENT;
+        return SVGTypes.TYPE_LENGTH_OR_INHERIT;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg12/LineHeightManager.java Wed Jun 21 00:18:34 2006
@@ -69,7 +69,7 @@
      * Implements {@link ValueManager#getPropertyType()}.
      */
     public int getPropertyType() {
-        return SVGTypes.TYPE_LENGTH_OR_IDENT;
+        return SVGTypes.TYPE_LINE_HEIGHT_VALUE;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg12/MarginLengthManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg12/MarginLengthManager.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg12/MarginLengthManager.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg12/MarginLengthManager.java Wed Jun 21 00:18:34 2006
@@ -67,7 +67,7 @@
      * Implements {@link ValueManager#getPropertyType()}.
      */
     public int getPropertyType() {
-        return SVGTypes.TYPE_LENGTH_OR_IDENT;
+        return SVGTypes.TYPE_LENGTH_OR_INHERIT;
     }
 
     /**

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/GenericDocument.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/GenericDocument.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/GenericDocument.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/GenericDocument.java Wed Jun 21 00:18:34 2006
@@ -17,6 +17,8 @@
  */
 package org.apache.batik.dom;
 
+import org.apache.batik.util.XMLConstants;
+
 import org.w3c.dom.Attr;
 import org.w3c.dom.CDATASection;
 import org.w3c.dom.Comment;
@@ -40,8 +42,10 @@
 public class GenericDocument
     extends AbstractDocument {
 
-    /** Local name for 'id' attributes. */
-    protected final static String ATTR_ID = "id";
+    /**
+     * Local name for 'id' attributes.
+     */
+    protected final static String ATTR_ID = XMLConstants.XML_ID_ATTRIBUTE;
 
     /**
      * Is this document immutable?

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGAnimatedLength.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGAnimatedLength.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGAnimatedLength.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGAnimatedLength.java Wed Jun 21 00:18:34 2006
@@ -19,6 +19,7 @@
 
 import org.apache.batik.parser.UnitProcessor;
 import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
 import org.w3c.dom.svg.SVGAnimatedLength;
 import org.w3c.dom.svg.SVGLength;
 
@@ -30,6 +31,7 @@
  * @version $Id$
  */
 public abstract class AbstractSVGAnimatedLength
+    extends    AbstractSVGAnimatedValue
     implements SVGAnimatedLength,
                LiveAttributeValue {
 
@@ -52,21 +54,6 @@
         UnitProcessor.OTHER_LENGTH;
 
     /**
-     * The associated element.
-     */
-    protected AbstractElement element;
-
-    /**
-     * The attribute's namespace URI.
-     */
-    protected String namespaceURI;
-
-    /**
-     * The attribute's local name.
-     */
-    protected String localName;
-
-    /**
      * This length's direction.
      */
     protected short direction;
@@ -77,9 +64,19 @@
     protected BaseSVGLength baseVal;
 
     /**
+     * The current animated value.
+     */
+    protected AnimSVGLength animVal;
+
+    /**
      * Whether the value is changing.
      */
     protected boolean changing;
+    
+    /**
+     * Whether the value must be non-negative.
+     */
+    protected boolean nonNegative;
 
     /**
      * Creates a new SVGAnimatedLength.
@@ -87,15 +84,16 @@
      * @param ns The attribute's namespace URI.
      * @param ln The attribute's local name.
      * @param dir The length's direction.
+     * @param nonneg Whether the length must be non-negative.
      */
     protected AbstractSVGAnimatedLength(AbstractElement elt,
                                         String ns,
                                         String ln,
-                                        short dir) {
-        element = elt;
-        namespaceURI = ns;
-        localName = ln;
+                                        short dir,
+                                        boolean nonneg) {
+        super(elt, ns, ln);
         direction = dir;
+        nonNegative = nonneg;
     }
 
     /**
@@ -118,7 +116,30 @@
      * <b>DOM</b>: Implements {@link SVGAnimatedLength#getAnimVal()}.
      */
     public SVGLength getAnimVal() {
-        throw new RuntimeException("!!! TODO: getAnimVal()");
+        if (animVal == null) {
+            animVal = new AnimSVGLength(direction);
+        }
+        return animVal;
+    }
+
+    /**
+     * Sets the animated value.
+     */
+    public void setAnimatedValue(int type, float val) {
+        if (animVal == null) {
+            animVal = new AnimSVGLength(direction);
+        }
+        hasAnimVal = true;
+        animVal.setAnimatedValue(type, val);
+        fireAnimatedAttributeListeners();
+    }
+
+    /**
+     * Resets the animated value.
+     */
+    public void resetAnimatedValue() {
+        hasAnimVal = false;
+        fireAnimatedAttributeListeners();
     }
 
     /**
@@ -128,6 +149,10 @@
         if (!changing && baseVal != null) {
             baseVal.invalidate();
         }
+        // XXX Notify baseVal listeners (if we need them).
+        if (!hasAnimVal) {
+            fireAnimatedAttributeListeners();
+        }
     }
 
     /**
@@ -137,6 +162,10 @@
         if (!changing && baseVal != null) {
             baseVal.invalidate();
         }
+        // XXX Notify baseVal listeners (if we need them).
+        if (!hasAnimVal) {
+            fireAnimatedAttributeListeners();
+        }
     }
 
     /**
@@ -146,10 +175,14 @@
         if (!changing && baseVal != null) {
             baseVal.invalidate();
         }
+        // XXX Notify baseVal listeners (if we need them).
+        if (!hasAnimVal) {
+            fireAnimatedAttributeListeners();
+        }
     }
 
     /**
-     * This class represents the SVGLength returned by getBaseVal().
+     * This class represents the SVGLength returned by {@link #getBaseVal()}.
      */
     protected class BaseSVGLength extends AbstractSVGLength {
 
@@ -193,26 +226,150 @@
                 return;
             }
 
-            String s = null;
+            unitType = SVG_LENGTHTYPE_UNKNOWN;
+            value = 0;
 
             Attr attr = element.getAttributeNodeNS(namespaceURI, localName);
-
+            String s;
             if (attr == null) {
                 s = getDefaultValue();
-            }
-            else{
+                if (s == null) {
+                    throw new LiveAttributeException(element, localName, true,
+                                                     null);
+                }
+            } else {
                 s = attr.getValue();
             }
 
             parse(s);
 
+            if (nonNegative && value < 0) {
+                throw new LiveAttributeException(element, localName, false, s);
+            }
+
             valid = true;
         }
 
         /**
+         * Returns the element this length is associated with.
          */
-        protected SVGOMElement getAssociatedElement(){
+        protected SVGOMElement getAssociatedElement() {
             return (SVGOMElement)element;
+        }
+    }
+
+    /**
+     * This class represents the SVGLength returned by getAnimVal().
+     */
+    protected class AnimSVGLength extends AbstractSVGLength {
+
+        /**
+         * Creates a new AnimSVGLength.
+         */
+        public AnimSVGLength(short direction) {
+            super(direction);
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link SVGLength#getUnitType()}.
+         */
+        public short getUnitType() {
+            if (hasAnimVal) {
+                return super.getUnitType();
+            }
+            return getBaseVal().getUnitType();
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link SVGLength#getValue()}.
+         */
+        public float getValue() {
+            if (hasAnimVal) {
+                return super.getValue();
+            }
+            return getBaseVal().getValue();
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link SVGLength#getValueInSpecifiedUnits()}.
+         */
+        public float getValueInSpecifiedUnits() {
+            if (hasAnimVal) {
+                return super.getValueInSpecifiedUnits();
+            }
+            return getBaseVal().getValueInSpecifiedUnits();
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link SVGLength#getValueAsString()}.
+         */
+        public String getValueAsString() {
+            if (hasAnimVal) {
+                return super.getValueAsString();
+            }
+            return getBaseVal().getValueAsString();
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link SVGLength#setValue(float)}.
+         */
+        public void setValue(float value) throws DOMException {
+            throw element.createDOMException
+                (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
+                 null);
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link
+         * SVGLength#setValueInSpecifiedUnits(float)}.
+         */
+        public void setValueInSpecifiedUnits(float value) throws DOMException {
+            throw element.createDOMException
+                (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
+                 null);
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link SVGLength#setValueAsString(String)}.
+         */
+        public void setValueAsString(String value) throws DOMException {
+            throw element.createDOMException
+                (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
+                 null);
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link
+         * SVGLength#newValueSpecifiedUnits(short,float)}.
+         */
+        public void newValueSpecifiedUnits(short unit, float value) {
+            throw element.createDOMException
+                (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
+                 null);
+        }
+
+        /**
+         * <b>DOM</b>: Implements {@link
+         * SVGLength#convertToSpecifiedUnits(short)}.
+         */
+        public void convertToSpecifiedUnits(short unit) {
+            throw element.createDOMException
+                (DOMException.NO_MODIFICATION_ALLOWED_ERR, "readonly.length",
+                 null);
+        }
+
+        /**
+         * Returns the element this length is associated with.
+         */
+        protected SVGOMElement getAssociatedElement() {
+            return (SVGOMElement) element;
+        }
+
+        /**
+         * Sets the animated value.
+         */
+        protected void setAnimatedValue(int type, float val) {
+            super.newValueSpecifiedUnits((short) type, val);
         }
     }
 }

Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGAnimatedValue.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGAnimatedValue.java?rev=415933&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGAnimatedValue.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGAnimatedValue.java Wed Jun 21 00:18:34 2006
@@ -0,0 +1,116 @@
+/*
+
+   Copyright 2006  The Apache Software Foundation 
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.batik.dom.svg;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * An abstract base class for the <code>SVGAnimated*</code> classes, that
+ * implements an {@link AnimatedAttributeListener} list.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public abstract class AbstractSVGAnimatedValue
+    implements AnimatedLiveAttributeValue {
+
+    /**
+     * The associated element.
+     */
+    protected AbstractElement element;
+
+    /**
+     * The namespace URI of the attribute.
+     */
+    protected String namespaceURI;
+
+    /**
+     * The local name of the attribute.
+     */
+    protected String localName;
+
+    /**
+     * Whether there is a current animated value.
+     */
+    protected boolean hasAnimVal;
+
+    /**
+     * Listener list.
+     */
+    protected LinkedList listeners = new LinkedList();
+
+    /**
+     * Creates a new AbstractSVGAnimatedValue.
+     */
+    public AbstractSVGAnimatedValue(AbstractElement elt, String ns, String ln) {
+        element = elt;
+        namespaceURI = ns;
+        localName = ln;
+    }
+
+    /**
+     * Returns the namespace URI of the attribute.
+     */
+    public String getNamespaceURI() {
+        return namespaceURI;
+    }
+
+    /**
+     * Returns the local name of the attribute.
+     */
+    public String getLocalName() {
+        return localName;
+    }
+
+    /**
+     * Returns whether this animated value has a specified value.
+     * @return true if the DOM attribute is specified or if the attribute has
+     *         an animated value, false otherwise
+     */
+    public boolean isSpecified() {
+        return hasAnimVal || element.hasAttributeNS(namespaceURI, localName);
+    }
+
+    /**
+     * Adds a listener for changes to the animated value.
+     */
+    public void addAnimatedAttributeListener(AnimatedAttributeListener aal) {
+        if (!listeners.contains(aal)) {
+            listeners.add(aal);
+        }
+    }
+
+    /**
+     * Removes a listener for changes to the animated value.
+     */
+    public void removeAnimatedAttributeListener(AnimatedAttributeListener aal) {
+        listeners.remove(aal);
+    }
+
+    /**
+     * Fires the listeners for the animated value.
+     */
+    protected void fireAnimatedAttributeListeners() {
+        Iterator i = listeners.iterator();
+        while (i.hasNext()) {
+            ((AnimatedAttributeListener) i.next()).animatedAttributeChanged
+                (element, this);
+        }
+    }
+}

Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGAnimatedValue.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGLength.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGLength.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGLength.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGLength.java Wed Jun 21 00:18:34 2006
@@ -97,7 +97,6 @@
      */
     protected abstract SVGOMElement getAssociatedElement();
 
-
     /**
      * Creates a new AbstractSVGLength.
      */
@@ -245,8 +244,8 @@
          * Returns the size of a px CSS unit in millimeters.
          */
         public float getPixelUnitToMillimeter() {
-            SVGContext ctx = getAssociatedElement().getSVGContext();
-            return ctx.getPixelUnitToMillimeter();
+            return getAssociatedElement().getSVGContext()
+                .getPixelUnitToMillimeter();
         }
         
         /**
@@ -276,16 +275,14 @@
          * Returns the viewport width used to compute units.
          */
         public float getViewportWidth() {
-            return getAssociatedElement().getSVGContext().
-                getViewportWidth();
+            return getAssociatedElement().getSVGContext().getViewportWidth();
         }
         
         /**
          * Returns the viewport height used to compute units.
          */
         public float getViewportHeight() {
-            return getAssociatedElement().getSVGContext().
-                getViewportHeight();
+            return getAssociatedElement().getSVGContext().getViewportHeight();
         }
     }   
 }

Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGLengthList.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGLengthList.java?rev=415933&r1=415932&r2=415933&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGLengthList.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/AbstractSVGLengthList.java Wed Jun 21 00:18:34 2006
@@ -67,7 +67,7 @@
                                                        Object[] args);
 
     /**
-     * return the element owning this SVGLengthList.
+     * Returns the element owning this SVGLengthList.
      */
     protected abstract Element getElement();