1 18 19 package org.apache.batik.extension; 20 21 import java.net.MalformedURLException ; 22 import java.net.URL ; 23 24 import org.apache.batik.css.engine.CSSStylableElement; 25 import org.apache.batik.css.engine.StyleMap; 26 import org.apache.batik.dom.AbstractDocument; 27 import org.apache.batik.dom.svg.XMLBaseSupport; 28 import org.w3c.dom.Node ; 29 import org.w3c.dom.css.CSSStyleDeclaration; 30 import org.w3c.dom.css.CSSValue; 31 import org.w3c.dom.svg.SVGAnimatedString; 32 import org.w3c.dom.svg.SVGStylable; 33 34 43 public abstract class StylableExtensionElement 44 extends ExtensionElement 45 implements CSSStylableElement, 46 SVGStylable { 47 48 51 protected URL cssBase; 52 53 56 protected StyleMap computedStyleMap; 57 58 61 protected StylableExtensionElement() { 62 } 63 64 69 protected StylableExtensionElement(String name, AbstractDocument owner) { 70 super(name, owner); 71 } 72 73 75 78 public StyleMap getComputedStyleMap(String pseudoElement) { 79 return computedStyleMap; 80 } 81 82 85 public void setComputedStyleMap(String pseudoElement, StyleMap sm) { 86 computedStyleMap = sm; 87 } 88 89 92 public String getXMLId() { 93 return getAttributeNS(null, "id"); 94 } 95 96 99 public String getCSSClass() { 100 return getAttributeNS(null, "class"); 101 } 102 103 106 public URL getCSSBase() { 107 if (cssBase == null) { 108 try { 109 String bu = XMLBaseSupport.getCascadedXMLBase(this); 110 if (bu == null) { 111 return null; 112 } 113 cssBase = new URL (XMLBaseSupport.getCascadedXMLBase(this)); 114 } catch (MalformedURLException e) { 115 e.printStackTrace(); 117 throw new InternalError (); 118 } 119 } 120 return cssBase; 121 } 122 123 127 public boolean isPseudoInstanceOf(String pseudoClass) { 128 if (pseudoClass.equals("first-child")) { 129 Node n = getPreviousSibling(); 130 while (n != null && n.getNodeType() != ELEMENT_NODE) { 131 n = n.getPreviousSibling(); 132 } 133 return n == null; 134 } 135 return false; 136 } 137 138 140 143 public CSSStyleDeclaration getStyle() { 144 throw new InternalError ("Not implemented"); 145 } 146 147 151 public CSSValue getPresentationAttribute(String name) { 152 throw new InternalError ("Not implemented"); 153 } 154 155 159 public SVGAnimatedString getClassName() { 160 throw new InternalError ("Not implemented"); 161 } 162 } 163 | Popular Tags |