KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Copyright 2003 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.SVGAnimatedPathData;
23 import org.w3c.dom.svg.SVGException;
24 import org.w3c.dom.svg.SVGPathSegList;
25
26 /**
27  * This class is the implementation of
28  * the SVGAnimatedPathData interface.
29  *
30  * @author <a HREF="mailto:nicolas.socheleau@bitflash.com">Nicolas Socheleau</a>
31  * @version $Id: SVGOMAnimatedPathData.java,v 1.4 2004/08/18 07:13:14 vhardy Exp $
32  */

33 public class SVGOMAnimatedPathData
34     implements SVGAnimatedPathData,
35                LiveAttributeValue {
36
37     /**
38      * The associated element.
39      */

40     protected AbstractElement element;
41
42     /**
43      * The attribute's namespace URI.
44      */

45     protected String JavaDoc namespaceURI;
46
47     /**
48      * The attribute's local name.
49      */

50     protected String JavaDoc localName;
51
52     /**
53      * Whether the list is changing.
54      */

55     protected boolean changing;
56
57     /**
58      * SVGPathSegList mapping the static 'd' attribute.
59      */

60     protected AbstractSVGPathSegList pathSegs;
61
62     /**
63      * Default value for the 'd' attribute.
64      */

65     protected String JavaDoc defaultValue;
66
67     /**
68      */

69     public SVGOMAnimatedPathData(AbstractElement elt,
70                                  String JavaDoc ns,
71                                  String JavaDoc ln,
72                                  String JavaDoc defaultValue){
73
74         element = elt;
75         namespaceURI = ns;
76         localName = ln;
77         this.defaultValue = defaultValue;
78     }
79
80     /**
81      */

82     public SVGPathSegList getAnimatedNormalizedPathSegList(){
83         throw new RuntimeException JavaDoc("TODO : getAnimatedNormalizedPathSegList() !!");
84     }
85           
86     
87     /**
88      */

89     public SVGPathSegList getAnimatedPathSegList(){
90         throw new RuntimeException JavaDoc("TODO : getAnimatedPathSegList() !!");
91     }
92
93     /**
94      */

95     public SVGPathSegList getNormalizedPathSegList(){
96         throw new RuntimeException JavaDoc("TODO : getNormalizedPathSegList() !!");
97     }
98           
99
100     /**
101      * return the SVGPathSegList mapping
102      * the static 'd' attribute
103      * of the element
104      *
105      * @return a path seg list.
106      */

107     public SVGPathSegList getPathSegList(){
108         if ( pathSegs == null ){
109             pathSegs = new SVGOMPathSegList();
110         }
111          return pathSegs;
112     }
113
114     /**
115      * Called when an Attr node has been added.
116      */

117     public void attrAdded(Attr JavaDoc node, String JavaDoc newv) {
118         if (!changing && pathSegs != null) {
119             pathSegs.invalidate();
120         }
121     }
122
123     /**
124      * Called when an Attr node has been modified.
125      */

126     public void attrModified(Attr JavaDoc node, String JavaDoc oldv, String JavaDoc newv) {
127         if (!changing && pathSegs != null) {
128             pathSegs.invalidate();
129         }
130     }
131
132     /**
133      * Called when an Attr node has been removed.
134      */

135     public void attrRemoved(Attr JavaDoc node, String JavaDoc oldv) {
136         if (!changing && pathSegs != null) {
137             pathSegs.invalidate();
138         }
139     }
140     
141     /**
142      * SVGPointList implementation for the
143      * static 'points' attribute of the element.
144      */

145     public class SVGOMPathSegList extends AbstractSVGPathSegList {
146
147         /**
148          * Create a DOMException.
149          */

150         protected DOMException JavaDoc createDOMException(short type,
151                                                   String JavaDoc key,
152                                                   Object JavaDoc[] args){
153             return element.createDOMException(type,key,args);
154         }
155
156         /**
157          * Create a SVGException.
158          */

159         protected SVGException createSVGException(short type,
160                                                   String JavaDoc key,
161                                                   Object JavaDoc[] args){
162
163             return ((SVGOMElement)element).createSVGException(type,key,args);
164         }
165
166         /**
167          * Retrieve the value of the attribute 'points'.
168          */

169         protected String JavaDoc getValueAsString(){
170             Attr JavaDoc attr = element.getAttributeNodeNS(namespaceURI, localName);
171             if (attr == null) {
172                 return defaultValue;
173             }
174             return attr.getValue();
175         }
176
177         /**
178          * Set the value of the attribute 'points'
179          */

180         protected void setAttributeValue(String JavaDoc value){
181             try{
182                 changing = true;
183                 element.setAttributeNS(namespaceURI, localName, value);
184             }
185             finally{
186                 changing = false;
187             }
188         }
189     }
190 }
191
Popular Tags