1 18 19 package org.apache.batik.bridge; 20 21 import java.awt.geom.AffineTransform ; 22 import java.awt.geom.Rectangle2D ; 23 24 import org.w3c.dom.Element ; 25 import org.w3c.dom.events.MutationEvent ; 26 27 import org.apache.batik.css.engine.CSSEngineEvent; 28 import org.apache.batik.dom.svg.SVGContext; 29 import org.apache.batik.dom.svg.SVGOMElement; 30 31 37 public abstract class SVGDescriptiveElementBridge extends AbstractSVGBridge 38 implements GenericBridge, BridgeUpdateHandler, SVGContext { 39 40 Element theElt; 41 Element parent; 42 BridgeContext theCtx; 43 44 public SVGDescriptiveElementBridge() { 45 } 46 47 48 56 public void handleElement(BridgeContext ctx, Element e){ 57 UserAgent ua = ctx.getUserAgent(); 58 ua.handleElement(e, Boolean.TRUE); 59 60 if (ctx.isDynamic()) { 61 SVGDescriptiveElementBridge b; 62 b = (SVGDescriptiveElementBridge)getInstance(); 63 b.theElt = e; 64 b.parent = (Element )e.getParentNode(); 65 b.theCtx = ctx; 66 ((SVGOMElement)e).setSVGContext(b); 67 } 68 69 } 70 71 73 public void dispose() { 74 UserAgent ua = theCtx.getUserAgent(); 75 ((SVGOMElement)theElt).setSVGContext(null); 76 ua.handleElement(theElt, parent); 77 theElt = null; 78 parent = null; 79 } 80 public void handleDOMNodeInsertedEvent(MutationEvent evt) { 81 UserAgent ua = theCtx.getUserAgent(); 82 ua.handleElement(theElt, Boolean.TRUE); 83 } 84 public void handleDOMCharacterDataModified(MutationEvent evt) { 85 UserAgent ua = theCtx.getUserAgent(); 86 ua.handleElement(theElt, Boolean.TRUE); 87 } 88 89 public void handleDOMNodeRemovedEvent (MutationEvent evt) { 90 dispose(); 91 } 92 93 public void handleDOMAttrModifiedEvent(MutationEvent evt) { } 94 public void handleCSSEngineEvent(CSSEngineEvent evt) { } 95 96 98 101 public float getPixelUnitToMillimeter() { 102 return theCtx.getUserAgent().getPixelUnitToMillimeter(); 103 } 104 105 110 public float getPixelToMM() { 111 return getPixelUnitToMillimeter(); 112 113 } 114 115 public Rectangle2D getBBox() { return null; } 116 public AffineTransform getScreenTransform() { 117 return theCtx.getUserAgent().getTransform(); 118 } 119 public void setScreenTransform(AffineTransform at) { 120 theCtx.getUserAgent().setTransform(at); 121 } 122 public AffineTransform getCTM() { return null; } 123 public AffineTransform getGlobalTransform() { return null; } 124 public float getViewportWidth() { 125 return theCtx.getBlockWidth(theElt); 126 } 127 public float getViewportHeight() { 128 return theCtx.getBlockHeight(theElt); 129 } 130 public float getFontSize() { return 0; } 131 }; 132 | Popular Tags |