1 /**********************************************
2 * Copyright (C) 2010 Lukas Laag
3 * This file is part of lib-gwt-svg.
4 *
5 * libgwtsvg is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * libgwtsvg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with libgwtsvg. If not, see http://www.gnu.org/licenses/
17 **********************************************/
18 /*
19 * Copyright (c) 2004 World Wide Web Consortium,
20 *
21 * (Massachusetts Institute of Technology, European Research Consortium for
22 * Informatics and Mathematics, Keio University). All Rights Reserved. This
23 * work is distributed under the W3C(r) Software License [1] in the hope that
24 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
25 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26 *
27 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
28 */
29
30 package org.vectomatic.dom.svg;
31
32 import org.vectomatic.dom.svg.impl.SVGClipPathElement;
33 import org.vectomatic.dom.svg.impl.SVGElement;
34 import org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired;
35 import org.vectomatic.dom.svg.itf.ISVGLangSpace;
36 import org.vectomatic.dom.svg.itf.ISVGStylable;
37 import org.vectomatic.dom.svg.itf.ISVGTests;
38 import org.vectomatic.dom.svg.itf.ISVGTransformable;
39 import org.vectomatic.dom.svg.itf.ISVGUnitTypes;
40 import org.vectomatic.dom.svg.utils.DOMHelper;
41 import org.vectomatic.dom.svg.utils.SVGConstants;
42
43 import com.google.gwt.core.client.JavaScriptException;
44 import com.google.gwt.dom.client.TagName;
45
46 /**
47 * The {@link org.vectomatic.dom.svg.OMSVGClipPathElement} interface corresponds
48 * to the <a href='http://www.w3.org/TR/SVG11/masking.html#ClipPathElement'
49 * title='clipPath element specification'>clipPath</a> element.
50 */
51 @TagName("clipPath")
52 public class OMSVGClipPathElement extends OMSVGElement implements ISVGTests, ISVGLangSpace, ISVGExternalResourcesRequired, ISVGStylable, ISVGTransformable, ISVGUnitTypes {
53 public OMSVGClipPathElement() {
54 this((SVGClipPathElement)DOMHelper.createElementNS(DOMHelper.getCurrentDocument(), SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_CLIP_PATH_TAG).cast());
55 }
56
57 protected OMSVGClipPathElement(SVGClipPathElement ot) {
58 super(ot);
59 }
60
61 // Implementation of the svg::SVGClipPathElement W3C IDL interface
62 /**
63 * Corresponds to attribute {@link org.vectomatic.dom.svg.OMSVGClipPathElement#getClipPathUnits()}
64 * on the given <a href='http://www.w3.org/TR/SVG11/masking.html#ClipPathElement'
65 * title='clipPath element specification'>clipPath</a> element. Takes one
66 * of the constants defined in {@link org.vectomatic.dom.svg.itf.ISVGUnitTypes}.
67 */
68 public final OMSVGAnimatedEnumeration getClipPathUnits() {
69 return ((SVGClipPathElement)ot).getClipPathUnits();
70 }
71
72 // Implementation of the svg::SVGExternalResourcesRequired W3C IDL interface
73 /**
74 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired#getExternalResourcesRequired()}
75 * on the given element. Note that the SVG DOM defines the attribute {@link
76 * org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired#getExternalResourcesRequired()}
77 * as being of type {@link org.vectomatic.dom.svg.OMSVGAnimatedBoolean}, whereas
78 * the SVG language definition says that {@link org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired#getExternalResourcesRequired()}
79 * is not animated. Because the SVG language definition states that {@link
80 * org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired#getExternalResourcesRequired()}
81 * cannot be animated, the {@link org.vectomatic.dom.svg.OMSVGAnimatedBoolean#getAnimVal()}
82 * will always be the same as the {@link org.vectomatic.dom.svg.OMSVGAnimatedBoolean#getBaseVal()}.
83 */
84 public final OMSVGAnimatedBoolean getExternalResourcesRequired() {
85 return ((SVGClipPathElement)ot).getExternalResourcesRequired();
86 }
87
88 // Implementation of the svg::SVGLangSpace W3C IDL interface
89 /**
90 * Corresponds to attribute <code>xml:lang</code> on the given element.
91 */
92 public final String getXmllang() {
93 return ((SVGClipPathElement)ot).getXmllang();
94 }
95 /**
96 * Corresponds to attribute <code>xml:lang</code> on the given element.
97 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised on an attempt
98 * to change the value of a <a href="svgdom.html#ReadOnlyNodes">read only
99 * attribute</a>.
100 */
101 public final void setXmllang(java.lang.String value) throws JavaScriptException {
102 ((SVGClipPathElement)ot).setXmllang(value);
103 }
104 /**
105 * Corresponds to attribute <code>xml:space</code> on the given element.
106 */
107 public final String getXmlspace() {
108 return ((SVGClipPathElement)ot).getXmlspace();
109 }
110 /**
111 * Corresponds to attribute <code>xml:space</code> on the given element.
112 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised on an attempt
113 * to change the value of a <a href="svgdom.html#ReadOnlyNodes">read only
114 * attribute</a>.
115 */
116 public final void setXmlspace(java.lang.String value) throws JavaScriptException {
117 ((SVGClipPathElement)ot).setXmlspace(value);
118 }
119
120 // Implementation of the svg::SVGLocatable W3C IDL interface
121 /**
122 * The element which established the current viewport. Often, the nearest
123 * ancestor <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement' title='svg
124 * element specification'>svg</a> element. Null if the current element is
125 * the outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
126 * title='svg element specification'>svg</a> element.
127 */
128 public final OMSVGElement getNearestViewportElement() {
129 SVGElement elt = ((SVGClipPathElement)ot).getNearestViewportElement();
130 return elt != null ? (OMSVGElement)convert(elt) : null;
131 }
132 /**
133 * The farthest ancestor <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
134 * title='svg element specification'>svg</a> element. Null if the current
135 * element is the outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
136 * title='svg element specification'>svg</a> element.
137 */
138 public final OMSVGElement getFarthestViewportElement() {
139 SVGElement elt = ((SVGClipPathElement)ot).getFarthestViewportElement();
140 return elt != null ? (OMSVGElement)convert(elt) : null;
141 }
142 /**
143 * Returns the tight bounding box in current user space (i.e., after application
144 * of the <code>transform</code> attribute, if any) on the geometry of all
145 * contained graphics elements, exclusive of stroking, clipping, masking and
146 * filter effects). Note that getBBox must return the actual bounding box
147 * at the time the method was called, even in case the element has not yet
148 * been rendered.
149 * @return An {@link org.vectomatic.dom.svg.OMSVGRect} object that defines
150 * the bounding box.
151 */
152 public final OMSVGRect getBBox() {
153 return ((SVGClipPathElement)ot).getBBox();
154 }
155 /**
156 * Returns the transformation matrix from current user units (i.e., after
157 * application of the <code>transform</code> attribute, if any) to the viewport
158 * coordinate system for the {@link org.vectomatic.dom.svg.itf.ISVGLocatable#getNearestViewportElement()}.
159 * @return An {@link org.vectomatic.dom.svg.OMSVGMatrix} object that defines
160 * the CTM.
161 */
162 public final OMSVGMatrix getCTM() {
163 return ((SVGClipPathElement)ot).getCTM();
164 }
165 /**
166 * Returns the transformation matrix from current user units (i.e., after
167 * application of the <code>transform</code> attribute, if any) to the parent
168 * user agent's notice of a "pixel". For display devices, ideally this represents
169 * a physical screen pixel. For other devices or environments where physical
170 * pixel sizes are not known, then an algorithm similar to the CSS2 definition
171 * of a "pixel" can be used instead. Note that null is returned if this element
172 * is not hooked into the document tree. This method would have been more
173 * aptly named as <code>getClientCTM</code>, but the name <code>getScreenCTM</code>
174 * is kept for historical reasons.
175 * @return An {@link org.vectomatic.dom.svg.OMSVGMatrix} object that defines
176 * the given transformation matrix.
177 */
178 public final OMSVGMatrix getScreenCTM() {
179 return ((SVGClipPathElement)ot).getScreenCTM();
180 }
181 /**
182 * Returns the transformation matrix from the user coordinate system on the
183 * current element (after application of the <code>transform</code> attribute,
184 * if any) to the user coordinate system on parameter <var>element</var> (after
185 * application of its <code>transform</code> attribute, if any).
186 * @param element The target element.
187 * @return An {@link org.vectomatic.dom.svg.OMSVGMatrix} object that defines
188 * the transformation.
189 * @throws SVGException(SVG_MATRIX_NOT_INVERTABLE) Raised if the currently
190 * defined transformation matrices make it impossible to compute the given
191 * matrix (e.g., because one of the transformations is singular).
192 */
193 public final OMSVGMatrix getTransformToElement(OMSVGElement element) throws JavaScriptException {
194 return ((SVGClipPathElement)ot).getTransformToElement(((SVGElement)element.ot));
195 }
196
197 // Implementation of the svg::SVGTests W3C IDL interface
198 /**
199 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGTests#getRequiredFeatures()}
200 * on the given element.
201 */
202 public final OMSVGStringList getRequiredFeatures() {
203 return ((SVGClipPathElement)ot).getRequiredFeatures();
204 }
205 /**
206 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGTests#getRequiredExtensions()}
207 * on the given element.
208 */
209 public final OMSVGStringList getRequiredExtensions() {
210 return ((SVGClipPathElement)ot).getRequiredExtensions();
211 }
212 /**
213 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGTests#getSystemLanguage()}
214 * on the given element.
215 */
216 public final OMSVGStringList getSystemLanguage() {
217 return ((SVGClipPathElement)ot).getSystemLanguage();
218 }
219 /**
220 * Returns true if the user agent supports the given extension, specified
221 * by a URI.
222 * @param extension The name of the extension, expressed as a URI.
223 * @return True or false, depending on whether the given extension is supported.
224 */
225 public final boolean hasExtension(String extension) {
226 return ((SVGClipPathElement)ot).hasExtension(extension);
227 }
228
229 // Implementation of the svg::SVGTransformable W3C IDL interface
230 /**
231 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGTransformable#getTransform()}
232 * on the given element.
233 */
234 public final OMSVGAnimatedTransformList getTransform() {
235 return ((SVGClipPathElement)ot).getTransform();
236 }
237
238 // Implementation of the svg::SVGUnitTypes W3C IDL interface
239
240 }