1 18 package org.apache.batik.dom.svg; 19 20 import org.apache.batik.util.SVGConstants; 21 22 import org.w3c.dom.Attr ; 23 import org.w3c.dom.DOMException ; 24 import org.w3c.dom.svg.SVGAnimatedPreserveAspectRatio; 25 import org.w3c.dom.svg.SVGPreserveAspectRatio; 26 import org.w3c.dom.svg.SVGException; 27 28 34 public class SVGOMAnimatedPreserveAspectRatio 35 implements SVGAnimatedPreserveAspectRatio, LiveAttributeValue { 36 39 protected AbstractElement element; 40 41 44 protected boolean changing = false; 45 46 50 protected AbstractSVGPreserveAspectRatio preserveAspectRatio; 51 52 53 54 public SVGOMAnimatedPreserveAspectRatio(AbstractElement elt) { 55 element = elt; 56 preserveAspectRatio = new SVGOMPreserveAspectRatio(); 57 String attrValue = elt.getAttributeNS 58 (null,SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE); 59 if (attrValue != null) { 60 preserveAspectRatio.setValueAsString(attrValue); 61 } 62 } 63 64 public void attrAdded(Attr node, String newv) { 65 if (!changing) { 66 preserveAspectRatio.setValueAsString(newv); 67 } 69 } 70 71 public void attrModified(Attr node, String oldv, String newv) { 72 if (!changing) { 73 preserveAspectRatio.setValueAsString(newv); 74 } 75 } 76 77 public void attrRemoved(Attr node, String oldv) { 78 if (!changing) { 79 preserveAspectRatio.reset(); 80 } 81 } 82 83 public SVGPreserveAspectRatio getAnimVal() { 84 throw new RuntimeException ("!!! TODO: getAnimVal()"); 85 86 } 87 88 public SVGPreserveAspectRatio getBaseVal() { 89 return preserveAspectRatio; 90 } 91 92 94 public class SVGOMPreserveAspectRatio 95 extends AbstractSVGPreserveAspectRatio { 96 97 100 protected DOMException createDOMException(short type, 101 String key, 102 Object [] args){ 103 return element.createDOMException(type,key,args); 104 } 105 106 protected void setAttributeValue(String value) throws DOMException { 107 try { 108 changing = true; 109 element.setAttributeNS 110 (null,SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE, 111 value); 112 } finally { 113 changing = false; 114 } 115 } 116 } 117 } 118 | Popular Tags |