View Javadoc

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.impl;
31  
32  import org.vectomatic.dom.svg.OMSVGAnimatedBoolean;
33  import org.vectomatic.dom.svg.OMSVGAnimatedLength;
34  import org.vectomatic.dom.svg.OMSVGAnimatedString;
35  import org.vectomatic.dom.svg.OMSVGAnimatedTransformList;
36  import org.vectomatic.dom.svg.OMSVGElementInstance;
37  import org.vectomatic.dom.svg.OMSVGMatrix;
38  import org.vectomatic.dom.svg.OMSVGRect;
39  import org.vectomatic.dom.svg.OMSVGStringList;
40  
41  import com.google.gwt.core.client.JavaScriptException;
42  
43  /**
44   * The {@link org.vectomatic.dom.svg.impl.SVGUseElement} interface corresponds
45   * to the <a href='http://www.w3.org/TR/SVG11/struct.html#UseElement' title='use
46   * element specification'>use</a> element.
47   */
48  public class SVGUseElement extends SVGElement {
49    protected SVGUseElement() {
50    }
51  
52    // Implementation of the svg::SVGUseElement W3C IDL interface
53    /**
54     * Corresponds to attribute {@link org.vectomatic.dom.svg.impl.SVGUseElement#getX()}
55     * on the given <a href='http://www.w3.org/TR/SVG11/struct.html#UseElement'
56     * title='use element specification'>use</a> element.
57     */
58    public final native OMSVGAnimatedLength getX() /*-{
59      return this.x;
60    }-*/;
61    /**
62     * Corresponds to attribute {@link org.vectomatic.dom.svg.impl.SVGUseElement#getY()}
63     * on the given <a href='http://www.w3.org/TR/SVG11/struct.html#UseElement'
64     * title='use element specification'>use</a> element.
65     */
66    public final native OMSVGAnimatedLength getY() /*-{
67      return this.y;
68    }-*/;
69    /**
70     * Corresponds to attribute {@link org.vectomatic.dom.svg.impl.SVGUseElement#getWidth()}
71     * on the given <a href='http://www.w3.org/TR/SVG11/struct.html#UseElement'
72     * title='use element specification'>use</a> element.
73     */
74    public final native OMSVGAnimatedLength getWidth() /*-{
75      return this.width;
76    }-*/;
77    /**
78     * Corresponds to attribute {@link org.vectomatic.dom.svg.impl.SVGUseElement#getHeight()}
79     * on the given <a href='http://www.w3.org/TR/SVG11/struct.html#UseElement'
80     * title='use element specification'>use</a> element.
81     */
82    public final native OMSVGAnimatedLength getHeight() /*-{
83      return this.height;
84    }-*/;
85    /**
86     * The root of the "instance tree".  See description of {@link org.vectomatic.dom.svg.OMSVGElementInstance}
87     * for a discussion on the instance tree.
88     */
89    public final native OMSVGElementInstance getInstanceRoot() /*-{
90      return this.instanceRoot;
91    }-*/;
92    /**
93     * If the <code>xlink:href</code> attribute is being animated, contains the
94     * current animated root of the "instance tree".  If the <code>xlink:href</code>
95     * attribute is not currently being animated, contains the same value as {@link
96     * org.vectomatic.dom.svg.impl.SVGUseElement#getInstanceRoot()}.  See description
97     * of {@link org.vectomatic.dom.svg.OMSVGElementInstance} for a discussion
98     * on the instance tree.
99     */
100   public final native OMSVGElementInstance getAnimatedInstanceRoot() /*-{
101     return this.animatedInstanceRoot;
102   }-*/;
103 
104   // Implementation of the svg::SVGExternalResourcesRequired W3C IDL interface
105   /**
106    * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired#getExternalResourcesRequired()}
107    * on the given element. Note that the SVG DOM defines the attribute {@link
108    * org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired#getExternalResourcesRequired()}
109    * as being of type {@link org.vectomatic.dom.svg.OMSVGAnimatedBoolean}, whereas
110    * the SVG language definition says that {@link org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired#getExternalResourcesRequired()}
111    * is not animated. Because the SVG language definition states that {@link
112    * org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired#getExternalResourcesRequired()}
113    * cannot be animated, the {@link org.vectomatic.dom.svg.OMSVGAnimatedBoolean#getAnimVal()}
114    * will always be the same as the {@link org.vectomatic.dom.svg.OMSVGAnimatedBoolean#getBaseVal()}.
115    */
116   public final native OMSVGAnimatedBoolean getExternalResourcesRequired() /*-{
117     return this.externalResourcesRequired;
118   }-*/;
119 
120   // Implementation of the svg::SVGLangSpace W3C IDL interface
121   /**
122    * Corresponds to attribute <code>xml:lang</code> on the given element.
123    */
124   public final native String getXmllang() /*-{
125     return this.xmllang;
126   }-*/;
127   /**
128    * Corresponds to attribute <code>xml:lang</code> on the given element.
129    * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised on an   attempt
130    * to change the value of a <a href="svgdom.html#ReadOnlyNodes">read only
131    * attribute</a>.
132    */
133   public final native void setXmllang(String value) throws JavaScriptException /*-{
134     this.xmllang = value;
135   }-*/;
136   /**
137    * Corresponds to attribute <code>xml:space</code> on the given element.
138    */
139   public final native String getXmlspace() /*-{
140     return this.xmlspace;
141   }-*/;
142   /**
143    * Corresponds to attribute <code>xml:space</code> on the given element.
144    * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised on an   attempt
145    * to change the value of a <a href="svgdom.html#ReadOnlyNodes">read only
146    * attribute</a>.
147    */
148   public final native void setXmlspace(String value) throws JavaScriptException /*-{
149     this.xmlspace = value;
150   }-*/;
151 
152   // Implementation of the svg::SVGLocatable W3C IDL interface
153   /**
154    * The element which established the current viewport. Often, the nearest
155    * ancestor <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement' title='svg
156    * element specification'>svg</a> element. Null if the current element is
157    * the outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
158    * title='svg element specification'>svg</a> element.
159    */
160   public final native SVGElement getNearestViewportElement() /*-{
161     return this.nearestViewportElement;
162   }-*/;
163   /**
164    * The farthest ancestor <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
165    * title='svg element specification'>svg</a> element. Null if the current
166    * element is the outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
167    * title='svg element specification'>svg</a> element.
168    */
169   public final native SVGElement getFarthestViewportElement() /*-{
170     return this.farthestViewportElement;
171   }-*/;
172   /**
173    * Returns the tight bounding box in current user space (i.e., after application
174    * of the <code>transform</code> attribute, if any) on the geometry of all
175    * contained graphics elements, exclusive of stroking, clipping, masking and
176    * filter effects). Note that getBBox must return the actual bounding box
177    * at the time the method was called, even in case the element has not yet
178    * been rendered.
179    * @return An {@link org.vectomatic.dom.svg.OMSVGRect} object that defines
180    * the bounding box.
181    */
182   public final native OMSVGRect getBBox() /*-{
183     return this.getBBox();
184   }-*/;
185   /**
186    * Returns the transformation matrix from current user units (i.e., after
187    * application of the <code>transform</code> attribute, if any) to the viewport
188    * coordinate system for the {@link org.vectomatic.dom.svg.itf.ISVGLocatable#getNearestViewportElement()}.
189    * @return An {@link org.vectomatic.dom.svg.OMSVGMatrix} object that defines
190    * the CTM.
191    */
192   public final native OMSVGMatrix getCTM() /*-{
193     return this.getCTM();
194   }-*/;
195   /**
196    * Returns the transformation matrix from current user units (i.e., after
197    * application of the <code>transform</code> attribute, if any) to the parent
198    * user agent's notice of a "pixel". For display devices, ideally this represents
199    * a physical screen pixel. For other devices or environments where physical
200    * pixel sizes are not known, then an algorithm similar to the CSS2 definition
201    * of a "pixel" can be used instead.  Note that null is returned if this element
202    * is not hooked into the document tree. This method would have been more
203    * aptly named as <code>getClientCTM</code>, but the name <code>getScreenCTM</code>
204    * is kept for historical reasons.
205    * @return An {@link org.vectomatic.dom.svg.OMSVGMatrix} object that defines
206    * the given   transformation matrix.
207    */
208   public final native OMSVGMatrix getScreenCTM() /*-{
209     return this.getScreenCTM();
210   }-*/;
211   /**
212    * Returns the transformation matrix from the user coordinate system on the
213    * current element (after application of the <code>transform</code> attribute,
214    * if any) to the user coordinate system on parameter <var>element</var> (after
215    * application of its <code>transform</code> attribute, if any).
216    * @param element The target element.
217    * @return An {@link org.vectomatic.dom.svg.OMSVGMatrix} object that defines
218    * the transformation.
219    * @throws SVGException(SVG_MATRIX_NOT_INVERTABLE) Raised if the currently
220    * defined transformation matrices make it impossible to compute the   given
221    * matrix (e.g., because one of the transformations is singular).
222    */
223   public final native OMSVGMatrix getTransformToElement(SVGElement element) throws JavaScriptException /*-{
224     return this.getTransformToElement(element);
225   }-*/;
226 
227   // Implementation of the svg::SVGTests W3C IDL interface
228   /**
229    * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGTests#getRequiredFeatures()}
230    * on the given element.
231    */
232   public final native OMSVGStringList getRequiredFeatures() /*-{
233     return @org.vectomatic.dom.svg.OMNode::convertList(Lcom/google/gwt/core/client/JavaScriptObject;)(this.requiredFeatures);
234   }-*/;
235   /**
236    * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGTests#getRequiredExtensions()}
237    * on the given element.
238    */
239   public final native OMSVGStringList getRequiredExtensions() /*-{
240     return @org.vectomatic.dom.svg.OMNode::convertList(Lcom/google/gwt/core/client/JavaScriptObject;)(this.requiredExtensions);
241   }-*/;
242   /**
243    * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGTests#getSystemLanguage()}
244    * on the given element.
245    */
246   public final native OMSVGStringList getSystemLanguage() /*-{
247     return @org.vectomatic.dom.svg.OMNode::convertList(Lcom/google/gwt/core/client/JavaScriptObject;)(this.systemLanguage);
248   }-*/;
249   /**
250    * Returns true if the user agent supports the given extension, specified
251    * by a URI.
252    * @param extension The name of the extension, expressed as a URI.
253    * @return True or false, depending on whether the given extension is   supported.
254    */
255   public final native boolean hasExtension(String extension) /*-{
256     return this.hasExtension(extension);
257   }-*/;
258 
259   // Implementation of the svg::SVGTransformable W3C IDL interface
260   /**
261    * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGTransformable#getTransform()}
262    * on the given element.
263    */
264   public final native OMSVGAnimatedTransformList getTransform() /*-{
265     return this.transform;
266   }-*/;
267 
268   // Implementation of the svg::SVGURIReference W3C IDL interface
269   /**
270    * Corresponds to attribute <span class='attr-name'>'xlink:href'</span> on
271    * the given element.
272    */
273   public final native OMSVGAnimatedString getHref() /*-{
274     return this.href;
275   }-*/;
276 
277 }