xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tkorm...@apache.org
Subject cvs commit: xml-batik/sources/org/apache/batik/bridge AbstractGraphicsNodeBridge.java SVGCircleElementBridge.java SVGEllipseElementBridge.java SVGGElementBridge.java SVGImageElementBridge.java SVGLineElementBridge.java SVGPathElementBridge.java SVGPolygonElementBridge.java SVGPolylineElementBridge.java SVGRectElementBridge.java SVGTextElementBridge.java
Date Wed, 13 Feb 2002 09:51:02 GMT
tkormann    02/02/13 01:51:01

  Modified:    samples/tests/spec/scripting transform.svg
               sources/org/apache/batik/bridge
                        AbstractGraphicsNodeBridge.java
                        SVGCircleElementBridge.java
                        SVGEllipseElementBridge.java SVGGElementBridge.java
                        SVGImageElementBridge.java
                        SVGLineElementBridge.java SVGPathElementBridge.java
                        SVGPolygonElementBridge.java
                        SVGPolylineElementBridge.java
                        SVGRectElementBridge.java SVGTextElementBridge.java
  Added:       samples/tests/spec/scripting transform2.svg
  Log:
  - dynamic 'transform' attribute now works on basic shapes, image, text and g
  - new test transform2.svg (translate and rotate are done in 'onload')
  
  Revision  Changes    Path
  1.2       +24 -5     xml-batik/samples/tests/spec/scripting/transform.svg
  
  Index: transform.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/samples/tests/spec/scripting/transform.svg,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- transform.svg	12 Feb 2002 16:34:06 -0000	1.1
  +++ transform.svg	13 Feb 2002 09:51:01 -0000	1.2
  @@ -14,7 +14,7 @@
   <!-- Modification of a transform attribute                                  -->
   <!--                                                                        -->
   <!-- @author tkormann@ilog.fr                                               -->
  -<!-- @version $Id: transform.svg,v 1.1 2002/02/12 16:34:06 tkormann Exp $ -->
  +<!-- @version $Id: transform.svg,v 1.2 2002/02/13 09:51:01 tkormann Exp $ -->
   <!-- ====================================================================== -->
   
   <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>  
  @@ -56,9 +56,20 @@
         <path d="M50 0 L100 100 L0 100Z" style="fill:gold"
           onload="transform(evt, 'translate(320 250)')"/>
   
  -      <line x1="0" y1="0" x2="100" y2="50" style="stroke:orange; stroke-width:8; fill:none"
  -        onload="transform(evt, 'translate(170 400)')"/>
  -
  +      <line x1="0" y1="0" x2="100" y2="50" 
  +        style="stroke:crimson; stroke-width:8; fill:none"
  +        onload="transform(evt, 'translate(20 400)')"/>
  +
  +      <text x="0" y="0" 
  +         style="fill:orange; text-anchor:middle;font-size:48" 
  +         onload="transform(evt, 'translate(220 420)')">Batik</text>
  +
  +      <image x="0" y="0" width="50" height="50" 
  +         xlink:href="../../resources/images/png2.png"
  +         onload="transform(evt, 'translate(320 400)')" />
  +      <image x="0" y="0" width="50" height="50" 
  +         xlink:href="../../resources/images/svg.svg"
  +         onload="transform(evt, 'translate(370 400)')" />
   </g>
   
   <g style="fill:none; stroke:black">
  @@ -75,7 +86,15 @@
   
         <path d="M50 0 L100 100 L0 100Z" transform="translate(320 250)"/>
   
  -      <line x1="0" y1="0" x2="100" y2="50" transform="translate(170 400)"/>
  +      <line x1="0" y1="0" x2="100" y2="50" transform="translate(20 400)"/>
  +
  +      <text x="0" y="0" 
  +             style="stroke:black; fill:none; text-anchor:middle;font-size:48" 
  +             transform="translate(220 420)">Batik</text>
  +      <rect x="0" y="0" width="50" height="50" transform="translate(320 400)" 
  +            style="stroke:black; fill:none;"/>
  +      <rect x="0" y="0" width="50" height="50" transform="translate(370 400)"
  +            style="stroke:black; fill:none;"/>
   
   </g>
   
  
  
  
  1.1                  xml-batik/samples/tests/spec/scripting/transform2.svg
  
  Index: transform2.svg
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
  "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
  
  <!-- ====================================================================== -->
  <!-- Copyright (C) The Apache Software Foundation. All rights reserved.     -->
  <!--                                                                        -->
  <!-- This software is published under the terms of the Apache Software      -->
  <!-- License version 1.1, a copy of which has been included with this       -->
  <!-- distribution in the LICENSE file.                                      -->
  <!-- ====================================================================== -->
  
  <!-- ====================================================================== -->
  <!-- Modification of a transform attribute                                  -->
  <!--                                                                        -->
  <!-- @author tkormann@ilog.fr                                               -->
  <!-- @version $Id: transform2.svg,v 1.1 2002/02/13 09:51:01 tkormann Exp $ -->
  <!-- ====================================================================== -->
  
  <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>  
  
  <svg id="body" width="450" height="500" viewBox="0 0 450 500">
      <title>transform attribute in 'onload' (2)</title>
  
      <text x="50%" y="45" class="title">transform attributes in 'onload' (2)</text>
  
      <script type="text/ecmascript">
  
      function transform(evt, transform) {
          var elt = evt.target;
          elt.setAttribute("transform", transform)
      }
  
      </script>
  
      <g id="test-content" >
  <g onload="transform(evt, 'translate(175, 150)')">
        <rect x="0" y="0" width="50" height="50" style="fill:crimson" />
        <rect x="50" y="0" width="50" height="50" style="fill:gold" />
        <rect x="0" y="50" width="50" height="50" style="fill:orange" />
        <rect x="50" y="50" width="50" height="50" style="fill:#eee" />
  </g>
  
  <g onload="transform(evt, 'translate(175, 320) rotate(45 50 50)')">
        <rect x="0" y="0" width="50" height="50" style="fill:crimson" />
        <rect x="50" y="0" width="50" height="50" style="fill:gold" />
        <rect x="0" y="50" width="50" height="50" style="fill:orange" />
        <rect x="50" y="50" width="50" height="50" style="fill:#eee" />
  </g>
  
  <g style="fill:none; stroke:black">
  
  <g transform="translate(175, 150)" style="stroke:black; fill:none">
        <rect x="0" y="0" width="50" height="50"  />
        <rect x="50" y="0" width="50" height="50" />
        <rect x="0" y="50" width="50" height="50" />
        <rect x="50" y="50" width="50" height="50" />
  </g>
  
  <g transform="translate(175, 320) rotate(45 50 50)">
        <rect x="0" y="0" width="50" height="50"  />
        <rect x="50" y="0" width="50" height="50"  />
        <rect x="0" y="50" width="50" height="50"  />
        <rect x="50" y="50" width="50" height="50"  />
  </g>
  
  </g>
  
  </g>
  
  </svg>
  
  
  
  1.10      +3 -3      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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AbstractGraphicsNodeBridge.java	12 Feb 2002 15:14:37 -0000	1.9
  +++ AbstractGraphicsNodeBridge.java	13 Feb 2002 09:51:01 -0000	1.10
  @@ -39,7 +39,7 @@
    * </ul>
    *
    * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
  - * @version $Id: AbstractGraphicsNodeBridge.java,v 1.9 2002/02/12 15:14:37 tkormann Exp
$
  + * @version $Id: AbstractGraphicsNodeBridge.java,v 1.10 2002/02/13 09:51:01 tkormann Exp
$
    */
   public abstract class AbstractGraphicsNodeBridge extends AbstractSVGBridge
       implements GraphicsNodeBridge, ErrorConstants {
  @@ -140,7 +140,8 @@
        * @param evt the DOM mutation event
        */
       protected void handleDOMAttrModifiedEvent(MutationEvent evt) {
  -        if (evt.getAttrName().equals(SVG_TRANSFORM_ATTRIBUTE)) {
  +        String attrName = evt.getAttrName();
  +        if (attrName.equals(SVG_TRANSFORM_ATTRIBUTE)) {
               BridgeUpdateEvent be = new BridgeUpdateEvent();
               fireBridgeUpdateStarting(be);
               
  @@ -151,7 +152,6 @@
                       (e, SVG_TRANSFORM_ATTRIBUTE, s);
               }
               node.setTransform(at);
  -
               fireBridgeUpdateCompleted(be);
           }
       }
  
  
  
  1.6       +5 -4      xml-batik/sources/org/apache/batik/bridge/SVGCircleElementBridge.java
  
  Index: SVGCircleElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGCircleElementBridge.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SVGCircleElementBridge.java	12 Feb 2002 15:14:37 -0000	1.5
  +++ SVGCircleElementBridge.java	13 Feb 2002 09:51:01 -0000	1.6
  @@ -22,7 +22,7 @@
    * Bridge class for the &lt;circle> element.
    *
    * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
  - * @version $Id: SVGCircleElementBridge.java,v 1.5 2002/02/12 15:14:37 tkormann Exp $
  + * @version $Id: SVGCircleElementBridge.java,v 1.6 2002/02/13 09:51:01 tkormann Exp $
    */
   public class SVGCircleElementBridge extends SVGShapeElementBridge {
   
  @@ -103,9 +103,10 @@
        * @param evt the DOM mutation event
        */
       protected void handleDOMAttrModifiedEvent(MutationEvent evt) {
  -        if (evt.getAttrName().equals(SVG_CX_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_CY_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_R_ATTRIBUTE)) {
  +        String attrName = evt.getAttrName();
  +        if (attrName.equals(SVG_CX_ATTRIBUTE) ||
  +            attrName.equals(SVG_CY_ATTRIBUTE) ||
  +            attrName.equals(SVG_R_ATTRIBUTE)) {
   
               BridgeUpdateEvent be = new BridgeUpdateEvent();
               fireBridgeUpdateStarting(be);
  
  
  
  1.6       +6 -5      xml-batik/sources/org/apache/batik/bridge/SVGEllipseElementBridge.java
  
  Index: SVGEllipseElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGEllipseElementBridge.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SVGEllipseElementBridge.java	12 Feb 2002 15:14:37 -0000	1.5
  +++ SVGEllipseElementBridge.java	13 Feb 2002 09:51:01 -0000	1.6
  @@ -22,7 +22,7 @@
    * Bridge class for the &lt;ellipse> element.
    *
    * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
  - * @version $Id: SVGEllipseElementBridge.java,v 1.5 2002/02/12 15:14:37 tkormann Exp $
  + * @version $Id: SVGEllipseElementBridge.java,v 1.6 2002/02/13 09:51:01 tkormann Exp $
    */
   public class SVGEllipseElementBridge extends SVGShapeElementBridge {
   
  @@ -116,10 +116,11 @@
        * @param evt the DOM mutation event
        */
       protected void handleDOMAttrModifiedEvent(MutationEvent evt) {
  -        if (evt.getAttrName().equals(SVG_CX_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_CY_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_RX_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_RY_ATTRIBUTE)) {
  +        String attrName = evt.getAttrName();
  +        if (attrName.equals(SVG_CX_ATTRIBUTE) ||
  +            attrName.equals(SVG_CY_ATTRIBUTE) ||
  +            attrName.equals(SVG_RX_ATTRIBUTE) ||
  +            attrName.equals(SVG_RY_ATTRIBUTE)) {
   
               BridgeUpdateEvent be = new BridgeUpdateEvent();
               fireBridgeUpdateStarting(be);
  
  
  
  1.12      +8 -1      xml-batik/sources/org/apache/batik/bridge/SVGGElementBridge.java
  
  Index: SVGGElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGGElementBridge.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SVGGElementBridge.java	13 Nov 2001 15:20:58 -0000	1.11
  +++ SVGGElementBridge.java	13 Feb 2002 09:51:01 -0000	1.12
  @@ -21,7 +21,7 @@
    * Bridge class for the &lt;g> element.
    *
    * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
  - * @version $Id: SVGGElementBridge.java,v 1.11 2001/11/13 15:20:58 tkormann Exp $
  + * @version $Id: SVGGElementBridge.java,v 1.12 2002/02/13 09:51:01 tkormann Exp $
    */
   public class SVGGElementBridge extends AbstractGraphicsNodeBridge {
   
  @@ -35,6 +35,13 @@
        */
       public String getLocalName() {
           return SVG_G_TAG;
  +    }
  +
  +    /**
  +     * Returns a new instance of this bridge.
  +     */
  +    public Bridge getInstance() {
  +        return new SVGGElementBridge();
       }
   
       /**
  
  
  
  1.35      +43 -1     xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java
  
  Index: SVGImageElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- SVGImageElementBridge.java	23 Jan 2002 14:14:07 -0000	1.34
  +++ SVGImageElementBridge.java	13 Feb 2002 09:51:01 -0000	1.35
  @@ -46,12 +46,13 @@
   import org.w3c.dom.events.EventListener;
   import org.w3c.dom.events.EventTarget;
   import org.w3c.dom.events.MouseEvent;
  +import org.w3c.dom.events.MutationEvent;
   
   /**
    * Bridge class for the &lt;image> element.
    *
    * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
  - * @version $Id: SVGImageElementBridge.java,v 1.34 2002/01/23 14:14:07 deweese Exp $
  + * @version $Id: SVGImageElementBridge.java,v 1.35 2002/02/13 09:51:01 tkormann Exp $
    */
   public class SVGImageElementBridge extends AbstractGraphicsNodeBridge {
   
  @@ -68,6 +69,13 @@
       }
   
       /**
  +     * Returns a new instance of this bridge.
  +     */
  +    public Bridge getInstance() {
  +        return new SVGImageElementBridge();
  +    }
  +
  +    /**
        * Creates a graphics node using the specified BridgeContext and for the
        * specified element.
        *
  @@ -168,6 +176,12 @@
   
           // bind the specified element and its associated graphics node if needed
           if (ctx.isDynamic()) {
  +            ((EventTarget)e).addEventListener("DOMAttrModified", 
  +                                              new DOMAttrModifiedEventListener(),
  +                                              false);
  +            this.e = e;
  +            this.node = node;
  +            this.ctx = ctx;
               // HACK due to the way images are represented in GVT
               ImageNode imgNode = (ImageNode)node;
               if (imgNode.getImage() instanceof RasterImageNode) {
  @@ -194,6 +208,34 @@
       public boolean isComposite() {
           return false;
       }
  +
  +    // dynamic support
  +
  +    /**
  +     * Handles DOMAttrModified events.
  +     *
  +     * @param evt the DOM mutation event
  +     */
  +    protected 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)) {
  +
  +            BridgeUpdateEvent be = new BridgeUpdateEvent();
  +            fireBridgeUpdateStarting(be);
  +            
  +            // <!> FIXME: Not yet implemented
  +            System.err.println("Not yet implemented");
  +
  +            fireBridgeUpdateCompleted(be);
  +        } else {
  +            super.handleDOMAttrModifiedEvent(evt);
  +        }
  +    }
  +
  +    // convenient methods
   
       /**
        * Returns a GraphicsNode that represents an raster image in JPEG or PNG
  
  
  
  1.6       +6 -5      xml-batik/sources/org/apache/batik/bridge/SVGLineElementBridge.java
  
  Index: SVGLineElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGLineElementBridge.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SVGLineElementBridge.java	12 Feb 2002 15:14:37 -0000	1.5
  +++ SVGLineElementBridge.java	13 Feb 2002 09:51:01 -0000	1.6
  @@ -21,7 +21,7 @@
    * Bridge class for the &lt;line> element.
    *
    * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
  - * @version $Id: SVGLineElementBridge.java,v 1.5 2002/02/12 15:14:37 tkormann Exp $
  + * @version $Id: SVGLineElementBridge.java,v 1.6 2002/02/13 09:51:01 tkormann Exp $
    */
   public class SVGLineElementBridge extends SVGDecoratedShapeElementBridge {
   
  @@ -101,10 +101,11 @@
        * @param evt the DOM mutation event
        */
       protected void handleDOMAttrModifiedEvent(MutationEvent evt) {
  -        if (evt.getAttrName().equals(SVG_X1_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_Y1_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_X2_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_Y2_ATTRIBUTE)) {
  +        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)) {
   
               BridgeUpdateEvent be = new BridgeUpdateEvent();
               fireBridgeUpdateStarting(be);
  
  
  
  1.9       +3 -2      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SVGPathElementBridge.java	12 Feb 2002 15:14:37 -0000	1.8
  +++ SVGPathElementBridge.java	13 Feb 2002 09:51:01 -0000	1.9
  @@ -24,7 +24,7 @@
    * Bridge class for the &lt;path> element.
    *
    * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
  - * @version $Id: SVGPathElementBridge.java,v 1.8 2002/02/12 15:14:37 tkormann Exp $
  + * @version $Id: SVGPathElementBridge.java,v 1.9 2002/02/13 09:51:01 tkormann Exp $
    */
   public class SVGPathElementBridge extends SVGDecoratedShapeElementBridge {
   
  @@ -90,7 +90,8 @@
        * @param evt the DOM mutation event
        */
       protected void handleDOMAttrModifiedEvent(MutationEvent evt) {
  -        if (evt.getAttrName().equals(SVG_D_ATTRIBUTE)) {
  +        String attrName = evt.getAttrName();
  +        if (attrName.equals(SVG_D_ATTRIBUTE)) {
   
               BridgeUpdateEvent be = new BridgeUpdateEvent();
               fireBridgeUpdateStarting(be);
  
  
  
  1.10      +3 -2      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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SVGPolygonElementBridge.java	12 Feb 2002 15:14:37 -0000	1.9
  +++ SVGPolygonElementBridge.java	13 Feb 2002 09:51:01 -0000	1.10
  @@ -24,7 +24,7 @@
    * Bridge class for the &lt;polygon> element.
    *
    * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
  - * @version $Id: SVGPolygonElementBridge.java,v 1.9 2002/02/12 15:14:37 tkormann Exp $
  + * @version $Id: SVGPolygonElementBridge.java,v 1.10 2002/02/13 09:51:01 tkormann Exp $
    */
   public class SVGPolygonElementBridge extends SVGDecoratedShapeElementBridge {
   
  @@ -89,7 +89,8 @@
        * @param evt the DOM mutation event
        */
       protected void handleDOMAttrModifiedEvent(MutationEvent evt) {
  -        if (evt.getAttrName().equals(SVG_POINTS_ATTRIBUTE)) {
  +        String attrName = evt.getAttrName();
  +        if (attrName.equals(SVG_POINTS_ATTRIBUTE)) {
   
               BridgeUpdateEvent be = new BridgeUpdateEvent();
               fireBridgeUpdateStarting(be);
  
  
  
  1.9       +3 -2      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SVGPolylineElementBridge.java	12 Feb 2002 15:14:37 -0000	1.8
  +++ SVGPolylineElementBridge.java	13 Feb 2002 09:51:01 -0000	1.9
  @@ -24,7 +24,7 @@
    * Bridge class for the &lt;polyline> element.
    *
    * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
  - * @version $Id: SVGPolylineElementBridge.java,v 1.8 2002/02/12 15:14:37 tkormann Exp $
  + * @version $Id: SVGPolylineElementBridge.java,v 1.9 2002/02/13 09:51:01 tkormann Exp $
    */
   public class SVGPolylineElementBridge extends SVGDecoratedShapeElementBridge {
   
  @@ -89,7 +89,8 @@
        * @param evt the DOM mutation event
        */
       protected void handleDOMAttrModifiedEvent(MutationEvent evt) {
  -        if (evt.getAttrName().equals(SVG_POINTS_ATTRIBUTE)) {
  +        String attrName = evt.getAttrName();
  +        if (attrName.equals(SVG_POINTS_ATTRIBUTE)) {
   
               BridgeUpdateEvent be = new BridgeUpdateEvent();
               fireBridgeUpdateStarting(be);
  
  
  
  1.8       +8 -7      xml-batik/sources/org/apache/batik/bridge/SVGRectElementBridge.java
  
  Index: SVGRectElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGRectElementBridge.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SVGRectElementBridge.java	12 Feb 2002 15:14:37 -0000	1.7
  +++ SVGRectElementBridge.java	13 Feb 2002 09:51:01 -0000	1.8
  @@ -24,7 +24,7 @@
    * Bridge class for the &lt;rect> element.
    *
    * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
  - * @version $Id: SVGRectElementBridge.java,v 1.7 2002/02/12 15:14:37 tkormann Exp $
  + * @version $Id: SVGRectElementBridge.java,v 1.8 2002/02/13 09:51:01 tkormann Exp $
    */
   public class SVGRectElementBridge extends SVGShapeElementBridge {
   
  @@ -160,12 +160,13 @@
        * @param evt the DOM mutation event
        */
       protected void handleDOMAttrModifiedEvent(MutationEvent evt) {
  -        if (evt.getAttrName().equals(SVG_X_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_Y_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_WIDTH_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_HEIGHT_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_RX_ATTRIBUTE) ||
  -            evt.getAttrName().equals(SVG_RY_ATTRIBUTE)) {
  +        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)) {
   
               BridgeUpdateEvent be = new BridgeUpdateEvent();
               fireBridgeUpdateStarting(be);
  
  
  
  1.46      +96 -10    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.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- SVGTextElementBridge.java	11 Feb 2002 16:00:08 -0000	1.45
  +++ SVGTextElementBridge.java	13 Feb 2002 09:51:01 -0000	1.46
  @@ -51,22 +51,40 @@
   import org.w3c.dom.css.CSSStyleDeclaration;
   import org.w3c.dom.css.CSSValue;
   import org.w3c.dom.css.CSSValueList;
  +import org.w3c.dom.events.Event;
  +import org.w3c.dom.events.EventListener;
  +import org.w3c.dom.events.EventTarget;
  +import org.w3c.dom.events.MutationEvent;
   
   /**
    * Bridge class for the &lt;text> element.
    *
    * @author <a href="bill.haneman@ireland.sun.com>Bill Haneman</a>
  - * @version $Id: SVGTextElementBridge.java,v 1.45 2002/02/11 16:00:08 tkormann Exp $
  + * @version $Id: SVGTextElementBridge.java,v 1.46 2002/02/13 09:51:01 tkormann Exp $
    */
   public class SVGTextElementBridge extends AbstractSVGBridge
       implements GraphicsNodeBridge, ErrorConstants {
   
       /**
  +     * The element that has been handled by this bridge.
  +     */
  +    protected Element e;
  +
  +    /**
  +     * The graphics node constructed by this bridge.
  +     */
  +    protected GraphicsNode node;
  +
  +    /**
  +     * The bridge context to use for dynamic updates.
  +     */
  +    protected BridgeContext ctx;
  +
  +    /**
        * Constructs a new bridge for the &lt;text> element.
        */
       public SVGTextElementBridge() {}
   
  -
       /**
        * Returns 'text'.
        */
  @@ -74,8 +92,11 @@
           return SVG_TEXT_TAG;
       }
   
  -    public Bridge getInstance(){
  -        return this;
  +    /**
  +     * Returns a new instance of this bridge.
  +     */
  +    public Bridge getInstance() {
  +        return new SVGTextElementBridge();
       }
   
       /**
  @@ -123,10 +144,23 @@
               node.setRenderingHints(hints);
           }
   
  +        node.setLocation(getLocation(ctx, e));
  +
  +        return node;
  +    }
  +
  +    /**
  +     * Returns the text node location according to the 'x' and 'y'
  +     * attributes of the specified text element.
  +     *
  +     * @param ctx the bridge context to use
  +     * @param e the text element
  +     */
  +    protected Point2D getLocation(BridgeContext ctx, Element e) {
           UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);
   
           // 'x' attribute - default is 0
  -        s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
  +        String s = e.getAttributeNS(null, SVG_X_ATTRIBUTE);
           float x = 0;
           if (s.length() != 0) {
               StringTokenizer st = new StringTokenizer(s);
  @@ -145,10 +179,7 @@
               y = UnitProcessor.svgVerticalCoordinateToUserSpace
                   (startY, SVG_Y_ATTRIBUTE, uctx);
           }
  -
  -        node.setLocation(new Point2D.Float(x, y));
  -
  -        return node;
  +        return new Point2D.Float(x, y);
       }
   
       /**
  @@ -170,7 +201,8 @@
           // now add the painting attributes, cannot do it before this because
           // some of the Paint objects need to know the bounds of the text
           // and this isn't know until the text node aci is set
  -        TextDecoration textDecoration = getTextDecoration(e, (TextNode)node, new TextDecoration(),
ctx);
  +        TextDecoration textDecoration = 
  +            getTextDecoration(e, (TextNode)node, new TextDecoration(), ctx);
           addPaintAttributes(as, e, (TextNode)node, textDecoration, ctx);
           ((TextNode)node).setAttributedCharacterIterator(as.getIterator());
   
  @@ -185,7 +217,14 @@
   
           // bind the specified element and its associated graphics node if needed
           if (ctx.isDynamic()) {
  +            ((EventTarget)e).addEventListener("DOMAttrModified", 
  +                                              new DOMAttrModifiedEventListener(),
  +                                              false);
  +            this.e = e;
  +            this.node = node;
  +            this.ctx = ctx;
               ctx.bind(e, node);
  +            BridgeEventSupport.addDOMListener(ctx, e);
           }
   
           // Handle children elements such as <title>
  @@ -197,6 +236,53 @@
        */
       public boolean isComposite() {
           return false;
  +    }
  +
  +    // dynamic support
  +
  +    /**
  +     * Handles DOMAttrModified events.
  +     *
  +     * @param evt the DOM mutation event
  +     */
  +    protected void handleDOMAttrModifiedEvent(MutationEvent evt) {
  +        String attrName = evt.getAttrName();
  +        if (attrName.equals(SVG_TRANSFORM_ATTRIBUTE)) {
  +            BridgeUpdateEvent be = new BridgeUpdateEvent();
  +            fireBridgeUpdateStarting(be);
  +            
  +            String s = evt.getNewValue();
  +            AffineTransform at = GraphicsNode.IDENTITY;
  +            if (s.length() != 0) {
  +                at = SVGUtilities.convertTransform
  +                    (e, SVG_TRANSFORM_ATTRIBUTE, s);
  +            }
  +            node.setTransform(at);
  +
  +            fireBridgeUpdateCompleted(be);
  +
  +        }
  +    }
  +
  +
  +    /**
  +     * The listener class for 'DOMAttrModified' event.
  +     */
  +    protected class DOMAttrModifiedEventListener implements EventListener {
  +
  +        /**
  +         * Handles 'DOMAttrModfied' events and deleguates to the
  +         * 'handleDOMAttrModifiedEvent' method any changes to the
  +         * GraphicsNode if any.
  +         *
  +         * @param evt the DOM event
  +         */
  +        public void handleEvent(Event evt) {
  +            if (evt.getTarget() != e) {
  +                throw new Error("handleEvent bad target");
  +            }
  +            handleDOMAttrModifiedEvent((MutationEvent)evt);
  +        }
       }
   
       // -----------------------------------------------------------------------
  
  
  

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


Mime
View raw message