KickJava   Java API By Example, From Geeks To Geeks.

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


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.SVGAnimatedLength;
25 import org.w3c.dom.svg.SVGAnimatedPreserveAspectRatio;
26 import org.w3c.dom.svg.SVGImageElement;
27
28 /**
29  * This class implements {@link SVGImageElement}.
30  *
31  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
32  * @version $Id: SVGOMImageElement.java,v 1.12 2004/09/01 09:35:22 deweese Exp $
33  */

34 public class SVGOMImageElement
35     extends SVGURIReferenceGraphicsElement
36     implements SVGImageElement {
37
38     /**
39      * The attribute initializer.
40      */

41     protected final static AttributeInitializer attributeInitializer;
42     static {
43         attributeInitializer = new AttributeInitializer(5);
44         attributeInitializer.addAttribute(null, null,
45                                           SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE,
46                                           "xMidYMid meet");
47         attributeInitializer.addAttribute(XMLSupport.XMLNS_NAMESPACE_URI,
48                                           null, "xmlns:xlink",
49                                           XLinkSupport.XLINK_NAMESPACE_URI);
50         attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
51                                           "xlink", "type", "simple");
52         attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
53                                           "xlink", "show", "embed");
54         attributeInitializer.addAttribute(XLinkSupport.XLINK_NAMESPACE_URI,
55                                           "xlink", "actuate", "onLoad");
56     }
57
58     /**
59      * Creates a new SVGOMImageElement object.
60      */

61     protected SVGOMImageElement() {
62     }
63
64     /**
65      * Creates a new SVGOMImageElement object.
66      * @param prefix The namespace prefix.
67      * @param owner The owner document.
68      */

69     public SVGOMImageElement(String JavaDoc prefix, AbstractDocument owner) {
70         super(prefix, owner);
71     }
72
73     /**
74      * <b>DOM</b>: Implements {@link Node#getLocalName()}.
75      */

76     public String JavaDoc getLocalName() {
77         return SVG_IMAGE_TAG;
78     }
79
80     /**
81      * <b>DOM</b>: Implements {@link SVGImageElement#getX()}.
82      */

83     public SVGAnimatedLength getX() {
84         return getAnimatedLengthAttribute
85             (null, SVG_X_ATTRIBUTE, SVG_IMAGE_X_DEFAULT_VALUE,
86              SVGOMAnimatedLength.HORIZONTAL_LENGTH);
87     }
88
89     /**
90      * <b>DOM</b>: Implements {@link SVGImageElement#getY()}.
91      */

92     public SVGAnimatedLength getY() {
93         return getAnimatedLengthAttribute
94             (null, SVG_Y_ATTRIBUTE, SVG_IMAGE_Y_DEFAULT_VALUE,
95              SVGOMAnimatedLength.VERTICAL_LENGTH);
96     }
97
98     /**
99      * <b>DOM</b>: Implements {@link SVGImageElement#getWidth()}.
100      */

101     public SVGAnimatedLength getWidth() {
102         return getAnimatedLengthAttribute
103             (null, SVG_WIDTH_ATTRIBUTE, "",
104              SVGOMAnimatedLength.HORIZONTAL_LENGTH);
105     }
106
107     /**
108      * <b>DOM</b>: Implements {@link SVGImageElement#getHeight()}.
109      */

110     public SVGAnimatedLength getHeight() {
111         return getAnimatedLengthAttribute
112             (null, SVG_HEIGHT_ATTRIBUTE, "",
113              SVGOMAnimatedLength.VERTICAL_LENGTH);
114     }
115
116     /**
117      * <b>DOM</b>: Implements {@link SVGImageElement#getPreserveAspectRatio()}.
118      */

119     public SVGAnimatedPreserveAspectRatio getPreserveAspectRatio() {
120         return SVGPreserveAspectRatioSupport.getPreserveAspectRatio(this);
121     }
122
123     /**
124      * Returns the AttributeInitializer for this element type.
125      * @return null if this element has no attribute with a default value.
126      */

127     protected AttributeInitializer getAttributeInitializer() {
128         return attributeInitializer;
129     }
130
131     /**
132      * Returns a new uninitialized instance of this object's class.
133      */

134     protected Node JavaDoc newNode() {
135         return new SVGOMImageElement();
136     }
137 }
138
Popular Tags