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.SVGAnimatedEnumeration; 23 24 31 public class SVGOMAnimatedEnumeration 32 implements SVGAnimatedEnumeration, 33 LiveAttributeValue { 34 35 38 protected AbstractElement element; 39 40 43 protected String namespaceURI; 44 45 48 protected String localName; 49 50 53 protected String [] values; 54 55 58 protected short defaultValue; 59 60 68 public SVGOMAnimatedEnumeration(AbstractElement elt, 69 String ns, 70 String ln, 71 String [] val, 72 short def) { 73 element = elt; 74 namespaceURI = ns; 75 localName = ln; 76 values = val; 77 defaultValue = def; 78 } 79 80 83 public short getBaseVal() { 84 String val = element.getAttributeNS(namespaceURI, localName); 85 if (val.length() == 0) { 86 return defaultValue; 87 } 88 for (short i = 0; i < values.length; i++) { 89 if (val.equals(values[i])) { 90 return i; 91 } 92 } 93 return 0; 94 } 95 96 100 public void setBaseVal(short baseVal) throws DOMException { 101 if (baseVal >= 0 && baseVal < values.length) { 102 element.setAttributeNS(namespaceURI, localName, values[baseVal]); 103 } 104 } 105 106 109 public short getAnimVal() { 110 throw new RuntimeException ("!!! TODO: getAnimVal()"); 111 } 112 113 116 public void attrAdded(Attr node, String newv) { 117 } 118 119 122 public void attrModified(Attr node, String oldv, String newv) { 123 } 124 125 128 public void attrRemoved(Attr node, String oldv) { 129 } 130 } 131 | Popular Tags |