KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Copyright 2000-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.apache.batik.dom.AbstractDocument;
21 import org.apache.batik.dom.util.XMLSupport;
22 import org.w3c.dom.DOMException JavaDoc;
23 import org.w3c.dom.svg.SVGAnimatedBoolean;
24 import org.w3c.dom.svg.SVGAnimatedEnumeration;
25 import org.w3c.dom.svg.SVGAnimatedLength;
26 import org.w3c.dom.svg.SVGLength;
27 import org.w3c.dom.svg.SVGPoint;
28 import org.w3c.dom.svg.SVGRect;
29 import org.w3c.dom.svg.SVGStringList;
30
31 /**
32  * This class provides a common superclass for all graphics elements.
33  *
34  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
35  * @version $Id: SVGOMTextContentElement.java,v 1.13 2004/12/15 10:50:29 deweese Exp $
36  */

37 public abstract class SVGOMTextContentElement
38     extends SVGStylableElement {
39
40     /**
41      * The 'lengthAdjust' attribute values.
42      */

43     protected final static String JavaDoc[] LENGTH_ADJUST_VALUES = {
44         "",
45         SVG_SPACING_ATTRIBUTE,
46         SVG_SPACING_AND_GLYPHS_VALUE
47     };
48
49     /**
50      * Creates a new SVGOMTextContentElement.
51      */

52     protected SVGOMTextContentElement() {
53     }
54
55     /**
56      * Creates a new SVGOMTextContentElement object.
57      * @param prefix The namespace prefix.
58      * @param owner The owner document.
59      */

60     protected SVGOMTextContentElement(String JavaDoc prefix, AbstractDocument owner) {
61         super(prefix, owner);
62
63     }
64
65     /**
66      * <b>DOM</b>: Implements {@link
67      * org.w3c.dom.svg.SVGTextContentElement#getTextLength()}.
68      */

69     public SVGAnimatedLength getTextLength() {
70         SVGAnimatedLength result =
71             (SVGAnimatedLength)getLiveAttributeValue
72             (null, SVG_TEXT_LENGTH_ATTRIBUTE);
73         if (result == null) {
74             result = new AbstractSVGAnimatedLength
75                 (this, null, SVG_TEXT_LENGTH_ATTRIBUTE,
76                  SVGOMAnimatedLength.HORIZONTAL_LENGTH) {
77                     boolean usedDefault;
78
79                     protected String JavaDoc getDefaultValue() {
80                         usedDefault = true;
81                         return ""+getComputedTextLength();
82                     }
83
84                     public SVGLength getBaseVal() {
85                         if (baseVal == null) {
86                             baseVal = new SVGTextLength(direction);
87                         }
88                         return baseVal;
89                     }
90                     
91                     class SVGTextLength extends BaseSVGLength {
92                         public SVGTextLength(short direction) {
93                             super(direction);
94                         }
95                         protected void revalidate() {
96                             usedDefault = false;
97
98                             super.revalidate();
99
100                             // Since the default value can change w/o notice
101
// always recompute it.
102
if (usedDefault) valid = false;
103                         }
104                     }
105                 };
106             putLiveAttributeValue(null, SVG_TEXT_LENGTH_ATTRIBUTE,
107                                   (LiveAttributeValue)result);
108         }
109         return result;
110     }
111
112     /**
113      * <b>DOM</b>: Implements {@link
114      * org.w3c.dom.svg.SVGTextContentElement#getLengthAdjust()}.
115      */

116     public SVGAnimatedEnumeration getLengthAdjust() {
117         return getAnimatedEnumerationAttribute
118             (null, SVG_LENGTH_ADJUST_ATTRIBUTE,
119              LENGTH_ADJUST_VALUES, (short)1);
120     }
121
122     /**
123      * <b>DOM</b>: Implements {@link
124      * org.w3c.dom.svg.SVGTextContentElement#getNumberOfChars()}.
125      */

126     public int getNumberOfChars() {
127         return SVGTextContentSupport.getNumberOfChars(this);
128         //throw new RuntimeException(" !!! SVGOMTextContentElement.getNumberOfChars()");
129
}
130
131     /**
132      * <b>DOM</b>: Implements {@link
133      * org.w3c.dom.svg.SVGTextContentElement#getComputedTextLength()}.
134      */

135     public float getComputedTextLength() {
136         return SVGTextContentSupport.getComputedTextLength(this);
137         //throw new RuntimeException(" !!! SVGOMTextContentElement.getComputedTextLength()");
138
}
139
140     /**
141      * <b>DOM</b>: Implements {@link
142      * org.w3c.dom.svg.SVGTextContentElement#getSubStringLength(int,int)}.
143      */

144     public float getSubStringLength(int charnum, int nchars)
145         throws DOMException JavaDoc {
146         return SVGTextContentSupport.getSubStringLength(this,charnum,nchars);
147         //throw new RuntimeException(" !!! SVGOMTextContentElement.getSubStringLength()");
148
}
149
150     /**
151      * <b>DOM</b>: Implements {@link
152      * org.w3c.dom.svg.SVGTextContentElement#getStartPositionOfChar(int)}.
153      */

154     public SVGPoint getStartPositionOfChar(int charnum) throws DOMException JavaDoc {
155         //throw new RuntimeException(" !!! SVGOMTextContentElement.getStartPositionOfChar()");
156
return SVGTextContentSupport.getStartPositionOfChar(this,charnum);
157     }
158
159     /**
160      * <b>DOM</b>: Implements {@link
161      * org.w3c.dom.svg.SVGTextContentElement#getEndPositionOfChar(int)}.
162      */

163     public SVGPoint getEndPositionOfChar(int charnum) throws DOMException JavaDoc {
164         //throw new RuntimeException(" !!! SVGOMTextContentElement.getEndPositionOfChar()");
165
return SVGTextContentSupport.getEndPositionOfChar(this,charnum);
166     }
167
168     /**
169      * <b>DOM</b>: Implements {@link
170      * org.w3c.dom.svg.SVGTextContentElement#getExtentOfChar(int)}.
171      */

172     public SVGRect getExtentOfChar(int charnum) throws DOMException JavaDoc {
173         //throw new RuntimeException(" !!! SVGOMTextContentElement.getExtentOfChar()");
174
return SVGTextContentSupport.getExtentOfChar(this,charnum);
175     }
176
177     /**
178      * <b>DOM</b>: Implements {@link
179      * org.w3c.dom.svg.SVGTextContentElement#getRotationOfChar(int)}.
180      */

181     public float getRotationOfChar(int charnum) throws DOMException JavaDoc {
182         //throw new RuntimeException(" !!! SVGOMTextContentElement.getRotationOfChar()");
183
return SVGTextContentSupport.getRotationOfChar(this,charnum);
184     }
185
186     /**
187      * <b>DOM</b>: Implements {@link
188      * org.w3c.dom.svg.SVGTextContentElement#getCharNumAtPosition(SVGPoint)}.
189      */

190     public int getCharNumAtPosition(SVGPoint point) {
191         //throw new RuntimeException(" !!! SVGOMTextContentElement.getCharNumAtPosition()");
192
return SVGTextContentSupport.getCharNumAtPosition(this,point.getX(),point.getY());
193     }
194
195     /**
196      * <b>DOM</b>: Implements {@link
197      * org.w3c.dom.svg.SVGTextContentElement#selectSubString(int,int)}.
198      */

199     public void selectSubString(int charnum, int nchars)
200         throws DOMException JavaDoc {
201         SVGTextContentSupport.selectSubString(this,charnum, nchars);
202         //throw new RuntimeException(" !!! SVGOMTextContentElement.getSubStringLength()");
203
}
204
205     // SVGExternalResourcesRequired support /////////////////////////////
206

207     /**
208      * <b>DOM</b>: Implements {@link
209      * org.w3c.dom.svg.SVGExternalResourcesRequired#getExternalResourcesRequired()}.
210      */

211     public SVGAnimatedBoolean getExternalResourcesRequired() {
212     return SVGExternalResourcesRequiredSupport.
213             getExternalResourcesRequired(this);
214     }
215
216     // SVGLangSpace support //////////////////////////////////////////////////
217

218     /**
219      * <b>DOM</b>: Returns the xml:lang attribute value.
220      */

221     public String JavaDoc getXMLlang() {
222         return XMLSupport.getXMLLang(this);
223     }
224
225     /**
226      * <b>DOM</b>: Sets the xml:lang attribute value.
227      */

228     public void setXMLlang(String JavaDoc lang) {
229         setAttributeNS(XMLSupport.XML_NAMESPACE_URI,
230                        XMLSupport.XML_LANG_ATTRIBUTE,
231                        lang);
232     }
233     
234     /**
235      * <b>DOM</b>: Returns the xml:space attribute value.
236      */

237     public String JavaDoc getXMLspace() {
238         return XMLSupport.getXMLSpace(this);
239     }
240
241     /**
242      * <b>DOM</b>: Sets the xml:space attribute value.
243      */

244     public void setXMLspace(String JavaDoc space) {
245         setAttributeNS(XMLSupport.XML_NAMESPACE_URI,
246                        XMLSupport.XML_SPACE_ATTRIBUTE,
247                        space);
248     }
249
250     // SVGTests support ///////////////////////////////////////////////////
251

252     /**
253      * <b>DOM</b>: Implements {@link
254      * org.w3c.dom.svg.SVGTests#getRequiredFeatures()}.
255      */

256     public SVGStringList getRequiredFeatures() {
257     return SVGTestsSupport.getRequiredFeatures(this);
258     }
259
260     /**
261      * <b>DOM</b>: Implements {@link
262      * org.w3c.dom.svg.SVGTests#getRequiredExtensions()}.
263      */

264     public SVGStringList getRequiredExtensions() {
265     return SVGTestsSupport.getRequiredExtensions(this);
266     }
267
268     /**
269      * <b>DOM</b>: Implements {@link
270      * org.w3c.dom.svg.SVGTests#getSystemLanguage()}.
271      */

272     public SVGStringList getSystemLanguage() {
273     return SVGTestsSupport.getSystemLanguage(this);
274     }
275
276     /**
277      * <b>DOM</b>: Implements {@link
278      * org.w3c.dom.svg.SVGTests#hasExtension(String)}.
279      */

280     public boolean hasExtension(String JavaDoc extension) {
281     return SVGTestsSupport.hasExtension(this, extension);
282     }
283 }
284
Popular Tags