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.SVGAnimatedBoolean; 23 24 30 public class SVGOMAnimatedBoolean 31 implements SVGAnimatedBoolean, 32 LiveAttributeValue { 33 34 37 protected AbstractElement element; 38 39 42 protected String namespaceURI; 43 44 47 protected String localName; 48 49 52 protected boolean baseVal; 53 54 57 protected String defaultValue; 58 59 62 protected boolean mutate; 63 64 72 public SVGOMAnimatedBoolean(AbstractElement elt, 73 String ns, 74 String ln, 75 Attr attr, 76 String val) { 77 element = elt; 78 namespaceURI = ns; 79 localName = ln; 80 if (attr != null) { 81 String s = attr.getValue(); 82 baseVal = "true".equals(s); 83 } 84 defaultValue = val; 85 } 86 87 90 public boolean getBaseVal() { 91 return baseVal; 92 } 93 94 97 public void setBaseVal(boolean baseVal) throws DOMException { 98 if (this.baseVal != baseVal) { 99 mutate = true; 100 this.baseVal = baseVal; 101 element.setAttributeNS(namespaceURI, localName, 102 (baseVal) ? "true" : "false"); 103 mutate = false; 104 } 105 } 106 107 110 public boolean getAnimVal() { 111 throw new RuntimeException ("!!! TODO: getAnimVal()"); 112 } 113 114 117 public void attrAdded(Attr node, String newv) { 118 if (!mutate) { 119 baseVal = "true".equals(newv); 120 } 121 } 122 123 126 public void attrModified(Attr node, String oldv, String newv) { 127 if (!mutate) { 128 baseVal = "true".equals(newv); 129 } 130 } 131 132 135 public void attrRemoved(Attr node, String oldv) { 136 if (!mutate) { 137 baseVal = "true".equals(defaultValue); 138 } 139 } 140 } 141 | Popular Tags |