KickJava   Java API By Example, From Geeks To Geeks.

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


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.dom.util.XLinkSupport;
22 import org.apache.batik.dom.util.XMLSupport;
23 import org.w3c.dom.Node JavaDoc;
24 import org.w3c.dom.svg.SVGAnimatedBoolean;
25 import org.w3c.dom.svg.SVGAnimatedEnumeration;
26 import org.w3c.dom.svg.SVGAnimatedLength;
27 import org.w3c.dom.svg.SVGAnimatedPreserveAspectRatio;
28 import org.w3c.dom.svg.SVGAnimatedRect;
29 import org.w3c.dom.svg.SVGAnimatedString;
30 import org.w3c.dom.svg.SVGAnimatedTransformList;
31 import org.w3c.dom.svg.SVGPatternElement;
32 import org.w3c.dom.svg.SVGStringList;
33
34 /**
35  * This class implements {@link org.w3c.dom.svg.SVGStopElement}.
36  *
37  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
38  * @version $Id: SVGOMPatternElement.java,v 1.15 2004/09/01 09:35:22 deweese Exp $
39  */

40 public class SVGOMPatternElement
41     extends SVGStylableElement
42     implements SVGPatternElement {
43
44     /**
45      * The attribute initializer.
46      */

47     protected final static AttributeInitializer attributeInitializer;
48     static {
49         attributeInitializer = new AttributeInitializer(5);
50         attributeInitializer.addAttribute(null, null,
51                                           SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE,
52                                           "xMidYMid meet");
53         attributeInitializer.addAttribute(XMLSupport.XMLNS_NAMESPACE_URI,
54                                           null, "xmlns:xlink",
55                                           XLinkSupport.XLINK_NAMESPACE_URI);
56         attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
57                                           "xlink", "type", "simple");
58         attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
59                                           "xlink", "show", "other");
60         attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
61                                           "xlink", "actuate", "onLoad");
62     }
63
64     /**
65      * The units values.
66      */

67     protected final static String JavaDoc[] UNITS_VALUES = {
68         "",
69         SVG_USER_SPACE_ON_USE_VALUE,
70         SVG_OBJECT_BOUNDING_BOX_VALUE
71     };
72
73     /**
74      * Creates a new SVGOMPatternElement object.
75      */

76     protected SVGOMPatternElement() {
77     }
78
79     /**
80      * Creates a new SVGOMPatternElement object.
81      * @param prefix The namespace prefix.
82      * @param owner The owner document.
83      */

84     public SVGOMPatternElement(String JavaDoc prefix,
85                                AbstractDocument owner) {
86         super(prefix, owner);
87     }
88
89     /**
90      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getLocalName()}.
91      */

92     public String JavaDoc getLocalName() {
93         return SVG_PATTERN_TAG;
94     }
95
96     /**
97      * To implement {@link SVGPatternElement#getPatternTransform()}.
98      */

99     public SVGAnimatedTransformList getPatternTransform() {
100         throw new RuntimeException JavaDoc(" !!! TODO: getPatternTransform()");
101     }
102
103     /**
104      * <b>DOM</b>: Implements {@link SVGPatternElement#getPatternUnits()}.
105      */

106     public SVGAnimatedEnumeration getPatternUnits() {
107         return getAnimatedEnumerationAttribute
108             (null, SVG_PATTERN_UNITS_ATTRIBUTE, UNITS_VALUES,
109              (short)2);
110     }
111
112     /**
113      * <b>DOM</b>: Implements {@link
114      * SVGPatternElement#getPatternContentUnits()}.
115      */

116     public SVGAnimatedEnumeration getPatternContentUnits() {
117         return getAnimatedEnumerationAttribute
118             (null, SVG_PATTERN_CONTENT_UNITS_ATTRIBUTE, UNITS_VALUES,
119              (short)1);
120     }
121
122     /**
123      * <b>DOM</b>: Implements {@link SVGPatternElement#getX()}.
124      */

125     public SVGAnimatedLength getX() {
126         return getAnimatedLengthAttribute
127             (null, SVG_X_ATTRIBUTE, SVG_PATTERN_X_DEFAULT_VALUE,
128              SVGOMAnimatedLength.HORIZONTAL_LENGTH);
129     }
130
131     /**
132      * <b>DOM</b>: Implements {@link SVGPatternElement#getY()}.
133      */

134     public SVGAnimatedLength getY() {
135         return getAnimatedLengthAttribute
136             (null, SVG_Y_ATTRIBUTE, SVG_PATTERN_Y_DEFAULT_VALUE,
137              SVGOMAnimatedLength.VERTICAL_LENGTH);
138     }
139
140     /**
141      * <b>DOM</b>: Implements {@link SVGPatternElement#getWidth()}.
142      */

143     public SVGAnimatedLength getWidth() {
144         return getAnimatedLengthAttribute
145             (null, SVG_WIDTH_ATTRIBUTE, SVG_PATTERN_WIDTH_DEFAULT_VALUE,
146              SVGOMAnimatedLength.HORIZONTAL_LENGTH);
147     }
148
149     /**
150      * <b>DOM</b>: Implements {@link
151      * org.w3c.dom.svg.SVGPatternElement#getHeight()}.
152      */

153     public SVGAnimatedLength getHeight() {
154         return getAnimatedLengthAttribute
155             (null, SVG_HEIGHT_ATTRIBUTE, SVG_PATTERN_HEIGHT_DEFAULT_VALUE,
156              SVGOMAnimatedLength.VERTICAL_LENGTH);
157     }
158
159     // XLink support //////////////////////////////////////////////////////
160

161     /**
162      * <b>DOM</b>: Implements {@link
163      * org.w3c.dom.svg.SVGURIReference#getHref()}.
164      */

165     public SVGAnimatedString getHref() {
166         return SVGURIReferenceSupport.getHref(this);
167     }
168
169     // SVGFitToViewBox support ////////////////////////////////////////////
170

171     /**
172      * <b>DOM</b>: Implements {@link
173      * org.w3c.dom.svg.SVGFitToViewBox#getViewBox()}.
174      */

175     public SVGAnimatedRect getViewBox() {
176         throw new RuntimeException JavaDoc(" !!! TODO: getViewBox()");
177     }
178
179     /**
180      * <b>DOM</b>: Implements {@link
181      * org.w3c.dom.svg.SVGFitToViewBox#getPreserveAspectRatio()}.
182      */

183     public SVGAnimatedPreserveAspectRatio getPreserveAspectRatio() {
184         return SVGPreserveAspectRatioSupport.getPreserveAspectRatio(this);
185     }
186
187     // SVGExternalResourcesRequired support /////////////////////////////
188

189     /**
190      * <b>DOM</b>: Implements {@link
191      * org.w3c.dom.svg.SVGExternalResourcesRequired#getExternalResourcesRequired()}.
192      */

193     public SVGAnimatedBoolean getExternalResourcesRequired() {
194         return SVGExternalResourcesRequiredSupport.
195             getExternalResourcesRequired(this);
196     }
197
198     // SVGLangSpace support //////////////////////////////////////////////////
199

200     /**
201      * <b>DOM</b>: Returns the xml:lang attribute value.
202      */

203     public String JavaDoc getXMLlang() {
204         return XMLSupport.getXMLLang(this);
205     }
206
207     /**
208      * <b>DOM</b>: Sets the xml:lang attribute value.
209      */

210     public void setXMLlang(String JavaDoc lang) {
211         setAttributeNS(XMLSupport.XML_NAMESPACE_URI,
212                        XMLSupport.XML_LANG_ATTRIBUTE,
213                        lang);
214     }
215
216     /**
217      * <b>DOM</b>: Returns the xml:space attribute value.
218      */

219     public String JavaDoc getXMLspace() {
220         return XMLSupport.getXMLSpace(this);
221     }
222
223     /**
224      * <b>DOM</b>: Sets the xml:space attribute value.
225      */

226     public void setXMLspace(String JavaDoc space) {
227         setAttributeNS(XMLSupport.XML_NAMESPACE_URI,
228                        XMLSupport.XML_SPACE_ATTRIBUTE,
229                        space);
230     }
231
232     // SVGTests support ///////////////////////////////////////////////////
233

234     /**
235      * <b>DOM</b>: Implements {@link
236      * org.w3c.dom.svg.SVGTests#getRequiredFeatures()}.
237      */

238     public SVGStringList getRequiredFeatures() {
239         return SVGTestsSupport.getRequiredFeatures(this);
240     }
241
242     /**
243      * <b>DOM</b>: Implements {@link
244      * org.w3c.dom.svg.SVGTests#getRequiredExtensions()}.
245      */

246     public SVGStringList getRequiredExtensions() {
247         return SVGTestsSupport.getRequiredExtensions(this);
248     }
249
250     /**
251      * <b>DOM</b>: Implements {@link
252      * org.w3c.dom.svg.SVGTests#getSystemLanguage()}.
253      */

254     public SVGStringList getSystemLanguage() {
255         return SVGTestsSupport.getSystemLanguage(this);
256     }
257
258     /**
259      * <b>DOM</b>: Implements {@link
260      * org.w3c.dom.svg.SVGTests#hasExtension(String)}.
261      */

262     public boolean hasExtension(String JavaDoc extension) {
263         return SVGTestsSupport.hasExtension(this, extension);
264     }
265
266     /**
267      * Returns the AttributeInitializer for this element type.
268      * @return null if this element has no attribute with a default value.
269      */

270     protected AttributeInitializer getAttributeInitializer() {
271         return attributeInitializer;
272     }
273
274     /**
275      * Returns a new uninitialized instance of this object's class.
276      */

277     protected Node JavaDoc newNode() {
278         return new SVGOMPatternElement();
279     }
280 }
281
Popular Tags