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.SVGAnimatedPoints; 23 import org.w3c.dom.svg.SVGException; 24 import org.w3c.dom.svg.SVGPointList; 25 26 33 public class SVGOMAnimatedPoints 34 implements SVGAnimatedPoints, 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 AbstractSVGPointList points; 61 62 65 protected String defaultValue; 66 67 69 public SVGOMAnimatedPoints(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 87 public SVGPointList getPoints(){ 88 if ( points == null ){ 89 points = new SVGOMPointList(); 90 } 91 return points; 92 } 93 94 96 public SVGPointList getAnimatedPoints(){ 97 throw new RuntimeException ("TODO : getAnimatedPoints() !!"); 98 } 99 100 103 public void attrAdded(Attr node, String newv) { 104 if (!changing && points != null) { 105 points.invalidate(); 106 } 107 } 108 109 112 public void attrModified(Attr node, String oldv, String newv) { 113 if (!changing && points != null) { 114 points.invalidate(); 115 } 116 } 117 118 121 public void attrRemoved(Attr node, String oldv) { 122 if (!changing && points != null) { 123 points.invalidate(); 124 } 125 } 126 127 131 public class SVGOMPointList extends AbstractSVGPointList { 132 133 136 protected DOMException createDOMException(short type, 137 String key, 138 Object [] args){ 139 return element.createDOMException(type,key,args); 140 } 141 142 145 protected SVGException createSVGException(short type, 146 String key, 147 Object [] args){ 148 149 return ((SVGOMElement)element).createSVGException(type,key,args); 150 } 151 152 155 protected String getValueAsString(){ 156 Attr attr = element.getAttributeNodeNS(namespaceURI, localName); 157 if (attr == null) { 158 return defaultValue; 159 } 160 return attr.getValue(); 161 } 162 163 166 protected void setAttributeValue(String value){ 167 try{ 168 changing = true; 169 element.setAttributeNS(namespaceURI, localName, value); 170 } 171 finally{ 172 changing = false; 173 } 174 } 175 } 176 } 177 | Popular Tags |