KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > svg > SVGOMAnimatedNumber


1 /*
2
3    Copyright 2000-2002 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.dom.svg;
19
20 import org.w3c.dom.Attr JavaDoc;
21 import org.w3c.dom.DOMException JavaDoc;
22 import org.w3c.dom.svg.SVGAnimatedNumber;
23
24 /**
25  * This class implements the {@link SVGAnimatedNumber} interface.
26  *
27  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
28  * @version $Id: SVGOMAnimatedNumber.java,v 1.8 2004/08/18 07:13:14 vhardy Exp $
29  */

30 public class SVGOMAnimatedNumber
31     implements SVGAnimatedNumber,
32                LiveAttributeValue {
33
34     /**
35      * The associated element.
36      */

37     protected AbstractElement element;
38
39     /**
40      * The attribute's namespace URI.
41      */

42     protected String JavaDoc namespaceURI;
43
44     /**
45      * The attribute's local name.
46      */

47     protected String JavaDoc localName;
48
49     /**
50      * The default value.
51      */

52     protected float defaultValue;
53
54     /**
55      * Creates a new SVGOMAnimatedNumber.
56      * @param elt The associated element.
57      * @param ns The attribute's namespace URI.
58      * @param ln The attribute's local name.
59      * @param val The default value, if the attribute is not specified.
60      */

61     public SVGOMAnimatedNumber(AbstractElement elt,
62                                String JavaDoc ns,
63                                String JavaDoc ln,
64                                float val) {
65         element = elt;
66         namespaceURI = ns;
67         localName = ln;
68         defaultValue = val;
69     }
70
71     /**
72      * <b>DOM</b>: Implements {@link SVGAnimatedNumber#getBaseVal()}.
73      */

74     public float getBaseVal() {
75         Attr JavaDoc attr = element.getAttributeNodeNS(namespaceURI, localName);
76         if (attr == null) {
77             return defaultValue;
78         }
79         return Float.parseFloat(attr.getValue());
80     }
81
82     /**
83      * <b>DOM</b>: Implements {@link SVGAnimatedNumber#setBaseVal(float)}.
84      */

85     public void setBaseVal(float baseVal) throws DOMException JavaDoc {
86         element.setAttributeNS(namespaceURI, localName,
87                                String.valueOf(baseVal));
88     }
89
90     /**
91      * <b>DOM</b>: Implements {@link SVGAnimatedNumber#getAnimVal()}.
92      */

93     public float getAnimVal() {
94         throw new RuntimeException JavaDoc("!!! TODO: getAnimVal()");
95     }
96
97     /**
98      * Called when an Attr node has been added.
99      */

100     public void attrAdded(Attr JavaDoc node, String JavaDoc newv) {
101     }
102
103     /**
104      * Called when an Attr node has been modified.
105      */

106     public void attrModified(Attr JavaDoc node, String JavaDoc oldv, String JavaDoc newv) {
107     }
108
109     /**
110      * Called when an Attr node has been removed.
111      */

112     public void attrRemoved(Attr JavaDoc node, String JavaDoc oldv) {
113     }
114 }
115
Popular Tags