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.Element ; 23 import org.w3c.dom.svg.SVGAnimatedNumberList; 24 import org.w3c.dom.svg.SVGException; 25 import org.w3c.dom.svg.SVGNumberList; 26 27 33 public class SVGOMAnimatedNumberList 34 implements SVGAnimatedNumberList, 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 AbstractSVGNumberList numbers; 61 62 65 protected String defaultValue; 66 67 69 public SVGOMAnimatedNumberList(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 SVGNumberList getBaseVal(){ 88 if ( numbers == null ){ 89 numbers = new SVGOMNumberList(); 90 } 91 return numbers; 92 } 93 94 96 public SVGNumberList getAnimVal(){ 97 throw new RuntimeException ("TODO : getAnimVal() !!"); 98 } 99 100 103 public void attrAdded(Attr node, String newv) { 104 if (!changing && numbers != null) { 105 numbers.invalidate(); 106 } 107 } 108 109 112 public void attrModified(Attr node, String oldv, String newv) { 113 if (!changing && numbers != null) { 114 numbers.invalidate(); 115 } 116 } 117 118 121 public void attrRemoved(Attr node, String oldv) { 122 if (!changing && numbers != null) { 123 numbers.invalidate(); 124 } 125 } 126 127 130 public class SVGOMNumberList extends AbstractSVGNumberList { 131 132 public SVGOMNumberList(){ 133 super(); 134 } 135 136 139 protected DOMException createDOMException(short type, 140 String key, 141 Object [] args){ 142 return element.createDOMException(type,key,args); 143 } 144 145 148 protected SVGException createSVGException(short type, 149 String key, 150 Object [] args){ 151 152 return ((SVGOMElement)element).createSVGException(type,key,args); 153 } 154 155 157 protected Element getElement(){ 158 return element; 159 } 160 161 164 protected String getValueAsString(){ 165 Attr attr = element.getAttributeNodeNS(namespaceURI, localName); 166 if (attr == null) { 167 return defaultValue; 168 } 169 return attr.getValue(); 170 } 171 172 175 protected void setAttributeValue(String value){ 176 try{ 177 changing = true; 178 element.setAttributeNS(namespaceURI, localName, value); 179 } 180 finally{ 181 changing = false; 182 } 183 } 184 } 185 } 186 | Popular Tags |