KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Copyright 2000-2004 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.util.SVGConstants;
22 import org.w3c.dom.Node JavaDoc;
23 import org.w3c.dom.svg.SVGAnimatedLengthList;
24 import org.w3c.dom.svg.SVGAnimatedTransformList;
25 import org.w3c.dom.svg.SVGElement;
26 import org.w3c.dom.svg.SVGException;
27 import org.w3c.dom.svg.SVGMatrix;
28 import org.w3c.dom.svg.SVGRect;
29 import org.w3c.dom.svg.SVGTextElement;
30
31 /**
32  * This class implements {@link SVGTextElement}.
33  *
34  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
35  * @version $Id: SVGOMTextElement.java,v 1.13 2004/08/18 07:13:18 vhardy Exp $
36  */

37 public class SVGOMTextElement
38     extends SVGOMTextPositioningElement
39     implements SVGTextElement {
40
41     // Default values for attributes on a text element
42
public static final String JavaDoc X_DEFAULT_VALUE = "0";
43     public static final String JavaDoc Y_DEFAULT_VALUE = "0";
44
45     /**
46      * Creates a new SVGOMTextElement object.
47      */

48     protected SVGOMTextElement() {
49     }
50
51     /**
52      * Creates a new SVGOMTextElement object.
53      * @param prefix The namespace prefix.
54      * @param owner The owner document.
55      */

56     public SVGOMTextElement(String JavaDoc prefix, AbstractDocument owner) {
57         super(prefix, owner);
58     }
59
60     /**
61      * <b>DOM</b>: Implements {@link Node#getLocalName()}.
62      */

63     public String JavaDoc getLocalName() {
64         return SVG_TEXT_TAG;
65     }
66
67     // SVGLocatable support /////////////////////////////////////////////
68

69     /**
70      * <b>DOM</b>: Implements {@link
71      * org.w3c.dom.svg.SVGLocatable#getNearestViewportElement()}.
72      */

73     public SVGElement getNearestViewportElement() {
74     return SVGLocatableSupport.getNearestViewportElement(this);
75     }
76
77     /**
78      * <b>DOM</b>: Implements {@link
79      * org.w3c.dom.svg.SVGLocatable#getFarthestViewportElement()}.
80      */

81     public SVGElement getFarthestViewportElement() {
82     return SVGLocatableSupport.getFarthestViewportElement(this);
83     }
84
85     /**
86      * <b>DOM</b>: Implements {@link org.w3c.dom.svg.SVGLocatable#getBBox()}.
87      */

88     public SVGRect getBBox() {
89     return SVGLocatableSupport.getBBox(this);
90     }
91
92     /**
93      * <b>DOM</b>: Implements {@link org.w3c.dom.svg.SVGLocatable#getCTM()}.
94      */

95     public SVGMatrix getCTM() {
96     return SVGLocatableSupport.getCTM(this);
97     }
98
99     /**
100      * <b>DOM</b>: Implements {@link
101      * org.w3c.dom.svg.SVGLocatable#getScreenCTM()}.
102      */

103     public SVGMatrix getScreenCTM() {
104     return SVGLocatableSupport.getScreenCTM(this);
105     }
106
107     /**
108      * <b>DOM</b>: Implements {@link
109      * org.w3c.dom.svg.SVGLocatable#getTransformToElement(SVGElement)}.
110      */

111     public SVGMatrix getTransformToElement(SVGElement element)
112     throws SVGException {
113     return SVGLocatableSupport.getTransformToElement(this, element);
114     }
115
116     // SVGTransformable support /////////////////////////////////////////////
117

118     /**
119      * <b>DOM</b>: Implements {@link
120      * org.w3c.dom.svg.SVGTransformable#getTransform()}.
121      */

122     public SVGAnimatedTransformList getTransform() {
123     return SVGTransformableSupport.getTransform(this);
124     }
125
126     /**
127      * Returns a new uninitialized instance of this object's class.
128      */

129     protected Node JavaDoc newNode() {
130         return new SVGOMTextElement();
131     }
132
133     // SVGTextPositioningElement support ////////////////////////////////////
134

135     /**
136      * <b>DOM</b>: Implements {@link
137      * org.w3c.dom.svg.SVGTextPositioningElement#getX()}.
138      */

139     public SVGAnimatedLengthList getX() {
140         SVGOMAnimatedLengthList result = (SVGOMAnimatedLengthList)
141             getLiveAttributeValue(null, SVGConstants.SVG_X_ATTRIBUTE);
142         if (result == null) {
143             result = new SVGOMAnimatedLengthList(this, null,
144                                                  SVGConstants.SVG_X_ATTRIBUTE,
145                                                  X_DEFAULT_VALUE,
146                                                  AbstractSVGLength.HORIZONTAL_LENGTH);
147             putLiveAttributeValue(null,
148                                   SVGConstants.SVG_X_ATTRIBUTE, result);
149         }
150         return result;
151     }
152
153     /**
154      * <b>DOM</b>: Implements {@link
155      * org.w3c.dom.svg.SVGTextPositioningElement#getY()}.
156      */

157     public SVGAnimatedLengthList getY() {
158         SVGOMAnimatedLengthList result = (SVGOMAnimatedLengthList)
159             getLiveAttributeValue(null, SVGConstants.SVG_Y_ATTRIBUTE);
160         if (result == null) {
161             result = new SVGOMAnimatedLengthList(this, null,
162                                                  SVGConstants.SVG_Y_ATTRIBUTE,
163                                                  Y_DEFAULT_VALUE,
164                                                  AbstractSVGLength.VERTICAL_LENGTH);
165             putLiveAttributeValue(null,
166                                   SVGConstants.SVG_Y_ATTRIBUTE, result);
167         }
168         return result;
169     }
170 }
171
Popular Tags