hillion     02/05/07 07:28:13

  Modified:    sources/org/apache/batik/dom/svg
                        AbstractSVGAnimatedLength.java
  Log:
  Fixed SVGLength.setXXX() methods.
  
  Revision  Changes    Path
  1.2       +31 -4     
xml-batik/sources/org/apache/batik/dom/svg/AbstractSVGAnimatedLength.java
  
  Index: AbstractSVGAnimatedLength.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/dom/svg/AbstractSVGAnimatedLength.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractSVGAnimatedLength.java    15 Apr 2002 10:16:12 -0000      1.1
  +++ AbstractSVGAnimatedLength.java    7 May 2002 14:28:13 -0000       1.2
  @@ -25,7 +25,7 @@
    * SVGAnimatedLength} interface.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: AbstractSVGAnimatedLength.java,v 1.1 2002/04/15 10:16:12 hillion 
Exp $
  + * @version $Id: AbstractSVGAnimatedLength.java,v 1.2 2002/05/07 14:28:13 hillion 
Exp $
    */
   public abstract class AbstractSVGAnimatedLength
       implements SVGAnimatedLength,
  @@ -50,6 +50,13 @@
           UnitProcessor.OTHER_LENGTH;
   
       /**
  +     * The unit string representations.
  +     */
  +    protected final static String[] UNITS = {
  +        "", "", "%", "em", "ex", "px", "cm", "mm", "in", "pt", "pc"
  +    };
  +
  +    /**
        * The associated element.
        */
       protected AbstractElement element;
  @@ -75,6 +82,11 @@
       protected BaseSVGLength baseVal;
   
       /**
  +     * Whether the value is changing.
  +     */
  +    protected boolean changing;
  +
  +    /**
        * Creates a new SVGAnimatedLength.
        * @param elt The associated element.
        * @param ns The attribute's namespace URI.
  @@ -118,7 +130,7 @@
        * Called when an Attr node has been added.
        */
       public void attrAdded(Attr node, String newv) {
  -        if (baseVal != null) {
  +        if (!changing && baseVal != null) {
               baseVal.invalidate();
           }
       }
  @@ -127,7 +139,7 @@
        * Called when an Attr node has been modified.
        */
       public void attrModified(Attr node, String oldv, String newv) {
  -        if (baseVal != null) {
  +        if (!changing && baseVal != null) {
               baseVal.invalidate();
           }
       }
  @@ -136,7 +148,7 @@
        * Called when an Attr node has been removed.
        */
       public void attrRemoved(Attr node, String oldv) {
  -        if (baseVal != null) {
  +        if (!changing && baseVal != null) {
               baseVal.invalidate();
           }
       }
  @@ -204,6 +216,7 @@
               revalidate();
               this.value = UnitProcessor.userSpaceToSVG(value, unitType,
                                                         direction, context);
  +            resetAttribute();
           }
   
           /**
  @@ -221,6 +234,7 @@
           public void setValueInSpecifiedUnits(float value) throws DOMException {
               revalidate();
               this.value = value;
  +            resetAttribute();
           }
   
           /**
  @@ -248,6 +262,7 @@
           public void newValueSpecifiedUnits(short unit, float value) {
               unitType = unit;
               this.value = value;
  +            resetAttribute();
           }
   
           /**
  @@ -258,6 +273,18 @@
               float v = getValue();
               unitType = unit;
               setValue(v);
  +        }
  +
  +        /**
  +         * Resets the value of the associated attribute.
  +         */
  +        protected void resetAttribute() {
  +            try {
  +                changing = true;
  +                setValueAsString(value + UNITS[unitType]);
  +            } finally {
  +                changing = false;
  +            }
           }
   
           /**
  
  
  

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

Reply via email to