1 18 package org.apache.batik.dom.svg; 19 20 import org.w3c.dom.Attr ; 21 import org.w3c.dom.DOMException ; 22 import org.w3c.dom.svg.SVGAnimatedTransformList; 23 import org.w3c.dom.svg.SVGException; 24 import org.w3c.dom.svg.SVGTransformList; 25 26 33 public class SVGOMAnimatedTransformList 34 implements SVGAnimatedTransformList, 35 LiveAttributeValue { 36 37 40 protected AbstractElement element; 41 42 45 protected String namespaceURI; 46 47 50 protected String localName; 51 52 55 protected boolean changing; 56 57 60 protected AbstractSVGTransformList transformList; 61 62 65 protected String defaultValue; 66 67 69 public SVGOMAnimatedTransformList(AbstractElement elt, 70 String ns, 71 String ln, 72 String defaultValue){ 73 74 element = elt; 75 namespaceURI = ns; 76 localName = ln; 77 this.defaultValue = defaultValue; 78 } 79 80 81 88 public SVGTransformList getBaseVal(){ 89 if ( transformList == null ){ 90 transformList = new SVGOMTransformList(); 91 } 92 return transformList; 93 } 94 95 public SVGTransformList getAnimVal(){ 96 throw new RuntimeException ("TODO : getAnimVal() !!"); 97 } 98 99 102 public void attrAdded(Attr node, String newv) { 103 if (!changing && transformList != null) { 104 transformList.invalidate(); 105 } 106 } 107 108 111 public void attrModified(Attr node, String oldv, String newv) { 112 if (!changing && transformList != null) { 113 transformList.invalidate(); 114 } 115 } 116 117 120 public void attrRemoved(Attr node, String oldv) { 121 if (!changing && transformList != null) { 122 transformList.invalidate(); 123 } 124 } 125 126 130 public class SVGOMTransformList extends AbstractSVGTransformList { 131 132 135 protected DOMException createDOMException(short type, 136 String key, 137 Object [] args){ 138 return element.createDOMException(type,key,args); 139 } 140 141 144 protected SVGException createSVGException(short type, 145 String key, 146 Object [] args){ 147 148 return ((SVGOMElement)element).createSVGException(type,key,args); 149 } 150 151 154 protected String getValueAsString(){ 155 Attr attr = element.getAttributeNodeNS(namespaceURI, localName); 156 if (attr == null) { 157 return defaultValue; 158 } 159 return attr.getValue(); 160 } 161 162 165 protected void setAttributeValue(String value){ 166 try{ 167 changing = true; 168 element.setAttributeNS(namespaceURI, localName, value); 169 } 170 finally{ 171 changing = false; 172 } 173 } 174 } 175 } 176 | Popular Tags |