1 /**********************************************
2 * Copyright (C) 2010-2011 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.events.ActivateEvent;
33 import org.vectomatic.dom.svg.events.ActivateHandler;
34 import org.vectomatic.dom.svg.events.FocusInEvent;
35 import org.vectomatic.dom.svg.events.FocusInHandler;
36 import org.vectomatic.dom.svg.events.FocusOutEvent;
37 import org.vectomatic.dom.svg.events.FocusOutHandler;
38 import org.vectomatic.dom.svg.events.HasDocumentHandlers;
39 import org.vectomatic.dom.svg.events.HasGraphicalHandlers;
40 import org.vectomatic.dom.svg.events.SVGZoomEvent;
41 import org.vectomatic.dom.svg.events.SVGZoomHandler;
42 import org.vectomatic.dom.svg.impl.SVGElement;
43 import org.vectomatic.dom.svg.impl.SVGSVGElement;
44 import org.vectomatic.dom.svg.itf.ISVGContainerElement;
45 import org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired;
46 import org.vectomatic.dom.svg.itf.ISVGFitToViewBox;
47 import org.vectomatic.dom.svg.itf.ISVGLangSpace;
48 import org.vectomatic.dom.svg.itf.ISVGLocatable;
49 import org.vectomatic.dom.svg.itf.ISVGStylable;
50 import org.vectomatic.dom.svg.itf.ISVGTests;
51 import org.vectomatic.dom.svg.itf.ISVGZoomAndPan;
52 import org.vectomatic.dom.svg.utils.DOMHelper;
53 import org.vectomatic.dom.svg.utils.SVGConstants;
54
55 import com.google.gwt.core.client.JavaScriptException;
56 import com.google.gwt.dom.client.Element;
57 import com.google.gwt.dom.client.Node;
58 import com.google.gwt.dom.client.NodeList;
59 import com.google.gwt.dom.client.Style;
60 import com.google.gwt.dom.client.TagName;
61 import com.google.gwt.event.dom.client.ClickEvent;
62 import com.google.gwt.event.dom.client.ClickHandler;
63 import com.google.gwt.event.dom.client.DragEndEvent;
64 import com.google.gwt.event.dom.client.DragEndHandler;
65 import com.google.gwt.event.dom.client.DragEnterEvent;
66 import com.google.gwt.event.dom.client.DragEnterHandler;
67 import com.google.gwt.event.dom.client.DragEvent;
68 import com.google.gwt.event.dom.client.DragHandler;
69 import com.google.gwt.event.dom.client.DragLeaveEvent;
70 import com.google.gwt.event.dom.client.DragLeaveHandler;
71 import com.google.gwt.event.dom.client.DragOverEvent;
72 import com.google.gwt.event.dom.client.DragOverHandler;
73 import com.google.gwt.event.dom.client.DragStartEvent;
74 import com.google.gwt.event.dom.client.DragStartHandler;
75 import com.google.gwt.event.dom.client.DropEvent;
76 import com.google.gwt.event.dom.client.DropHandler;
77 import com.google.gwt.event.dom.client.LoadEvent;
78 import com.google.gwt.event.dom.client.LoadHandler;
79 import com.google.gwt.event.dom.client.MouseDownEvent;
80 import com.google.gwt.event.dom.client.MouseDownHandler;
81 import com.google.gwt.event.dom.client.MouseMoveEvent;
82 import com.google.gwt.event.dom.client.MouseMoveHandler;
83 import com.google.gwt.event.dom.client.MouseOutEvent;
84 import com.google.gwt.event.dom.client.MouseOutHandler;
85 import com.google.gwt.event.dom.client.MouseOverEvent;
86 import com.google.gwt.event.dom.client.MouseOverHandler;
87 import com.google.gwt.event.dom.client.MouseUpEvent;
88 import com.google.gwt.event.dom.client.MouseUpHandler;
89 import com.google.gwt.event.dom.client.ScrollEvent;
90 import com.google.gwt.event.dom.client.ScrollHandler;
91 import com.google.gwt.event.dom.client.TouchCancelEvent;
92 import com.google.gwt.event.dom.client.TouchCancelHandler;
93 import com.google.gwt.event.dom.client.TouchEndEvent;
94 import com.google.gwt.event.dom.client.TouchEndHandler;
95 import com.google.gwt.event.dom.client.TouchMoveEvent;
96 import com.google.gwt.event.dom.client.TouchMoveHandler;
97 import com.google.gwt.event.dom.client.TouchStartEvent;
98 import com.google.gwt.event.dom.client.TouchStartHandler;
99 import com.google.gwt.event.logical.shared.ResizeEvent;
100 import com.google.gwt.event.logical.shared.ResizeHandler;
101 import com.google.gwt.event.shared.HandlerRegistration;
102
103 /**
104 * <p>A key interface definition is the {@link org.vectomatic.dom.svg.OMSVGSVGElement}
105 * interface, which is the interface that corresponds to the <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
106 * title='svg element specification'>svg</a> element. This interface contains
107 * various miscellaneous commonly-used utility methods, such as matrix operations
108 * and the ability to control the time of redraw on visual rendering devices.</p>
109 * <p>{@link org.vectomatic.dom.svg.OMSVGSVGElement} extends <code>ViewCSS</code>
110 * and <code>DocumentCSS</code> to provide access to the computed values of
111 * properties and the override style sheet as described in <a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/"><cite>DOM
112 * Level 2 Style</cite></a> [<a href="refs.html#ref-DOM2STYLE">DOM2STYLE</a>].</p>
113 */
114 @TagName("svg")
115 public class OMSVGSVGElement extends OMSVGElement implements HasGraphicalHandlers, HasDocumentHandlers, ISVGTests, ISVGLangSpace, ISVGExternalResourcesRequired, ISVGStylable, ISVGLocatable, ISVGFitToViewBox, ISVGZoomAndPan, ISVGContainerElement {
116 public OMSVGSVGElement() {
117 this((SVGSVGElement)DOMHelper.createElementNS(DOMHelper.getCurrentDocument(), SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_SVG_TAG).cast());
118 }
119
120 public OMSVGSVGElement(SVGSVGElement ot) {
121 super(ot);
122 }
123
124 // Implementation of the svg::SVGSVGElement W3C IDL interface
125 /**
126 * Corresponds to attribute {@link org.vectomatic.dom.svg.OMSVGSVGElement#getX()}
127 * on the given <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
128 * title='svg element specification'>svg</a> element.
129 */
130 public final OMSVGAnimatedLength getX() {
131 return ((SVGSVGElement)ot).getX();
132 }
133 /**
134 * Corresponds to attribute {@link org.vectomatic.dom.svg.OMSVGSVGElement#getY()}
135 * on the given <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
136 * title='svg element specification'>svg</a> element.
137 */
138 public final OMSVGAnimatedLength getY() {
139 return ((SVGSVGElement)ot).getY();
140 }
141 /**
142 * Corresponds to attribute {@link org.vectomatic.dom.svg.OMSVGSVGElement#getWidth()}
143 * on the given <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
144 * title='svg element specification'>svg</a> element.
145 */
146 public final OMSVGAnimatedLength getWidth() {
147 return ((SVGSVGElement)ot).getWidth();
148 }
149 /**
150 * Corresponds to attribute {@link org.vectomatic.dom.svg.OMSVGSVGElement#getHeight()}
151 * on the given <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
152 * title='svg element specification'>svg</a> element.
153 */
154 public final OMSVGAnimatedLength getHeight() {
155 return ((SVGSVGElement)ot).getHeight();
156 }
157 /**
158 * Corresponds to attribute {@link org.vectomatic.dom.svg.OMSVGSVGElement#getContentScriptType()}
159 * on the given <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
160 * title='svg element specification'>svg</a> element.
161 */
162 public final String getContentScriptType() {
163 return ((SVGSVGElement)ot).getContentScriptType();
164 }
165 /**
166 * Corresponds to attribute {@link org.vectomatic.dom.svg.OMSVGSVGElement#getContentScriptType()}
167 * on the given <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
168 * title='svg element specification'>svg</a> element.
169 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised on an attempt
170 * to change the value of a <a href="svgdom.html#ReadOnlyNodes">read only
171 * attribute</a>.
172 */
173 public final void setContentScriptType(java.lang.String value) throws JavaScriptException {
174 ((SVGSVGElement)ot).setContentScriptType(value);
175 }
176 /**
177 * Corresponds to attribute {@link org.vectomatic.dom.svg.OMSVGSVGElement#getContentStyleType()}
178 * on the given <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
179 * title='svg element specification'>svg</a> element.
180 */
181 public final String getContentStyleType() {
182 return ((SVGSVGElement)ot).getContentStyleType();
183 }
184 /**
185 * Corresponds to attribute {@link org.vectomatic.dom.svg.OMSVGSVGElement#getContentStyleType()}
186 * on the given <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
187 * title='svg element specification'>svg</a> element.
188 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised on an attempt
189 * to change the value of a <a href="svgdom.html#ReadOnlyNodes">read only
190 * attribute</a>.
191 */
192 public final void setContentStyleType(java.lang.String value) throws JavaScriptException {
193 ((SVGSVGElement)ot).setContentStyleType(value);
194 }
195 /**
196 * <p>The position and size of the viewport (implicit or explicit) that corresponds
197 * to this <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement' title='svg
198 * element specification'>svg</a> element. When the user agent is actually
199 * rendering the content, then the position and size values represent the
200 * actual values when rendering. The position and size values are unitless
201 * values in the coordinate system of the parent element. If no parent element
202 * exists (i.e., <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
203 * title='svg element specification'>svg</a> element represents the root of
204 * the document tree), if this SVG document is embedded as part of another
205 * document (e.g., via the HTML <span class='element-name'>'object'</span>
206 * element), then the position and size are unitless values in the coordinate
207 * system of the parent document. (If the parent uses CSS or XSL layout, then
208 * unitless values represent pixel units for the current CSS or XSL viewport,
209 * as described in the CSS2 specification.) If the parent element does not
210 * have a coordinate system, then the user agent should provide reasonable
211 * default values for this attribute.</p> <p>The {@link org.vectomatic.dom.svg.OMSVGRect}
212 * object is <a href="types.html#ReadOnlyRect">read only</a>.</p>
213 */
214 public final OMSVGRect getViewport() {
215 return ((SVGSVGElement)ot).getViewport();
216 }
217 /**
218 * Size of a pixel units (as defined by CSS2) along the x-axis of the viewport,
219 * which represents a unit somewhere in the range of 70dpi to 120dpi, and,
220 * on systems that support this, might actually match the characteristics
221 * of the target medium. On systems where it is impossible to know the size
222 * of a pixel, a suitable default pixel size is provided.
223 */
224 public final float getPixelUnitToMillimeterX() {
225 return ((SVGSVGElement)ot).getPixelUnitToMillimeterX();
226 }
227 /**
228 * Corresponding size of a pixel unit along the y-axis of the viewport.
229 */
230 public final float getPixelUnitToMillimeterY() {
231 return ((SVGSVGElement)ot).getPixelUnitToMillimeterY();
232 }
233 /**
234 * User interface (UI) events in DOM Level 2 indicate the screen positions
235 * at which the given UI event occurred. When the user agent actually knows
236 * the physical size of a "screen unit", this attribute will express that
237 * information; otherwise, user agents will provide a suitable default value
238 * such as .28mm.
239 */
240 public final float getScreenPixelToMillimeterX() {
241 return ((SVGSVGElement)ot).getScreenPixelToMillimeterX();
242 }
243 /**
244 * Corresponding size of a screen pixel along the y-axis of the viewport.
245 */
246 public final float getScreenPixelToMillimeterY() {
247 return ((SVGSVGElement)ot).getScreenPixelToMillimeterY();
248 }
249 /**
250 * The initial view (i.e., before magnification and panning) of the current
251 * innermost SVG document fragment can be either the "standard" view (i.e.,
252 * based on attributes on the <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
253 * title='svg element specification'>svg</a> element such as <code>svg/viewBox</code>)
254 * or to a "custom" view (i.e., a hyperlink into a particular <a href='http://www.w3.org/TR/SVG11/linking.html#ViewElement'
255 * title='view element specification'>view</a> or other element - see <a href="linking.html#LinksIntoSVG">Linking
256 * into SVG content: URI fragments and SVG views</a>). If the initial view
257 * is the "standard" view, then this attribute is false. If the initial view
258 * is a "custom" view, then this attribute is true.
259 */
260 public final boolean getUseCurrentView() {
261 return ((SVGSVGElement)ot).getUseCurrentView();
262 }
263 /**
264 * <p>The definition of the initial view (i.e., before magnification and panning)
265 * of the current innermost SVG document fragment. The meaning depends on
266 * the situation:</p> <ul> <li> If the initial view was a "standard"
267 * view, then: <ul> <li>the values for {@link org.vectomatic.dom.svg.itf.ISVGFitToViewBox#getViewBox()},
268 * {@link org.vectomatic.dom.svg.itf.ISVGFitToViewBox#getPreserveAspectRatio()}
269 * and {@link org.vectomatic.dom.svg.itf.ISVGZoomAndPan#getZoomAndPan()}
270 * within {@link org.vectomatic.dom.svg.OMSVGSVGElement#getCurrentView()}
271 * will match the values for the corresponding DOM attributes that are
272 * on SVGSVGElement directly</li> <li>the values for {@link org.vectomatic.dom.svg.itf.ISVGViewSpec#getTransform()}
273 * and {@link org.vectomatic.dom.svg.itf.ISVGViewSpec#getViewTarget()}
274 * within {@link org.vectomatic.dom.svg.OMSVGSVGElement#getCurrentView()}
275 * will be null</li> </ul> </li> <li> If the initial view was
276 * a link into a <a href='http://www.w3.org/TR/SVG11/linking.html#ViewElement'
277 * title='view element specification'>view</a> element, then: <ul>
278 * <li>the values for {@link org.vectomatic.dom.svg.itf.ISVGFitToViewBox#getViewBox()},
279 * {@link org.vectomatic.dom.svg.itf.ISVGFitToViewBox#getPreserveAspectRatio()}
280 * and {@link org.vectomatic.dom.svg.itf.ISVGZoomAndPan#getZoomAndPan()}
281 * within {@link org.vectomatic.dom.svg.OMSVGSVGElement#getCurrentView()}
282 * will correspond to the corresponding attributes for the given <a
283 * href='http://www.w3.org/TR/SVG11/linking.html#ViewElement' title='view
284 * element specification'>view</a> element</li> <li>the values for {@link
285 * org.vectomatic.dom.svg.itf.ISVGViewSpec#getTransform()} and {@link
286 * org.vectomatic.dom.svg.itf.ISVGViewSpec#getViewTarget()} within {@link
287 * org.vectomatic.dom.svg.OMSVGSVGElement#getCurrentView()} will be
288 * null</li> </ul> </li> <li> If the initial view was a link into
289 * another element (i.e., other than a <a href='http://www.w3.org/TR/SVG11/linking.html#ViewElement'
290 * title='view element specification'>view</a>), then: <ul> <li>the
291 * values for {@link org.vectomatic.dom.svg.itf.ISVGFitToViewBox#getViewBox()},
292 * {@link org.vectomatic.dom.svg.itf.ISVGFitToViewBox#getPreserveAspectRatio()}
293 * and {@link org.vectomatic.dom.svg.itf.ISVGZoomAndPan#getZoomAndPan()}
294 * within {@link org.vectomatic.dom.svg.OMSVGSVGElement#getCurrentView()}
295 * will match the values for the corresponding DOM attributes that are
296 * on SVGSVGElement directly for the closest ancestor <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
297 * title='svg element specification'>svg</a> element</li> <li>the values
298 * for {@link org.vectomatic.dom.svg.itf.ISVGViewSpec#getTransform()} within
299 * {@link org.vectomatic.dom.svg.OMSVGSVGElement#getCurrentView()} will be
300 * null</li> <li>the {@link org.vectomatic.dom.svg.itf.ISVGViewSpec#getViewTarget()}
301 * within {@link org.vectomatic.dom.svg.OMSVGSVGElement#getCurrentView()}
302 * will represent the target of the link</li> </ul> </li> <li>
303 * If the initial view was a link into the SVG document fragment using
304 * an SVG view specification fragment identifier (i.e., #svgView(...)),
305 * then: <ul> <li>the values for {@link org.vectomatic.dom.svg.itf.ISVGFitToViewBox#getViewBox()},
306 * {@link org.vectomatic.dom.svg.itf.ISVGFitToViewBox#getPreserveAspectRatio()},
307 * {@link org.vectomatic.dom.svg.itf.ISVGZoomAndPan#getZoomAndPan()},
308 * {@link org.vectomatic.dom.svg.itf.ISVGViewSpec#getTransform()} and
309 * {@link org.vectomatic.dom.svg.itf.ISVGViewSpec#getViewTarget()} within
310 * {@link org.vectomatic.dom.svg.OMSVGSVGElement#getCurrentView()} will
311 * correspond to the values from the SVG view specification fragment
312 * identifier</li> </ul> </li> </ul> <p>The object itself and its contents
313 * are both read only.</p>
314 */
315 public final OMSVGViewSpec getCurrentView() {
316 return ((SVGSVGElement)ot).getCurrentView();
317 }
318 /**
319 * On an outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
320 * title='svg element specification'>svg</a> element, this attribute indicates
321 * the current scale factor relative to the initial view to take into account
322 * user magnification and panning operations, as described under <a href='interact.html#ZoomAndPanAttribute'>Magnification
323 * and panning</a>. DOM attributes {@link org.vectomatic.dom.svg.OMSVGSVGElement#getCurrentScale()}
324 * and {@link org.vectomatic.dom.svg.OMSVGSVGElement#getCurrentTranslate()}
325 * are equivalent to the 2x3 matrix [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y].
326 * If "magnification" is enabled (i.e., <span class='attr-value'>zoomAndPan="magnify"</span>),
327 * then the effect is as if an extra transformation were placed at the outermost
328 * level on the SVG document fragment (i.e., outside the outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
329 * title='svg element specification'>svg</a> element). <p>When accessed on
330 * an <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement' title='svg
331 * element specification'>svg</a> element that is not an outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
332 * title='svg element specification'>svg</a> element, it is undefined what
333 * behavior this attribute has.</p>
334 */
335 public final float getCurrentScale() {
336 return ((SVGSVGElement)ot).getCurrentScale();
337 }
338 /**
339 * On an outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
340 * title='svg element specification'>svg</a> element, this attribute indicates
341 * the current scale factor relative to the initial view to take into account
342 * user magnification and panning operations, as described under <a href='interact.html#ZoomAndPanAttribute'>Magnification
343 * and panning</a>. DOM attributes {@link org.vectomatic.dom.svg.OMSVGSVGElement#getCurrentScale()}
344 * and {@link org.vectomatic.dom.svg.OMSVGSVGElement#getCurrentTranslate()}
345 * are equivalent to the 2x3 matrix [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y].
346 * If "magnification" is enabled (i.e., <span class='attr-value'>zoomAndPan="magnify"</span>),
347 * then the effect is as if an extra transformation were placed at the outermost
348 * level on the SVG document fragment (i.e., outside the outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
349 * title='svg element specification'>svg</a> element). <p>When accessed on
350 * an <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement' title='svg
351 * element specification'>svg</a> element that is not an outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
352 * title='svg element specification'>svg</a> element, it is undefined what
353 * behavior this attribute has.</p>
354 */
355 public final void setCurrentScale(float value) {
356 ((SVGSVGElement)ot).setCurrentScale(value);
357 }
358 /**
359 * On an outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
360 * title='svg element specification'>svg</a> element, the corresponding translation
361 * factor that takes into account user "magnification". <p>When accessed on
362 * an <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement' title='svg
363 * element specification'>svg</a> element that is not an outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
364 * title='svg element specification'>svg</a> element, it is undefined what
365 * behavior this attribute has.</p>
366 */
367 public final OMSVGPoint getCurrentTranslate() {
368 return ((SVGSVGElement)ot).getCurrentTranslate();
369 }
370 /**
371 * Takes a time-out value which indicates that redraw shall not occur until:
372 * <ol> <li>the corresponding unsuspendRedraw() call has been made,</li>
373 * <li>an unsuspendRedrawAll() call has been made, or</li> <li>its timer
374 * has timed out.</li> </ol> <p>In environments that do not support interactivity
375 * (e.g., print media), then redraw shall not be suspended. Calls to suspendRedraw()
376 * and unsuspendRedraw() should, but need not be, made in balanced pairs.</p>
377 * <p>To suspend redraw actions as a collection of SVG DOM changes occur,
378 * precede the changes to the SVG DOM with a method call similar to:</p> <pre>suspendHandleID
379 * = suspendRedraw(maxWaitMilliseconds);</pre> <p>and follow the changes with
380 * a method call similar to:</p> <pre>unsuspendRedraw(suspendHandleID);</pre>
381 * <p>Note that multiple suspendRedraw calls can be used at once and that
382 * each such method call is treated independently of the other suspendRedraw
383 * method calls.</p>
384 * @param maxWaitMilliseconds The amount of time in milliseconds to hold
385 * off before redrawing the device. Values greater than 60 seconds will
386 * be truncated down to 60 seconds.
387 * @return A number which acts as a unique identifier for the given suspendRedraw()
388 * call. This value must be passed as the parameter to the corresponding
389 * unsuspendRedraw() method call.
390 */
391 public final int suspendRedraw(int maxWaitMilliseconds) {
392 return ((SVGSVGElement)ot).suspendRedraw(maxWaitMilliseconds);
393 }
394 /**
395 * Cancels a specified suspendRedraw() by providing a unique suspend handle
396 * ID that was returned by a previous suspendRedraw() call.
397 * @param suspendHandleID A number which acts as a unique identifier for
398 * the desired suspendRedraw() call. The number supplied must be a value
399 * returned from a previous call to suspendRedraw(). If an invalid handle
400 * ID value is provided then the request to unsuspendRedraw() is silently
401 * ignored.
402 */
403 public final void unsuspendRedraw(int suspendHandleID) {
404 ((SVGSVGElement)ot).unsuspendRedraw(suspendHandleID);
405 }
406 /**
407 * Cancels all currently active suspendRedraw() method calls. This method
408 * is most useful at the very end of a set of SVG DOM calls to ensure that
409 * all pending suspendRedraw() method calls have been cancelled.
410 */
411 public final void unsuspendRedrawAll() {
412 ((SVGSVGElement)ot).unsuspendRedrawAll();
413 }
414 /**
415 * In rendering environments supporting interactivity, forces the user agent
416 * to immediately redraw all regions of the viewport that require updating.
417 */
418 public final void forceRedraw() {
419 ((SVGSVGElement)ot).forceRedraw();
420 }
421 /**
422 * Suspends (i.e., pauses) all currently running animations that are defined
423 * within the SVG document fragment corresponding to this <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
424 * title='svg element specification'>svg</a> element, causing the animation
425 * clock corresponding to this document fragment to stand still until it is
426 * unpaused.
427 */
428 public final void pauseAnimations() {
429 ((SVGSVGElement)ot).pauseAnimations();
430 }
431 /**
432 * Unsuspends (i.e., unpauses) currently running animations that are defined
433 * within the SVG document fragment, causing the animation clock to continue
434 * from the time at which it was suspended.
435 */
436 public final void unpauseAnimations() {
437 ((SVGSVGElement)ot).unpauseAnimations();
438 }
439 /**
440 * Returns true if this SVG document fragment is in a paused state.
441 * @return Boolean indicating whether this SVG document fragment is in a
442 * paused state.
443 */
444 public final boolean animationsPaused() {
445 return ((SVGSVGElement)ot).animationsPaused();
446 }
447 /**
448 * Returns the current time in seconds relative to the start time for the
449 * current SVG document fragment. If <span class="dom-method-name">getCurrentTime</span>
450 * is called before the document timeline has begun (for example, by script
451 * running in a <a href='http://www.w3.org/TR/SVG11/script.html#ScriptElement'
452 * title='script element specification'>script</a> element before the document's
453 * <a href="interact.html#LoadEvent">SVGLoad</a> event is dispatched), then
454 * 0 is returned.
455 * @return The current time in seconds, or 0 if the document timeline has
456 * not yet begun.
457 */
458 public final float getCurrentTime() {
459 return ((SVGSVGElement)ot).getCurrentTime();
460 }
461 /**
462 * Adjusts the clock for this SVG document fragment, establishing a new current
463 * time. If <span class="dom-method-name">setCurrentTime</span> is called
464 * before the document timeline has begun (for example, by script running
465 * in a <a href='http://www.w3.org/TR/SVG11/script.html#ScriptElement' title='script
466 * element specification'>script</a> element before the document's <a href="interact.html#LoadEvent">SVGLoad</a>
467 * event is dispatched), then the value of <var>seconds</var> in the last
468 * invocation of the method gives the time that the document will seek to
469 * once the document timeline has begun.
470 * @param seconds The new current time in seconds relative to the start
471 * time for the current SVG document fragment.
472 */
473 public final void setCurrentTime(float seconds) {
474 ((SVGSVGElement)ot).setCurrentTime(seconds);
475 }
476 /**
477 * Returns the list of graphics elements whose rendered content intersects
478 * the supplied rectangle. Each candidate graphics element is to be considered
479 * a match only if the same graphics element can be a <a href="interact.html#PointerEventsProperty">target
480 * of pointer events</a> as defined in <code>pointer-events</code> processing.
481 * @param rect The test rectangle. The values are in the <code>initial coordinate
482 * system</code> for the current <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
483 * title='svg element specification'>svg</a> element.
484 * @param referenceElement If not null, then any intersected element that
485 * doesn't have the referenceElement as ancestor must not be included in
486 * the returned NodeList.
487 * @return A list of Elements whose content intersects the supplied rectangle.
488 * This {@link com.google.gwt.dom.client.NodeList} must be implemented identically
489 * to the {@link com.google.gwt.dom.client.NodeList} interface as defined
490 * in DOM Level 2 Core ([<a href="refs.html#ref-DOM2">DOM2</a>], section
491 * 1.2) with the exception that the interface is not <a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#td-live">live</a>.
492 */
493 public final NodeList<? extends Node> getIntersectionList(OMSVGRect rect, OMSVGElement referenceElement) {
494 return ((SVGSVGElement)ot).getIntersectionList(rect, ((SVGElement)referenceElement.ot));
495 }
496 /**
497 * Returns the list of graphics elements whose rendered content is entirely
498 * contained within the supplied rectangle. Each candidate graphics element
499 * is to be considered a match only if the same graphics element can be a
500 * <a href="interact.html#PointerEventsProperty">target of pointer events</a>
501 * as defined in <code>pointer-events</code> processing.
502 * @param rect The test rectangle. The values are in the <code>initial coordinate
503 * system</code> for the current <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
504 * title='svg element specification'>svg</a> element.
505 * @param referenceElement If not null, then any intersected element that
506 * doesn't have the referenceElement as ancestor must not be included in
507 * the returned NodeList.
508 * @return A list of Elements whose content is enclosed by the supplied
509 * rectangle. This {@link com.google.gwt.dom.client.NodeList} must be implemented
510 * identically to the {@link com.google.gwt.dom.client.NodeList} interface
511 * as defined in DOM Level 2 Core ([<a href="refs.html#ref-DOM2">DOM2</a>],
512 * section 1.2) with the exception that the interface is not <a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#td-live">live</a>.
513 */
514 public final NodeList<? extends Node> getEnclosureList(OMSVGRect rect, OMSVGElement referenceElement) {
515 return ((SVGSVGElement)ot).getEnclosureList(rect, ((SVGElement)referenceElement.ot));
516 }
517 /**
518 * Returns true if the rendered content of the given element intersects the
519 * supplied rectangle. Each candidate graphics element is to be considered
520 * a match only if the same graphics element can be a <a href="interact.html#PointerEventsProperty">target
521 * of pointer events</a> as defined in <code>pointer-events</code> processing.
522 * @param element The element on which to perform the given test.
523 * @param rect The test rectangle. The values are in the <code>initial coordinate
524 * system</code> for the current <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
525 * title='svg element specification'>svg</a> element.
526 * @return True or false, depending on whether the given element intersects
527 * the supplied rectangle.
528 */
529 public final boolean checkIntersection(OMSVGElement element, OMSVGRect rect) {
530 return ((SVGSVGElement)ot).checkIntersection(((SVGElement)element.ot), rect);
531 }
532 /**
533 * Returns true if the rendered content of the given element is entirely contained
534 * within the supplied rectangle. Each candidate graphics element is to be
535 * considered a match only if the same graphics element can be a <a href="interact.html#PointerEventsProperty">target
536 * of pointer events</a> as defined in <code>pointer-events</code> processing.
537 * @param element The element on which to perform the given test.
538 * @param rect The test rectangle. The values are in the <code>initial coordinate
539 * system</code> for the current <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
540 * title='svg element specification'>svg</a> element.
541 * @return True or false, depending on whether the given element is enclosed
542 * by the supplied rectangle.
543 */
544 public final boolean checkEnclosure(OMSVGElement element, OMSVGRect rect) {
545 return ((SVGSVGElement)ot).checkEnclosure(((SVGElement)element.ot), rect);
546 }
547 /**
548 * Unselects any selected objects, including any selections of text strings
549 * and type-in bars.
550 */
551 public final void deselectAll() {
552 ((SVGSVGElement)ot).deselectAll();
553 }
554 /**
555 * Creates an {@link org.vectomatic.dom.svg.OMSVGNumber} object outside of
556 * any document trees. The object is initialized to a value of zero.
557 * @return An {@link org.vectomatic.dom.svg.OMSVGNumber} object.
558 */
559 public final OMSVGNumber createSVGNumber() {
560 return ((SVGSVGElement)ot).createSVGNumber();
561 }
562 /**
563 * Creates an {@link org.vectomatic.dom.svg.OMSVGLength} object outside of
564 * any document trees. The object is initialized to the value of 0 user units.
565 * @return An {@link org.vectomatic.dom.svg.OMSVGLength} object.
566 */
567 public final OMSVGLength createSVGLength() {
568 return ((SVGSVGElement)ot).createSVGLength();
569 }
570 /**
571 * Creates an {@link org.vectomatic.dom.svg.OMSVGAngle} object outside of
572 * any document trees. The object is initialized to the value 0 degrees (unitless).
573 * @return An {@link org.vectomatic.dom.svg.OMSVGAngle} object.
574 */
575 public final OMSVGAngle createSVGAngle() {
576 return ((SVGSVGElement)ot).createSVGAngle();
577 }
578 /**
579 * Creates an {@link org.vectomatic.dom.svg.OMSVGPoint} object outside of
580 * any document trees. The object is initialized to the point (0,0) in the
581 * user coordinate system.
582 * @return An {@link org.vectomatic.dom.svg.OMSVGPoint} object.
583 */
584 public final OMSVGPoint createSVGPoint() {
585 return ((SVGSVGElement)ot).createSVGPoint();
586 }
587 /**
588 * Creates an {@link org.vectomatic.dom.svg.OMSVGMatrix} object outside of
589 * any document trees. The object is initialized to the identity matrix.
590 * @return An {@link org.vectomatic.dom.svg.OMSVGMatrix} object.
591 */
592 public final OMSVGMatrix createSVGMatrix() {
593 return ((SVGSVGElement)ot).createSVGMatrix();
594 }
595 /**
596 * Creates an {@link org.vectomatic.dom.svg.OMSVGRect} object outside of any
597 * document trees. The object is initialized such that all values are set
598 * to 0 user units.
599 * @return An {@link org.vectomatic.dom.svg.OMSVGRect} object.
600 */
601 public final OMSVGRect createSVGRect() {
602 return ((SVGSVGElement)ot).createSVGRect();
603 }
604 /**
605 * Creates an {@link org.vectomatic.dom.svg.OMSVGTransform} object outside
606 * of any document trees. The object is initialized to an identity matrix
607 * transform (SVG_TRANSFORM_MATRIX).
608 * @return An {@link org.vectomatic.dom.svg.OMSVGTransform} object.
609 */
610 public final OMSVGTransform createSVGTransform() {
611 return ((SVGSVGElement)ot).createSVGTransform();
612 }
613 /**
614 * <p xmlns:edit="http://xmlns.grorg.org/SVGT12NG/"> Creates an {@link org.vectomatic.dom.svg.OMSVGTransform}
615 * object outside of any document trees. The object is initialized to the
616 * given matrix transform (i.e., SVG_TRANSFORM_MATRIX). The values from the
617 * parameter <var>matrix</var> are copied, the <var>matrix</var> parameter
618 * is not adopted as <a edit:format="expanded">SVGTransform::matrix</a>. </p>
619 * @param matrix The transform matrix.
620 * @return An {@link org.vectomatic.dom.svg.OMSVGTransform} object.
621 */
622 public final OMSVGTransform createSVGTransformFromMatrix(OMSVGMatrix matrix) {
623 return ((SVGSVGElement)ot).createSVGTransformFromMatrix(matrix);
624 }
625 /**
626 * Searches this SVG document fragment (i.e., the search is restricted to
627 * a subset of the document tree) for an Element whose id is given by <var>elementId</var>.
628 * If an Element is found, that Element is returned. If no such element exists,
629 * returns null. Behavior is not defined if more than one element has this
630 * id.
631 * @param elementId The unique id value for an element.
632 * @return The matching element.
633 */
634 public final OMElement getElementById(String elementId) {
635 Element elt = ((SVGSVGElement)ot).getElementById(elementId);
636 return elt != null ? (OMElement) convert(elt) : null;
637 }
638
639 // Implementation of the svg::SVGExternalResourcesRequired W3C IDL interface
640 /**
641 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired#getExternalResourcesRequired()}
642 * on the given element. Note that the SVG DOM defines the attribute {@link
643 * org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired#getExternalResourcesRequired()}
644 * as being of type {@link org.vectomatic.dom.svg.OMSVGAnimatedBoolean}, whereas
645 * the SVG language definition says that {@link org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired#getExternalResourcesRequired()}
646 * is not animated. Because the SVG language definition states that {@link
647 * org.vectomatic.dom.svg.itf.ISVGExternalResourcesRequired#getExternalResourcesRequired()}
648 * cannot be animated, the {@link org.vectomatic.dom.svg.OMSVGAnimatedBoolean#getAnimVal()}
649 * will always be the same as the {@link org.vectomatic.dom.svg.OMSVGAnimatedBoolean#getBaseVal()}.
650 */
651 public final OMSVGAnimatedBoolean getExternalResourcesRequired() {
652 return ((SVGSVGElement)ot).getExternalResourcesRequired();
653 }
654
655 // Implementation of the svg::SVGFitToViewBox W3C IDL interface
656 /**
657 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGFitToViewBox#getViewBox()}
658 * on the given element.
659 */
660 public final OMSVGAnimatedRect getViewBox() {
661 return ((SVGSVGElement)ot).getViewBox();
662 }
663 /**
664 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGFitToViewBox#getPreserveAspectRatio()}
665 * on the given element.
666 */
667 public final OMSVGAnimatedPreserveAspectRatio getPreserveAspectRatio() {
668 return ((SVGSVGElement)ot).getPreserveAspectRatio();
669 }
670
671 // Implementation of the svg::SVGLangSpace W3C IDL interface
672 /**
673 * Corresponds to attribute <code>xml:lang</code> on the given element.
674 */
675 public final String getXmllang() {
676 return ((SVGSVGElement)ot).getXmllang();
677 }
678 /**
679 * Corresponds to attribute <code>xml:lang</code> on the given element.
680 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised on an attempt
681 * to change the value of a <a href="svgdom.html#ReadOnlyNodes">read only
682 * attribute</a>.
683 */
684 public final void setXmllang(java.lang.String value) throws JavaScriptException {
685 ((SVGSVGElement)ot).setXmllang(value);
686 }
687 /**
688 * Corresponds to attribute <code>xml:space</code> on the given element.
689 */
690 public final String getXmlspace() {
691 return ((SVGSVGElement)ot).getXmlspace();
692 }
693 /**
694 * Corresponds to attribute <code>xml:space</code> on the given element.
695 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised on an attempt
696 * to change the value of a <a href="svgdom.html#ReadOnlyNodes">read only
697 * attribute</a>.
698 */
699 public final void setXmlspace(java.lang.String value) throws JavaScriptException {
700 ((SVGSVGElement)ot).setXmlspace(value);
701 }
702
703 // Implementation of the svg::SVGLocatable W3C IDL interface
704 /**
705 * The element which established the current viewport. Often, the nearest
706 * ancestor <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement' title='svg
707 * element specification'>svg</a> element. Null if the current element is
708 * the outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
709 * title='svg element specification'>svg</a> element.
710 */
711 public final OMSVGElement getNearestViewportElement() {
712 SVGElement elt = ((SVGSVGElement)ot).getNearestViewportElement();
713 return elt != null ? (OMSVGElement)convert(elt) : null;
714 }
715 /**
716 * The farthest ancestor <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
717 * title='svg element specification'>svg</a> element. Null if the current
718 * element is the outermost <a href='http://www.w3.org/TR/SVG11/struct.html#SVGElement'
719 * title='svg element specification'>svg</a> element.
720 */
721 public final OMSVGElement getFarthestViewportElement() {
722 SVGElement elt = ((SVGSVGElement)ot).getFarthestViewportElement();
723 return elt != null ? (OMSVGElement)convert(elt) : null;
724 }
725 /**
726 * Returns the tight bounding box in current user space (i.e., after application
727 * of the <code>transform</code> attribute, if any) on the geometry of all
728 * contained graphics elements, exclusive of stroking, clipping, masking and
729 * filter effects). Note that getBBox must return the actual bounding box
730 * at the time the method was called, even in case the element has not yet
731 * been rendered.
732 * @return An {@link org.vectomatic.dom.svg.OMSVGRect} object that defines
733 * the bounding box.
734 */
735 public final OMSVGRect getBBox() {
736 return ((SVGSVGElement)ot).getBBox();
737 }
738 /**
739 * Returns the transformation matrix from current user units (i.e., after
740 * application of the <code>transform</code> attribute, if any) to the viewport
741 * coordinate system for the {@link org.vectomatic.dom.svg.itf.ISVGLocatable#getNearestViewportElement()}.
742 * @return An {@link org.vectomatic.dom.svg.OMSVGMatrix} object that defines
743 * the CTM.
744 */
745 public final OMSVGMatrix getCTM() {
746 return ((SVGSVGElement)ot).getCTM();
747 }
748 /**
749 * Returns the transformation matrix from current user units (i.e., after
750 * application of the <code>transform</code> attribute, if any) to the parent
751 * user agent's notice of a "pixel". For display devices, ideally this represents
752 * a physical screen pixel. For other devices or environments where physical
753 * pixel sizes are not known, then an algorithm similar to the CSS2 definition
754 * of a "pixel" can be used instead. Note that null is returned if this element
755 * is not hooked into the document tree. This method would have been more
756 * aptly named as <code>getClientCTM</code>, but the name <code>getScreenCTM</code>
757 * is kept for historical reasons.
758 * @return An {@link org.vectomatic.dom.svg.OMSVGMatrix} object that defines
759 * the given transformation matrix.
760 */
761 public final OMSVGMatrix getScreenCTM() {
762 return ((SVGSVGElement)ot).getScreenCTM();
763 }
764 /**
765 * Returns the transformation matrix from the user coordinate system on the
766 * current element (after application of the <code>transform</code> attribute,
767 * if any) to the user coordinate system on parameter <var>element</var> (after
768 * application of its <code>transform</code> attribute, if any).
769 * @param element The target element.
770 * @return An {@link org.vectomatic.dom.svg.OMSVGMatrix} object that defines
771 * the transformation.
772 * @throws SVGException(SVG_MATRIX_NOT_INVERTABLE) Raised if the currently
773 * defined transformation matrices make it impossible to compute the given
774 * matrix (e.g., because one of the transformations is singular).
775 */
776 public final OMSVGMatrix getTransformToElement(OMSVGElement element) throws JavaScriptException {
777 return ((SVGSVGElement)ot).getTransformToElement(((SVGElement)element.ot));
778 }
779
780 // Implementation of the svg::SVGTests W3C IDL interface
781 /**
782 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGTests#getRequiredFeatures()}
783 * on the given element.
784 */
785 public final OMSVGStringList getRequiredFeatures() {
786 return ((SVGSVGElement)ot).getRequiredFeatures();
787 }
788 /**
789 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGTests#getRequiredExtensions()}
790 * on the given element.
791 */
792 public final OMSVGStringList getRequiredExtensions() {
793 return ((SVGSVGElement)ot).getRequiredExtensions();
794 }
795 /**
796 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGTests#getSystemLanguage()}
797 * on the given element.
798 */
799 public final OMSVGStringList getSystemLanguage() {
800 return ((SVGSVGElement)ot).getSystemLanguage();
801 }
802 /**
803 * Returns true if the user agent supports the given extension, specified
804 * by a URI.
805 * @param extension The name of the extension, expressed as a URI.
806 * @return True or false, depending on whether the given extension is supported.
807 */
808 public final boolean hasExtension(String extension) {
809 return ((SVGSVGElement)ot).hasExtension(extension);
810 }
811
812 // Implementation of the svg::SVGZoomAndPan W3C IDL interface
813 /**
814 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGZoomAndPan#getZoomAndPan()}
815 * on the given element. The value must be one of the SVG_ZOOMANDPAN_ constants
816 * defined on this interface.
817 */
818 public final short getZoomAndPan() {
819 return ((SVGSVGElement)ot).getZoomAndPan();
820 }
821 /**
822 * Corresponds to attribute {@link org.vectomatic.dom.svg.itf.ISVGZoomAndPan#getZoomAndPan()}
823 * on the given element. The value must be one of the SVG_ZOOMANDPAN_ constants
824 * defined on this interface.
825 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) Raised on an attempt
826 * to change the value of a <a href="svgdom.html#ReadOnlyNodes">read only
827 * attribute</a>.
828 */
829 public final void setZoomAndPan(short value) throws JavaScriptException {
830 ((SVGSVGElement)ot).setZoomAndPan(value);
831 }
832
833 @Override
834 public final HandlerRegistration addClickHandler(ClickHandler handler) {
835 return addDomHandler(handler, ClickEvent.getType());
836 }
837 @Override
838 public final HandlerRegistration addDragEndHandler(DragEndHandler handler) {
839 return addDomHandler(handler, DragEndEvent.getType());
840 }
841 @Override
842 public final HandlerRegistration addDragEnterHandler(DragEnterHandler handler) {
843 return addDomHandler(handler, DragEnterEvent.getType());
844 }
845 @Override
846 public final HandlerRegistration addDragHandler(DragHandler handler) {
847 return addDomHandler(handler, DragEvent.getType());
848 }
849 @Override
850 public final HandlerRegistration addDragLeaveHandler(DragLeaveHandler handler) {
851 return addDomHandler(handler, DragLeaveEvent.getType());
852 }
853 @Override
854 public final HandlerRegistration addDragOverHandler(DragOverHandler handler) {
855 return addDomHandler(handler, DragOverEvent.getType());
856 }
857 @Override
858 public final HandlerRegistration addDragStartHandler(DragStartHandler handler) {
859 return addDomHandler(handler, DragStartEvent.getType());
860 }
861 @Override
862 public final HandlerRegistration addDropHandler(DropHandler handler) {
863 return addDomHandler(handler, DropEvent.getType());
864 }
865 @Override
866 public final HandlerRegistration addLoadHandler(LoadHandler handler) {
867 return addDomHandler(handler, LoadEvent.getType());
868 }
869 @Override
870 public final HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
871 return addDomHandler(handler, MouseDownEvent.getType());
872 }
873 @Override
874 public final HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler) {
875 return addDomHandler(handler, MouseMoveEvent.getType());
876 }
877 @Override
878 public final HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
879 return addDomHandler(handler, MouseOutEvent.getType());
880 }
881 @Override
882 public final HandlerRegistration addMouseOverHandler(MouseOverHandler handler) {
883 return addDomHandler(handler, MouseOverEvent.getType());
884 }
885 @Override
886 public final HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
887 return addDomHandler(handler, MouseUpEvent.getType());
888 }
889 @Override
890 public final HandlerRegistration addScrollHandler(ScrollHandler handler) {
891 return addDomHandler(handler, ScrollEvent.getType());
892 }
893 @Override
894 public final HandlerRegistration addTouchCancelHandler(TouchCancelHandler handler) {
895 return addDomHandler(handler, TouchCancelEvent.getType());
896 }
897 @Override
898 public final HandlerRegistration addTouchEndHandler(TouchEndHandler handler) {
899 return addDomHandler(handler, TouchEndEvent.getType());
900 }
901 @Override
902 public final HandlerRegistration addTouchMoveHandler(TouchMoveHandler handler) {
903 return addDomHandler(handler, TouchMoveEvent.getType());
904 }
905 @Override
906 public final HandlerRegistration addTouchStartHandler(TouchStartHandler handler) {
907 return addDomHandler(handler, TouchStartEvent.getType());
908 }
909 @Override
910 public final HandlerRegistration addResizeHandler(ResizeHandler handler) {
911 return addHandler(handler, ResizeEvent.getType());
912 }
913 @Override
914 public final HandlerRegistration addActivateHandler(ActivateHandler handler) {
915 return addDomHandler(handler, ActivateEvent.getType());
916 }
917 @Override
918 public final HandlerRegistration addFocusInHandler(FocusInHandler handler) {
919 return addDomHandler(handler, FocusInEvent.getType());
920 }
921 @Override
922 public final HandlerRegistration addFocusOutHandler(FocusOutHandler handler) {
923 return addDomHandler(handler, FocusOutEvent.getType());
924 }
925 @Override
926 public final HandlerRegistration addSVGZoomHandler(SVGZoomHandler handler) {
927 return addDomHandler(handler, SVGZoomEvent.getType());
928 }
929 // Helper methods
930 /**
931 * Creates an {@link org.vectomatic.dom.svg.OMSVGNumber} object outside of
932 * any document trees. The object is initialized to the specified value.
933 * @param value the value to use for initialization
934 * @return An {@link org.vectomatic.dom.svg.OMSVGNumber} object.
935 */
936 public final OMSVGNumber createSVGNumber(float value) {
937 OMSVGNumber number = createSVGNumber();
938 number.setValue(value);
939 return number;
940 }
941 /**
942 * Creates an {@link org.vectomatic.dom.svg.OMSVGLength} object outside of
943 * any document trees. The object is initialized to the specified value
944 * and unit type.
945 * @param unitType the unit type to use for initialization
946 * @param valueInSpecifiedUnits the value to use for initialization, in the specified units
947 * @return An {@link org.vectomatic.dom.svg.OMSVGLength} object.
948 */
949 public final OMSVGLength createSVGLength(short unitType, float valueInSpecifiedUnits) {
950 OMSVGLength length = ((SVGSVGElement)ot).createSVGLength();
951 length.newValueSpecifiedUnits(unitType, valueInSpecifiedUnits);
952 return length;
953 }
954 /**
955 * Creates an {@link org.vectomatic.dom.svg.OMSVGLength} object outside of
956 * any document trees. The object is initialized to the specified value
957 * and unit type.
958 * @param unitType the unit type to use for initialization
959 * @param valueInSpecifiedUnits the value to use for initialization, in the specified units
960 * @return An {@link org.vectomatic.dom.svg.OMSVGLength} object.
961 */
962 public final OMSVGLength createSVGLength(Style.Unit unitType, float valueInSpecifiedUnits) {
963 return createSVGLength(OMSVGLength.unitToCode(unitType), valueInSpecifiedUnits);
964 }
965 /**
966 * Creates an {@link org.vectomatic.dom.svg.OMSVGLength} object outside of
967 * any document trees. The object is initialized to the specified length.
968 * @param l the length to use for initialization
969 * @return An {@link org.vectomatic.dom.svg.OMSVGLength} object.
970 */
971 public final OMSVGLength createSVGLength(OMSVGLength l) {
972 return createSVGLength(l.getUnitType(), l.getValueInSpecifiedUnits());
973 }
974 /**
975 * Creates an {@link org.vectomatic.dom.svg.OMSVGAngle} object outside of
976 * any document trees. The object is initialized to the specified value
977 * and unit type.
978 * @param unitType the unit type to use for initialization
979 * @param valueInSpecifiedUnits the value to use for initialization, in the specified units
980 * @return An {@link org.vectomatic.dom.svg.OMSVGAngle} object.
981 */
982 public final OMSVGAngle createSVGAngle(short unitType, float valueInSpecifiedUnits) {
983 OMSVGAngle angle = ((SVGSVGElement)ot).createSVGAngle();
984 angle.newValueSpecifiedUnits(unitType, valueInSpecifiedUnits);
985 return angle;
986 }
987 /**
988 * Creates an {@link org.vectomatic.dom.svg.OMSVGAngle} object outside of
989 * any document trees. The object is initialized to the specified angle.
990 * @param a the angle to use for initialization
991 * @return An {@link org.vectomatic.dom.svg.OMSVGAngle} object.
992 */
993 public final OMSVGAngle createSVGAngle(OMSVGAngle a) {
994 return createSVGAngle(a.getUnitType(), a.getValueInSpecifiedUnits());
995 }
996 /**
997 * Creates an {@link org.vectomatic.dom.svg.OMSVGPoint} object outside of
998 * any document trees. The object is initialized to the specified coordinates.
999 * @param x the X coordinate to use for initialization
1000 * @param y the Y coordinate to use for initialization
1001 * @return An {@link org.vectomatic.dom.svg.OMSVGPoint} object.
1002 */
1003 public final OMSVGPoint createSVGPoint(float x, float y) {
1004 OMSVGPoint point = ((SVGSVGElement)ot).createSVGPoint();
1005 point.setX(x);
1006 point.setY(y);
1007 return point;
1008 }
1009 /**
1010 * Creates an {@link org.vectomatic.dom.svg.OMSVGPoint} object outside of
1011 * any document trees. The object is initialized to the specified point.
1012 * @param p the point to use for initialization
1013 * @return An {@link org.vectomatic.dom.svg.OMSVGPoint} object.
1014 */
1015 public final OMSVGPoint createSVGPoint(OMSVGPoint p) {
1016 return createSVGPoint(p.getX(), p.getY());
1017 }
1018 /**
1019 * Creates an {@link org.vectomatic.dom.svg.OMSVGMatrix} object outside of
1020 * any document trees. The object is initialized to the specified components.
1021 * @param a the A component to use for initialization
1022 * @param b the B component to use for initialization
1023 * @param c the C component to use for initialization
1024 * @param d the D component to use for initialization
1025 * @param e the E component to use for initialization
1026 * @param f the F component to use for initialization
1027 * @return An {@link org.vectomatic.dom.svg.OMSVGMatrix} object.
1028 */
1029 public final OMSVGMatrix createSVGMatrix(float a, float b, float c, float d, float e, float f) {
1030 OMSVGMatrix matrix = ((SVGSVGElement)ot).createSVGMatrix();
1031 matrix.setA(a);
1032 matrix.setB(b);
1033 matrix.setC(c);
1034 matrix.setD(d);
1035 matrix.setE(e);
1036 matrix.setF(f);
1037 return matrix;
1038 }
1039 /**
1040 * Creates an {@link org.vectomatic.dom.svg.OMSVGMatrix} object outside of
1041 * any document trees. The object is initialized to the specified matrix.
1042 * @param m the matrix to use for initialization
1043 * @return An {@link org.vectomatic.dom.svg.OMSVGMatrix} object.
1044 */
1045 public final OMSVGMatrix createSVGMatrix(OMSVGMatrix m) {
1046 return createSVGMatrix(m.getA(), m.getB(), m.getC(), m.getD(), m.getE(), m.getF());
1047 }
1048 /**
1049 * Creates an {@link org.vectomatic.dom.svg.OMSVGRect} object outside of
1050 * any document trees. The object is initialized to the specified coordinates
1051 * and size.
1052 * @param x the X coordinate to use for initialization
1053 * @param y the Y coordinate to use for initialization
1054 * @param width the width to use for initialization
1055 * @param height the height to use for initialization
1056 * @return An {@link org.vectomatic.dom.svg.OMSVGRect} object.
1057 */
1058 public final OMSVGRect createSVGRect(float x, float y, float width, float height) {
1059 OMSVGRect rect = ((SVGSVGElement)ot).createSVGRect();
1060 rect.setX(x);
1061 rect.setY(y);
1062 rect.setWidth(width);
1063 rect.setHeight(height);
1064 return rect;
1065 }
1066 /**
1067 * Creates an {@link org.vectomatic.dom.svg.OMSVGRect} object outside of
1068 * any document trees. The object is initialized to the specified rectangle.
1069 * @param rect the rect to use for initialization
1070 * @return An {@link org.vectomatic.dom.svg.OMSVGRect} object.
1071 */
1072 public final OMSVGRect createSVGRect(OMSVGRect rect) {
1073 return createSVGRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
1074 }
1075 /**
1076 * Sets the base value for the height of this {@link org.vectomatic.dom.svg.OMSVGSVGElement}
1077 * to the specified value and unit type.
1078 * @param unitType the unit type in which the height is specified
1079 * @param height the height in the specified units
1080 */
1081 public final void setHeight(short unitType, float height) {
1082 getHeight().getBaseVal().newValueSpecifiedUnits(unitType, height);
1083 }
1084 /**
1085 * Sets the base value for the height of this {@link org.vectomatic.dom.svg.OMSVGSVGElement}
1086 * to the specified value and unit type.
1087 * @param unitType the unit type in which the height is specified
1088 * @param height the height in the specified units
1089 */
1090 public final void setHeight(com.google.gwt.dom.client.Style.Unit unitType, float height) {
1091 getHeight().getBaseVal().newValueSpecifiedUnits(unitType, height);
1092 }
1093 /**
1094 * Sets the base value for the viewbox of this {@link org.vectomatic.dom.svg.OMSVGSVGElement}
1095 * to the specified rectangle.
1096 * @param rect the rectangle used to specify the viewbox
1097 */
1098 public final void setViewBox(OMSVGRect rect) {
1099 setViewBox(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
1100 }
1101 /**
1102 * Sets the base value for the viewbox of this {@link org.vectomatic.dom.svg.OMSVGSVGElement}
1103 * to the specified coordinates and size.
1104 * @param x the X coordinate to use for the viewbox
1105 * @param y the Y coordinate to use for the viewbox
1106 * @param width the width to use for the viewbox
1107 * @param height the height to use for the viewbox
1108 */
1109 public final void setViewBox(float x, float y, float width, float height) {
1110 if (!((SVGSVGElement)ot).hasAttribute(SVGConstants.SVG_VIEW_BOX_ATTRIBUTE)) {
1111 StringBuilder builder = new StringBuilder();
1112 builder.append(x);
1113 builder.append(" ");
1114 builder.append(y);
1115 builder.append(" ");
1116 builder.append(width);
1117 builder.append(" ");
1118 builder.append(height);
1119 ((SVGSVGElement)ot).setAttribute(SVGConstants.SVG_VIEW_BOX_ATTRIBUTE, builder.toString());
1120 return;
1121 }
1122 OMSVGRect viewBox = getViewBox().getBaseVal();
1123 viewBox.setX(x);
1124 viewBox.setY(y);
1125 viewBox.setWidth(width);
1126 viewBox.setHeight(height);
1127 }
1128 /**
1129 * Sets the base value for the width of this {@link org.vectomatic.dom.svg.OMSVGSVGElement}
1130 * to the specified value and unit type.
1131 * @param unitType the unit type in which the width is specified
1132 * @param width the width in the specified units
1133 */
1134 public final void setWidth(short unitType, float width) {
1135 getWidth().getBaseVal().newValueSpecifiedUnits(unitType, width);
1136 }
1137 /**
1138 * Sets the base value for the width of this {@link org.vectomatic.dom.svg.OMSVGSVGElement}
1139 * to the specified value and unit type.
1140 * @param unitType the unit type in which the width is specified
1141 * @param width the width in the specified units
1142 */
1143 public final void setWidth(com.google.gwt.dom.client.Style.Unit unitType, float width) {
1144 getWidth().getBaseVal().newValueSpecifiedUnits(unitType, width);
1145 }
1146 }