001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.dom.svg;
020:
021: import java.awt.geom.AffineTransform;
022: import java.util.List;
023:
024: import org.apache.batik.dom.AbstractDocument;
025: import org.apache.batik.dom.util.DoublyIndexedTable;
026: import org.apache.batik.dom.util.XLinkSupport;
027: import org.apache.batik.dom.util.XMLSupport;
028: import org.apache.batik.dom.util.ListNodeList;
029: import org.apache.batik.util.SVGTypes;
030:
031: import org.w3c.dom.DOMException;
032: import org.w3c.dom.Element;
033: import org.w3c.dom.Node;
034: import org.w3c.dom.NodeList;
035: import org.w3c.dom.css.CSSStyleDeclaration;
036: import org.w3c.dom.css.DocumentCSS;
037: import org.w3c.dom.css.ViewCSS;
038: import org.w3c.dom.events.DocumentEvent;
039: import org.w3c.dom.events.Event;
040: import org.w3c.dom.stylesheets.DocumentStyle;
041: import org.w3c.dom.stylesheets.StyleSheetList;
042: import org.w3c.dom.svg.SVGAngle;
043: import org.w3c.dom.svg.SVGAnimatedBoolean;
044: import org.w3c.dom.svg.SVGAnimatedLength;
045: import org.w3c.dom.svg.SVGAnimatedPreserveAspectRatio;
046: import org.w3c.dom.svg.SVGAnimatedRect;
047: import org.w3c.dom.svg.SVGElement;
048: import org.w3c.dom.svg.SVGException;
049: import org.w3c.dom.svg.SVGLength;
050: import org.w3c.dom.svg.SVGMatrix;
051: import org.w3c.dom.svg.SVGNumber;
052: import org.w3c.dom.svg.SVGPoint;
053: import org.w3c.dom.svg.SVGRect;
054: import org.w3c.dom.svg.SVGSVGElement;
055: import org.w3c.dom.svg.SVGStringList;
056: import org.w3c.dom.svg.SVGTransform;
057: import org.w3c.dom.svg.SVGViewSpec;
058: import org.w3c.dom.views.AbstractView;
059: import org.w3c.dom.views.DocumentView;
060:
061: /**
062: * This class implements {@link org.w3c.dom.svg.SVGSVGElement}.
063: *
064: * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
065: * @version $Id: SVGOMSVGElement.java 489964 2006-12-24 01:30:23Z cam $
066: */
067: public class SVGOMSVGElement extends SVGStylableElement implements
068: SVGSVGElement {
069:
070: /**
071: * Table mapping XML attribute names to TraitInformation objects.
072: */
073: protected static DoublyIndexedTable xmlTraitInformation;
074: static {
075: DoublyIndexedTable t = new DoublyIndexedTable(
076: SVGStylableElement.xmlTraitInformation);
077: t.put(null, SVG_X_ATTRIBUTE, new TraitInformation(true,
078: SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_WIDTH));
079: t.put(null, SVG_Y_ATTRIBUTE, new TraitInformation(true,
080: SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_HEIGHT));
081: t.put(null, SVG_WIDTH_ATTRIBUTE, new TraitInformation(true,
082: SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_WIDTH));
083: t.put(null, SVG_HEIGHT_ATTRIBUTE, new TraitInformation(true,
084: SVGTypes.TYPE_LENGTH, PERCENTAGE_VIEWPORT_HEIGHT));
085: // t.put(null, SVG_BASE_PROFILE_ATTRIBUTE,
086: // new TraitInformation(false, SVGTypes.TYPE_CDATA));
087: // t.put(null, SVG_CONTENT_SCRIPT_TYPE_ATTRIBUTE,
088: // new TraitInformation(false, SVGTypes.TYPE_CDATA));
089: // t.put(null, SVG_CONTENT_STYLE_TYPE_ATTRIBUTE,
090: // new TraitInformation(false, SVGTypes.TYPE_CDATA));
091: // t.put(null, SVG_VERSION_ATTRIBUTE,
092: // new TraitInformation(false, SVGTypes.TYPE_CDATA));
093: t.put(null, SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE,
094: new TraitInformation(true,
095: SVGTypes.TYPE_PRESERVE_ASPECT_RATIO_VALUE));
096: t.put(null, SVG_VIEW_BOX_ATTRIBUTE, new TraitInformation(true,
097: SVGTypes.TYPE_NUMBER_LIST));
098: t.put(null, SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE,
099: new TraitInformation(true, SVGTypes.TYPE_BOOLEAN));
100: xmlTraitInformation = t;
101: }
102:
103: /**
104: * The attribute initializer.
105: */
106: protected static final AttributeInitializer attributeInitializer;
107: static {
108: attributeInitializer = new AttributeInitializer(7);
109: attributeInitializer.addAttribute(
110: XMLSupport.XMLNS_NAMESPACE_URI, null, "xmlns",
111: SVG_NAMESPACE_URI);
112: attributeInitializer.addAttribute(
113: XMLSupport.XMLNS_NAMESPACE_URI, "xmlns", "xlink",
114: XLinkSupport.XLINK_NAMESPACE_URI);
115: attributeInitializer.addAttribute(null, null,
116: SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE, "xMidYMid meet");
117: attributeInitializer.addAttribute(null, null,
118: SVG_ZOOM_AND_PAN_ATTRIBUTE, SVG_MAGNIFY_VALUE);
119: attributeInitializer.addAttribute(null, null,
120: SVG_VERSION_ATTRIBUTE, SVG_VERSION);
121: attributeInitializer.addAttribute(null, null,
122: SVG_CONTENT_SCRIPT_TYPE_ATTRIBUTE, "text/ecmascript");
123: attributeInitializer.addAttribute(null, null,
124: SVG_CONTENT_STYLE_TYPE_ATTRIBUTE, "text/css");
125: }
126:
127: /**
128: * The 'x' attribute value.
129: */
130: protected SVGOMAnimatedLength x;
131:
132: /**
133: * The 'y' attribute value.
134: */
135: protected SVGOMAnimatedLength y;
136:
137: /**
138: * The 'width' attribute value.
139: */
140: protected SVGOMAnimatedLength width;
141:
142: /**
143: * The 'height' attribute value.
144: */
145: protected SVGOMAnimatedLength height;
146:
147: /**
148: * The 'externalResourcesRequired' attribute value.
149: */
150: protected SVGOMAnimatedBoolean externalResourcesRequired;
151:
152: /**
153: * The 'preserveAspectRatio' attribute value.
154: */
155: protected SVGOMAnimatedPreserveAspectRatio preserveAspectRatio;
156:
157: /**
158: * Creates a new SVGOMSVGElement object.
159: */
160: protected SVGOMSVGElement() {
161: }
162:
163: /**
164: * Creates a new SVGOMSVGElement object.
165: * @param prefix The namespace prefix.
166: * @param owner The owner document.
167: */
168: public SVGOMSVGElement(String prefix, AbstractDocument owner) {
169: super (prefix, owner);
170: initializeLiveAttributes();
171: }
172:
173: /**
174: * Initializes all live attributes for this element.
175: */
176: protected void initializeAllLiveAttributes() {
177: super .initializeAllLiveAttributes();
178: initializeLiveAttributes();
179: }
180:
181: /**
182: * Initializes the live attribute values of this element.
183: */
184: private void initializeLiveAttributes() {
185: x = createLiveAnimatedLength(null, SVG_X_ATTRIBUTE,
186: SVG_SVG_X_DEFAULT_VALUE,
187: SVGOMAnimatedLength.HORIZONTAL_LENGTH, false);
188: y = createLiveAnimatedLength(null, SVG_Y_ATTRIBUTE,
189: SVG_SVG_Y_DEFAULT_VALUE,
190: SVGOMAnimatedLength.VERTICAL_LENGTH, false);
191: width = createLiveAnimatedLength(null, SVG_WIDTH_ATTRIBUTE,
192: SVG_SVG_WIDTH_DEFAULT_VALUE,
193: SVGOMAnimatedLength.HORIZONTAL_LENGTH, true);
194: height = createLiveAnimatedLength(null, SVG_HEIGHT_ATTRIBUTE,
195: SVG_SVG_HEIGHT_DEFAULT_VALUE,
196: SVGOMAnimatedLength.VERTICAL_LENGTH, true);
197: externalResourcesRequired = createLiveAnimatedBoolean(null,
198: SVG_EXTERNAL_RESOURCES_REQUIRED_ATTRIBUTE, false);
199: preserveAspectRatio = createLiveAnimatedPreserveAspectRatio();
200: }
201:
202: /**
203: * <b>DOM</b>: Implements {@link Node#getLocalName()}.
204: */
205: public String getLocalName() {
206: return SVG_SVG_TAG;
207: }
208:
209: /**
210: * <b>DOM</b>: Implements {@link SVGSVGElement#getX()}.
211: */
212: public SVGAnimatedLength getX() {
213: return x;
214: }
215:
216: /**
217: * <b>DOM</b>: Implements {@link SVGSVGElement#getY()}.
218: */
219: public SVGAnimatedLength getY() {
220: return y;
221: }
222:
223: /**
224: * <b>DOM</b>: Implements {@link SVGSVGElement#getWidth()}.
225: */
226: public SVGAnimatedLength getWidth() {
227: return width;
228: }
229:
230: /**
231: * <b>DOM</b>: Implements {@link SVGSVGElement#getHeight()}.
232: */
233: public SVGAnimatedLength getHeight() {
234: return height;
235: }
236:
237: /**
238: * <b>DOM</b>: Implements {@link SVGSVGElement#getContentScriptType()}.
239: */
240: public String getContentScriptType() {
241: return getAttributeNS(null, SVG_CONTENT_SCRIPT_TYPE_ATTRIBUTE);
242: }
243:
244: /**
245: * <b>DOM</b>: Implements {@link SVGSVGElement#setContentScriptType(String)}.
246: */
247: public void setContentScriptType(String type) {
248: setAttributeNS(null, SVG_CONTENT_SCRIPT_TYPE_ATTRIBUTE, type);
249: }
250:
251: /**
252: * <b>DOM</b>: Implements {@link SVGSVGElement#getContentStyleType()}.
253: */
254: public String getContentStyleType() {
255: return getAttributeNS(null, SVG_CONTENT_STYLE_TYPE_ATTRIBUTE);
256: }
257:
258: /**
259: * <b>DOM</b>: Implements {@link SVGSVGElement#setContentStyleType(String)}.
260: */
261: public void setContentStyleType(String type) {
262: setAttributeNS(null, SVG_CONTENT_STYLE_TYPE_ATTRIBUTE, type);
263: }
264:
265: /**
266: * <b>DOM</b>: Implements {@link SVGSVGElement#getViewport()}.
267: */
268: public SVGRect getViewport() {
269: SVGContext ctx = getSVGContext();
270: return new SVGOMRect(0, 0, ctx.getViewportWidth(), ctx
271: .getViewportHeight());
272: }
273:
274: /**
275: * <b>DOM</b>: Implements {@link SVGSVGElement#getPixelUnitToMillimeterX()}.
276: */
277: public float getPixelUnitToMillimeterX() {
278: return getSVGContext().getPixelUnitToMillimeter();
279: }
280:
281: /**
282: * <b>DOM</b>: Implements {@link SVGSVGElement#getPixelUnitToMillimeterY()}.
283: */
284: public float getPixelUnitToMillimeterY() {
285: return getSVGContext().getPixelUnitToMillimeter();
286: }
287:
288: /**
289: * <b>DOM</b>: Implements {@link
290: * SVGSVGElement#getScreenPixelToMillimeterX()}.
291: */
292: public float getScreenPixelToMillimeterX() {
293: return getSVGContext().getPixelUnitToMillimeter();
294: }
295:
296: /**
297: * <b>DOM</b>: Implements {@link
298: * SVGSVGElement#getScreenPixelToMillimeterY()}.
299: */
300: public float getScreenPixelToMillimeterY() {
301: return getSVGContext().getPixelUnitToMillimeter();
302: }
303:
304: /**
305: * <b>DOM</b>: Implements {@link SVGSVGElement#getUseCurrentView()}.
306: */
307: public boolean getUseCurrentView() {
308: throw new UnsupportedOperationException(
309: "SVGSVGElement.getUseCurrentView is not implemented"); // XXX
310: }
311:
312: /**
313: * <b>DOM</b>: Implements {@link SVGSVGElement#setUseCurrentView(boolean)}.
314: */
315: public void setUseCurrentView(boolean useCurrentView)
316: throws DOMException {
317: throw new UnsupportedOperationException(
318: "SVGSVGElement.setUseCurrentView is not implemented"); // XXX
319: }
320:
321: /**
322: * <b>DOM</b>: Implements {@link SVGSVGElement#getCurrentView()}.
323: */
324: public SVGViewSpec getCurrentView() {
325: throw new UnsupportedOperationException(
326: "SVGSVGElement.getCurrentView is not implemented"); // XXX
327: }
328:
329: /**
330: * <b>DOM</b>: Implements {@link SVGSVGElement#getCurrentView()}.
331: */
332: public float getCurrentScale() {
333: AffineTransform scrnTrans = getSVGContext()
334: .getScreenTransform();
335: if (scrnTrans != null) {
336: return (float) Math.sqrt(scrnTrans.getDeterminant());
337: }
338: return 1;
339: }
340:
341: /**
342: * <b>DOM</b>: Implements {@link SVGSVGElement#setCurrentScale(float)}.
343: */
344: public void setCurrentScale(float currentScale) throws DOMException {
345: SVGContext context = getSVGContext();
346: AffineTransform scrnTrans = context.getScreenTransform();
347: float scale = 1;
348: if (scrnTrans != null) {
349: scale = (float) Math.sqrt(scrnTrans.getDeterminant());
350: }
351: float delta = currentScale / scale;
352: // The way currentScale, currentTranslate are defined
353: // changing scale has no effect on translate.
354: scrnTrans = new AffineTransform(scrnTrans.getScaleX() * delta,
355: scrnTrans.getShearY() * delta, scrnTrans.getShearX()
356: * delta, scrnTrans.getScaleY() * delta,
357: scrnTrans.getTranslateX(), scrnTrans.getTranslateY());
358: context.setScreenTransform(scrnTrans);
359: }
360:
361: /**
362: * <b>DOM</b>: Implements {@link SVGSVGElement#getCurrentTranslate()}.
363: */
364: public SVGPoint getCurrentTranslate() {
365: return new SVGPoint() {
366: protected AffineTransform getScreenTransform() {
367: SVGContext context = getSVGContext();
368: return context.getScreenTransform();
369: }
370:
371: public float getX() {
372: AffineTransform scrnTrans = getScreenTransform();
373: return (float) scrnTrans.getTranslateX();
374: }
375:
376: public float getY() {
377: AffineTransform scrnTrans = getScreenTransform();
378: return (float) scrnTrans.getTranslateY();
379: }
380:
381: public void setX(float newX) {
382: SVGContext context = getSVGContext();
383: AffineTransform scrnTrans = context
384: .getScreenTransform();
385: scrnTrans = new AffineTransform(scrnTrans.getScaleX(),
386: scrnTrans.getShearY(), scrnTrans.getShearX(),
387: scrnTrans.getScaleY(), newX, scrnTrans
388: .getTranslateY());
389: context.setScreenTransform(scrnTrans);
390: }
391:
392: public void setY(float newY) {
393: SVGContext context = getSVGContext();
394: AffineTransform scrnTrans = context
395: .getScreenTransform();
396: scrnTrans = new AffineTransform(scrnTrans.getScaleX(),
397: scrnTrans.getShearY(), scrnTrans.getShearX(),
398: scrnTrans.getScaleY(), scrnTrans
399: .getTranslateX(), newY);
400: context.setScreenTransform(scrnTrans);
401: }
402:
403: public SVGPoint matrixTransform(SVGMatrix mat) {
404: AffineTransform scrnTrans = getScreenTransform();
405: float x = (float) scrnTrans.getTranslateX();
406: float y = (float) scrnTrans.getTranslateY();
407: float newX = mat.getA() * x + mat.getC() * y
408: + mat.getE();
409: float newY = mat.getB() * x + mat.getD() * y
410: + mat.getF();
411: return new SVGOMPoint(newX, newY);
412: }
413: };
414: }
415:
416: /**
417: * <b>DOM</b>: Implements {@link SVGSVGElement#suspendRedraw(int)}.
418: */
419: public int suspendRedraw(int max_wait_milliseconds) {
420: if (max_wait_milliseconds > 60000) {
421: max_wait_milliseconds = 60000;
422: } else if (max_wait_milliseconds < 0) {
423: max_wait_milliseconds = 0;
424: }
425: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
426: return ctx.suspendRedraw(max_wait_milliseconds);
427: }
428:
429: /**
430: * <b>DOM</b>: Implements {@link SVGSVGElement#unsuspendRedraw(int)}.
431: */
432: public void unsuspendRedraw(int suspend_handle_id)
433: throws DOMException {
434: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
435: if (!ctx.unsuspendRedraw(suspend_handle_id)) {
436: throw createDOMException(DOMException.NOT_FOUND_ERR,
437: "invalid.suspend.handle",
438: new Object[] { new Integer(suspend_handle_id) });
439: }
440: }
441:
442: /**
443: * <b>DOM</b>: Implements {@link SVGSVGElement#unsuspendRedrawAll()}.
444: */
445: public void unsuspendRedrawAll() {
446: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
447: ctx.unsuspendRedrawAll();
448: }
449:
450: /**
451: * <b>DOM</b>: Implements {@link SVGSVGElement#forceRedraw()}.
452: */
453: public void forceRedraw() {
454: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
455: ctx.forceRedraw();
456: }
457:
458: /**
459: * <b>DOM</b>: Implements {@link SVGSVGElement#pauseAnimations()}.
460: */
461: public void pauseAnimations() {
462: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
463: ctx.pauseAnimations();
464: }
465:
466: /**
467: * <b>DOM</b>: Implements {@link SVGSVGElement#unpauseAnimations()}.
468: */
469: public void unpauseAnimations() {
470: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
471: ctx.unpauseAnimations();
472: }
473:
474: /**
475: * <b>DOM</b>: Implements {@link SVGSVGElement#animationsPaused()}.
476: */
477: public boolean animationsPaused() {
478: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
479: return ctx.animationsPaused();
480: }
481:
482: /**
483: * <b>DOM</b>: Implements {@link SVGSVGElement#getCurrentTime()}.
484: */
485: public float getCurrentTime() {
486: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
487: return ctx.getCurrentTime();
488: }
489:
490: /**
491: * <b>DOM</b>: Implements {@link SVGSVGElement#setCurrentTime(float)}.
492: */
493: public void setCurrentTime(float seconds) {
494: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
495: ctx.setCurrentTime(seconds);
496: }
497:
498: /**
499: * <b>DOM</b>: Implements {@link
500: * SVGSVGElement#getIntersectionList(SVGRect,SVGElement)}.
501: */
502: public NodeList getIntersectionList(SVGRect rect,
503: SVGElement referenceElement) {
504: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
505: List list = ctx.getIntersectionList(rect, referenceElement);
506: return new ListNodeList(list);
507: }
508:
509: /**
510: * <b>DOM</b>: Implements {@link
511: * SVGSVGElement#getEnclosureList(SVGRect,SVGElement)}.
512: */
513: public NodeList getEnclosureList(SVGRect rect,
514: SVGElement referenceElement) {
515: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
516: List list = ctx.getEnclosureList(rect, referenceElement);
517: return new ListNodeList(list);
518: }
519:
520: /**
521: * <b>DOM</b>: Implements {@link
522: * SVGSVGElement#checkIntersection(SVGElement,SVGRect)}.
523: */
524: public boolean checkIntersection(SVGElement element, SVGRect rect) {
525: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
526: return ctx.checkIntersection(element, rect);
527: }
528:
529: /**
530: * <b>DOM</b>: Implements {@link
531: * SVGSVGElement#checkEnclosure(SVGElement,SVGRect)}.
532: */
533: public boolean checkEnclosure(SVGElement element, SVGRect rect) {
534: SVGSVGContext ctx = (SVGSVGContext) getSVGContext();
535: return ctx.checkEnclosure(element, rect);
536: }
537:
538: /**
539: * <b>DOM</b>: Implements {@link SVGSVGElement#deselectAll()}.
540: */
541: public void deselectAll() {
542: ((SVGSVGContext) getSVGContext()).deselectAll();
543: }
544:
545: /**
546: * <b>DOM</b>: Implements {@link SVGSVGElement#createSVGNumber()}.
547: */
548: public SVGNumber createSVGNumber() {
549: return new SVGNumber() {
550: protected float value;
551:
552: public float getValue() {
553: return value;
554: }
555:
556: public void setValue(float f) {
557: value = f;
558: }
559: };
560: }
561:
562: /**
563: * <b>DOM</b>: Implements {@link SVGSVGElement#createSVGLength()}.
564: */
565: public SVGLength createSVGLength() {
566: return new SVGOMLength(this );
567: }
568:
569: /**
570: * <b>DOM</b>: Implements {@link SVGSVGElement#createSVGAngle()}.
571: */
572: public SVGAngle createSVGAngle() {
573: return new SVGOMAngle();
574: }
575:
576: /**
577: * <b>DOM</b>: Implements {@link SVGSVGElement#createSVGPoint()}.
578: */
579: public SVGPoint createSVGPoint() {
580: return new SVGOMPoint(0, 0);
581: }
582:
583: /**
584: * <b>DOM</b>: Implements {@link SVGSVGElement#createSVGMatrix()}.
585: */
586: public SVGMatrix createSVGMatrix() {
587: return new AbstractSVGMatrix() {
588: protected AffineTransform at = new AffineTransform();
589:
590: protected AffineTransform getAffineTransform() {
591: return at;
592: }
593: };
594: }
595:
596: /**
597: * <b>DOM</b>: Implements {@link SVGSVGElement#createSVGRect()}.
598: */
599: public SVGRect createSVGRect() {
600: return new SVGOMRect(0, 0, 0, 0);
601: }
602:
603: /**
604: * <b>DOM</b>: Implements {@link SVGSVGElement#createSVGTransform()}.
605: */
606: public SVGTransform createSVGTransform() {
607: SVGOMTransform ret = new SVGOMTransform();
608: ret.setType(SVGTransform.SVG_TRANSFORM_MATRIX);
609: return ret;
610: }
611:
612: /**
613: * <b>DOM</b>: Implements {@link
614: * SVGSVGElement#createSVGTransformFromMatrix(SVGMatrix)}.
615: */
616: public SVGTransform createSVGTransformFromMatrix(SVGMatrix matrix) {
617: SVGOMTransform tr = new SVGOMTransform();
618: tr.setMatrix(matrix);
619: return tr;
620: }
621:
622: /**
623: * <b>DOM</b>: Implements {@link SVGSVGElement#getElementById(String)}.
624: */
625: public Element getElementById(String elementId) {
626: return ownerDocument.getChildElementById(this , elementId);
627: }
628:
629: // SVGLocatable ///////////////////////////////////////////////////////
630:
631: /**
632: * <b>DOM</b>: Implements {@link
633: * org.w3c.dom.svg.SVGLocatable#getNearestViewportElement()}.
634: */
635: public SVGElement getNearestViewportElement() {
636: return SVGLocatableSupport.getNearestViewportElement(this );
637: }
638:
639: /**
640: * <b>DOM</b>: Implements {@link
641: * org.w3c.dom.svg.SVGLocatable#getFarthestViewportElement()}.
642: */
643: public SVGElement getFarthestViewportElement() {
644: return SVGLocatableSupport.getFarthestViewportElement(this );
645: }
646:
647: /**
648: * <b>DOM</b>: Implements {@link
649: * org.w3c.dom.svg.SVGLocatable#getBBox()}.
650: */
651: public SVGRect getBBox() {
652: return SVGLocatableSupport.getBBox(this );
653: }
654:
655: /**
656: * <b>DOM</b>: Implements {@link
657: * org.w3c.dom.svg.SVGLocatable#getCTM()}.
658: */
659: public SVGMatrix getCTM() {
660: return SVGLocatableSupport.getCTM(this );
661: }
662:
663: /**
664: * <b>DOM</b>: Implements {@link
665: * org.w3c.dom.svg.SVGLocatable#getScreenCTM()}.
666: */
667: public SVGMatrix getScreenCTM() {
668: return SVGLocatableSupport.getScreenCTM(this );
669: }
670:
671: /**
672: * <b>DOM</b>: Implements {@link
673: * org.w3c.dom.svg.SVGLocatable#getTransformToElement(SVGElement)}.
674: */
675: public SVGMatrix getTransformToElement(SVGElement element)
676: throws SVGException {
677: return SVGLocatableSupport.getTransformToElement(this , element);
678: }
679:
680: // ViewCSS ////////////////////////////////////////////////////////////////
681:
682: /**
683: * <b>DOM</b>: Implements {@link
684: * org.w3c.dom.views.AbstractView#getDocument()}.
685: */
686: public DocumentView getDocument() {
687: return (DocumentView) getOwnerDocument();
688: }
689:
690: /**
691: * <b>DOM</b>: Implements {@link
692: * org.w3c.dom.css.ViewCSS#getComputedStyle(Element,String)}.
693: */
694: public CSSStyleDeclaration getComputedStyle(Element elt,
695: String pseudoElt) {
696: AbstractView av = ((DocumentView) getOwnerDocument())
697: .getDefaultView();
698: return ((ViewCSS) av).getComputedStyle(elt, pseudoElt);
699: }
700:
701: // DocumentEvent /////////////////////////////////////////////////////////
702:
703: /**
704: * <b>DOM</b>: Implements {@link
705: * org.w3c.dom.events.DocumentEvent#createEvent(String)}.
706: */
707: public Event createEvent(String eventType) throws DOMException {
708: return ((DocumentEvent) getOwnerDocument())
709: .createEvent(eventType);
710: }
711:
712: /**
713: * <b>DOM</b>: Implements {@link
714: * org.w3c.dom.events.DocumentEvent#canDispatch(String,String)}.
715: */
716: public boolean canDispatch(String namespaceURI, String type)
717: throws DOMException {
718: AbstractDocument doc = (AbstractDocument) getOwnerDocument();
719: return doc.canDispatch(namespaceURI, type);
720: }
721:
722: // DocumentCSS ////////////////////////////////////////////////////////////
723:
724: /**
725: * <b>DOM</b>: Implements {@link
726: * org.w3c.dom.stylesheets.DocumentStyle#getStyleSheets()}.
727: */
728: public StyleSheetList getStyleSheets() {
729: return ((DocumentStyle) getOwnerDocument()).getStyleSheets();
730: }
731:
732: /**
733: * <b>DOM</b>: Implements {@link
734: * org.w3c.dom.css.DocumentCSS#getOverrideStyle(Element,String)}.
735: */
736: public CSSStyleDeclaration getOverrideStyle(Element elt,
737: String pseudoElt) {
738: return ((DocumentCSS) getOwnerDocument()).getOverrideStyle(elt,
739: pseudoElt);
740: }
741:
742: // SVGLangSpace support //////////////////////////////////////////////////
743:
744: /**
745: * <b>DOM</b>: Returns the xml:lang attribute value.
746: */
747: public String getXMLlang() {
748: return XMLSupport.getXMLLang(this );
749: }
750:
751: /**
752: * <b>DOM</b>: Sets the xml:lang attribute value.
753: */
754: public void setXMLlang(String lang) {
755: setAttributeNS(XML_NAMESPACE_URI, XML_LANG_QNAME, lang);
756: }
757:
758: /**
759: * <b>DOM</b>: Returns the xml:space attribute value.
760: */
761: public String getXMLspace() {
762: return XMLSupport.getXMLSpace(this );
763: }
764:
765: /**
766: * <b>DOM</b>: Sets the xml:space attribute value.
767: */
768: public void setXMLspace(String space) {
769: setAttributeNS(XML_NAMESPACE_URI, XML_SPACE_QNAME, space);
770: }
771:
772: // SVGZoomAndPan support ///////////////////////////////////////////////
773:
774: /**
775: * <b>DOM</b>: Implements {@link
776: * org.w3c.dom.svg.SVGZoomAndPan#getZoomAndPan()}.
777: */
778: public short getZoomAndPan() {
779: return SVGZoomAndPanSupport.getZoomAndPan(this );
780: }
781:
782: /**
783: * <b>DOM</b>: Implements {@link
784: * org.w3c.dom.svg.SVGZoomAndPan#getZoomAndPan()}.
785: */
786: public void setZoomAndPan(short val) {
787: SVGZoomAndPanSupport.setZoomAndPan(this , val);
788: }
789:
790: // SVGFitToViewBox support ////////////////////////////////////////////
791:
792: /**
793: * <b>DOM</b>: Implements {@link
794: * org.w3c.dom.svg.SVGFitToViewBox#getViewBox()}.
795: */
796: public SVGAnimatedRect getViewBox() {
797: throw new UnsupportedOperationException(
798: "SVGFitToViewBox.getViewBox is not implemented"); // XXX
799: }
800:
801: /**
802: * <b>DOM</b>: Implements {@link
803: * org.w3c.dom.svg.SVGFitToViewBox#getPreserveAspectRatio()}.
804: */
805: public SVGAnimatedPreserveAspectRatio getPreserveAspectRatio() {
806: return preserveAspectRatio;
807: }
808:
809: // SVGExternalResourcesRequired support /////////////////////////////
810:
811: /**
812: * <b>DOM</b>: Implements {@link
813: * org.w3c.dom.svg.SVGExternalResourcesRequired#getExternalResourcesRequired()}.
814: */
815: public SVGAnimatedBoolean getExternalResourcesRequired() {
816: return externalResourcesRequired;
817: }
818:
819: // SVGTests support ///////////////////////////////////////////////////
820:
821: /**
822: * <b>DOM</b>: Implements {@link
823: * org.w3c.dom.svg.SVGTests#getRequiredFeatures()}.
824: */
825: public SVGStringList getRequiredFeatures() {
826: return SVGTestsSupport.getRequiredFeatures(this );
827: }
828:
829: /**
830: * <b>DOM</b>: Implements {@link
831: * org.w3c.dom.svg.SVGTests#getRequiredExtensions()}.
832: */
833: public SVGStringList getRequiredExtensions() {
834: return SVGTestsSupport.getRequiredExtensions(this );
835: }
836:
837: /**
838: * <b>DOM</b>: Implements {@link
839: * org.w3c.dom.svg.SVGTests#getSystemLanguage()}.
840: */
841: public SVGStringList getSystemLanguage() {
842: return SVGTestsSupport.getSystemLanguage(this );
843: }
844:
845: /**
846: * <b>DOM</b>: Implements {@link
847: * org.w3c.dom.svg.SVGTests#hasExtension(String)}.
848: */
849: public boolean hasExtension(String extension) {
850: return SVGTestsSupport.hasExtension(this , extension);
851: }
852:
853: /**
854: * Returns the AttributeInitializer for this element type.
855: * @return null if this element has no attribute with a default value.
856: */
857: protected AttributeInitializer getAttributeInitializer() {
858: return attributeInitializer;
859: }
860:
861: /**
862: * Returns a new uninitialized instance of this object's class.
863: */
864: protected Node newNode() {
865: return new SVGOMSVGElement();
866: }
867:
868: /**
869: * Returns the table of TraitInformation objects for this element.
870: */
871: protected DoublyIndexedTable getTraitInformationTable() {
872: return xmlTraitInformation;
873: }
874: }
|