KickJava   Java API By Example, From Geeks To Geeks.

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


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.SVGAnimatedInteger;
23
24 /**
25  * This class implements the {@link SVGAnimatedInteger} interface.
26  *
27  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
28  * @version $Id: SVGOMAnimatedInteger.java,v 1.6 2004/08/18 07:13:14 vhardy Exp $
29  */

30 public class SVGOMAnimatedInteger
31     implements SVGAnimatedInteger,
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 int defaultValue;
53
54     /**
55      * Creates a new SVGOMAnimatedInteger.
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 SVGOMAnimatedInteger(AbstractElement elt,
62                                 String JavaDoc ns,
63                                 String JavaDoc ln,
64                                 int val) {
65         element = elt;
66         namespaceURI = ns;
67         localName = ln;
68         defaultValue = val;
69     }
70
71     /**
72      * <b>DOM</b>: Implements {@link SVGAnimatedInteger#getBaseVal()}.
73      */

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

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

93     public int 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