KickJava   Java API By Example, From Geeks To Geeks.

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


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.w3c.dom.Attr JavaDoc;
22 import org.w3c.dom.Node JavaDoc;
23 import org.w3c.dom.svg.SVGAnimatedLength;
24 import org.w3c.dom.svg.SVGRectElement;
25
26 /**
27  * This class implements {@link SVGRectElement}.
28  *
29  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
30  * @version $Id: SVGOMRectElement.java,v 1.7 2004/08/18 07:13:17 vhardy Exp $
31  */

32 public class SVGOMRectElement
33     extends SVGGraphicsElement
34     implements SVGRectElement {
35
36     /**
37      * Creates a new SVGOMRectElement object.
38      */

39     protected SVGOMRectElement() {
40     }
41
42     /**
43      * Creates a new SVGOMRectElement object.
44      * @param prefix The namespace prefix.
45      * @param owner The owner document.
46      */

47     public SVGOMRectElement(String JavaDoc prefix, AbstractDocument owner) {
48         super(prefix, owner);
49     }
50
51     /**
52      * <b>DOM</b>: Implements {@link Node#getLocalName()}.
53      */

54     public String JavaDoc getLocalName() {
55         return SVG_RECT_TAG;
56     }
57
58     /**
59      * <b>DOM</b>: Implements {@link SVGRectElement#getX()}.
60      */

61     public SVGAnimatedLength getX() {
62         return getAnimatedLengthAttribute
63             (null, SVG_X_ATTRIBUTE, SVG_RECT_X_DEFAULT_VALUE,
64              SVGOMAnimatedLength.HORIZONTAL_LENGTH);
65     }
66
67     /**
68      * <b>DOM</b>: Implements {@link SVGRectElement#getY()}.
69      */

70     public SVGAnimatedLength getY() {
71         return getAnimatedLengthAttribute
72             (null, SVG_Y_ATTRIBUTE, SVG_RECT_Y_DEFAULT_VALUE,
73              SVGOMAnimatedLength.VERTICAL_LENGTH);
74     }
75
76     /**
77      * <b>DOM</b>: Implements {@link SVGRectElement#getWidth()}.
78      */

79     public SVGAnimatedLength getWidth() {
80         return getAnimatedLengthAttribute
81             (null, SVG_WIDTH_ATTRIBUTE, "",
82              SVGOMAnimatedLength.HORIZONTAL_LENGTH);
83     }
84
85     /**
86      * <b>DOM</b>: Implements {@link SVGRectElement#getHeight()}.
87      */

88     public SVGAnimatedLength getHeight() {
89         return getAnimatedLengthAttribute
90             (null, SVG_HEIGHT_ATTRIBUTE, "",
91              SVGOMAnimatedLength.VERTICAL_LENGTH);
92     }
93
94     /**
95      * <b>DOM</b>: Implements {@link SVGRectElement#getRx()}.
96      */

97     public SVGAnimatedLength getRx() {
98         SVGAnimatedLength result =
99             (SVGAnimatedLength)getLiveAttributeValue(null, SVG_RX_ATTRIBUTE);
100         if (result == null) {
101             result = new AbstractSVGAnimatedLength
102                 (this, null, SVG_RX_ATTRIBUTE,
103                  SVGOMAnimatedLength.HORIZONTAL_LENGTH) {
104                     protected String JavaDoc getDefaultValue() {
105                         Attr JavaDoc attr = getAttributeNodeNS(null, SVG_RY_ATTRIBUTE);
106                         if (attr == null) {
107                             return "0";
108                         }
109                         return attr.getValue();
110                     }
111                 };
112             putLiveAttributeValue(null, SVG_RX_ATTRIBUTE,
113                                   (LiveAttributeValue)result);
114         }
115         return result;
116     }
117
118     /**
119      * <b>DOM</b>: Implements {@link SVGRectElement#getRy()}.
120      */

121     public SVGAnimatedLength getRy() {
122         SVGAnimatedLength result =
123             (SVGAnimatedLength)getLiveAttributeValue(null, SVG_RY_ATTRIBUTE);
124         if (result == null) {
125             result = new AbstractSVGAnimatedLength
126                 (this, null, SVG_RY_ATTRIBUTE,
127                  SVGOMAnimatedLength.HORIZONTAL_LENGTH) {
128                     protected String JavaDoc getDefaultValue() {
129                         Attr JavaDoc attr = getAttributeNodeNS(null, SVG_RX_ATTRIBUTE);
130                         if (attr == null) {
131                             return "0";
132                         }
133                         return attr.getValue();
134                     }
135                 };
136             putLiveAttributeValue(null, SVG_RY_ATTRIBUTE,
137                                   (LiveAttributeValue)result);
138         }
139         return result;
140     }
141
142     /**
143      * Returns a new uninitialized instance of this object's class.
144      */

145     protected Node JavaDoc newNode() {
146         return new SVGOMRectElement();
147     }
148 }
149
Popular Tags