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.SVGAnimatedPathData; 23 import org.w3c.dom.svg.SVGException; 24 import org.w3c.dom.svg.SVGPathSegList; 25 26 33 public class SVGOMAnimatedPathData 34 implements SVGAnimatedPathData, 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 AbstractSVGPathSegList pathSegs; 61 62 65 protected String defaultValue; 66 67 69 public SVGOMAnimatedPathData(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 82 public SVGPathSegList getAnimatedNormalizedPathSegList(){ 83 throw new RuntimeException ("TODO : getAnimatedNormalizedPathSegList() !!"); 84 } 85 86 87 89 public SVGPathSegList getAnimatedPathSegList(){ 90 throw new RuntimeException ("TODO : getAnimatedPathSegList() !!"); 91 } 92 93 95 public SVGPathSegList getNormalizedPathSegList(){ 96 throw new RuntimeException ("TODO : getNormalizedPathSegList() !!"); 97 } 98 99 100 107 public SVGPathSegList getPathSegList(){ 108 if ( pathSegs == null ){ 109 pathSegs = new SVGOMPathSegList(); 110 } 111 return pathSegs; 112 } 113 114 117 public void attrAdded(Attr node, String newv) { 118 if (!changing && pathSegs != null) { 119 pathSegs.invalidate(); 120 } 121 } 122 123 126 public void attrModified(Attr node, String oldv, String newv) { 127 if (!changing && pathSegs != null) { 128 pathSegs.invalidate(); 129 } 130 } 131 132 135 public void attrRemoved(Attr node, String oldv) { 136 if (!changing && pathSegs != null) { 137 pathSegs.invalidate(); 138 } 139 } 140 141 145 public class SVGOMPathSegList extends AbstractSVGPathSegList { 146 147 150 protected DOMException createDOMException(short type, 151 String key, 152 Object [] args){ 153 return element.createDOMException(type,key,args); 154 } 155 156 159 protected SVGException createSVGException(short type, 160 String key, 161 Object [] args){ 162 163 return ((SVGOMElement)element).createSVGException(type,key,args); 164 } 165 166 169 protected String getValueAsString(){ 170 Attr attr = element.getAttributeNodeNS(namespaceURI, localName); 171 if (attr == null) { 172 return defaultValue; 173 } 174 return attr.getValue(); 175 } 176 177 180 protected void setAttributeValue(String value){ 181 try{ 182 changing = true; 183 element.setAttributeNS(namespaceURI, localName, value); 184 } 185 finally{ 186 changing = false; 187 } 188 } 189 } 190 } 191 | Popular Tags |