1 18 package org.apache.batik.dom.svg; 19 20 import org.apache.batik.dom.AbstractDocument; 21 import org.apache.batik.dom.util.XMLSupport; 22 import org.w3c.dom.DOMException ; 23 import org.w3c.dom.svg.SVGAnimatedBoolean; 24 import org.w3c.dom.svg.SVGAnimatedEnumeration; 25 import org.w3c.dom.svg.SVGAnimatedLength; 26 import org.w3c.dom.svg.SVGLength; 27 import org.w3c.dom.svg.SVGPoint; 28 import org.w3c.dom.svg.SVGRect; 29 import org.w3c.dom.svg.SVGStringList; 30 31 37 public abstract class SVGOMTextContentElement 38 extends SVGStylableElement { 39 40 43 protected final static String [] LENGTH_ADJUST_VALUES = { 44 "", 45 SVG_SPACING_ATTRIBUTE, 46 SVG_SPACING_AND_GLYPHS_VALUE 47 }; 48 49 52 protected SVGOMTextContentElement() { 53 } 54 55 60 protected SVGOMTextContentElement(String prefix, AbstractDocument owner) { 61 super(prefix, owner); 62 63 } 64 65 69 public SVGAnimatedLength getTextLength() { 70 SVGAnimatedLength result = 71 (SVGAnimatedLength)getLiveAttributeValue 72 (null, SVG_TEXT_LENGTH_ATTRIBUTE); 73 if (result == null) { 74 result = new AbstractSVGAnimatedLength 75 (this, null, SVG_TEXT_LENGTH_ATTRIBUTE, 76 SVGOMAnimatedLength.HORIZONTAL_LENGTH) { 77 boolean usedDefault; 78 79 protected String getDefaultValue() { 80 usedDefault = true; 81 return ""+getComputedTextLength(); 82 } 83 84 public SVGLength getBaseVal() { 85 if (baseVal == null) { 86 baseVal = new SVGTextLength(direction); 87 } 88 return baseVal; 89 } 90 91 class SVGTextLength extends BaseSVGLength { 92 public SVGTextLength(short direction) { 93 super(direction); 94 } 95 protected void revalidate() { 96 usedDefault = false; 97 98 super.revalidate(); 99 100 if (usedDefault) valid = false; 103 } 104 } 105 }; 106 putLiveAttributeValue(null, SVG_TEXT_LENGTH_ATTRIBUTE, 107 (LiveAttributeValue)result); 108 } 109 return result; 110 } 111 112 116 public SVGAnimatedEnumeration getLengthAdjust() { 117 return getAnimatedEnumerationAttribute 118 (null, SVG_LENGTH_ADJUST_ATTRIBUTE, 119 LENGTH_ADJUST_VALUES, (short)1); 120 } 121 122 126 public int getNumberOfChars() { 127 return SVGTextContentSupport.getNumberOfChars(this); 128 } 130 131 135 public float getComputedTextLength() { 136 return SVGTextContentSupport.getComputedTextLength(this); 137 } 139 140 144 public float getSubStringLength(int charnum, int nchars) 145 throws DOMException { 146 return SVGTextContentSupport.getSubStringLength(this,charnum,nchars); 147 } 149 150 154 public SVGPoint getStartPositionOfChar(int charnum) throws DOMException { 155 return SVGTextContentSupport.getStartPositionOfChar(this,charnum); 157 } 158 159 163 public SVGPoint getEndPositionOfChar(int charnum) throws DOMException { 164 return SVGTextContentSupport.getEndPositionOfChar(this,charnum); 166 } 167 168 172 public SVGRect getExtentOfChar(int charnum) throws DOMException { 173 return SVGTextContentSupport.getExtentOfChar(this,charnum); 175 } 176 177 181 public float getRotationOfChar(int charnum) throws DOMException { 182 return SVGTextContentSupport.getRotationOfChar(this,charnum); 184 } 185 186 190 public int getCharNumAtPosition(SVGPoint point) { 191 return SVGTextContentSupport.getCharNumAtPosition(this,point.getX(),point.getY()); 193 } 194 195 199 public void selectSubString(int charnum, int nchars) 200 throws DOMException { 201 SVGTextContentSupport.selectSubString(this,charnum, nchars); 202 } 204 205 207 211 public SVGAnimatedBoolean getExternalResourcesRequired() { 212 return SVGExternalResourcesRequiredSupport. 213 getExternalResourcesRequired(this); 214 } 215 216 218 221 public String getXMLlang() { 222 return XMLSupport.getXMLLang(this); 223 } 224 225 228 public void setXMLlang(String lang) { 229 setAttributeNS(XMLSupport.XML_NAMESPACE_URI, 230 XMLSupport.XML_LANG_ATTRIBUTE, 231 lang); 232 } 233 234 237 public String getXMLspace() { 238 return XMLSupport.getXMLSpace(this); 239 } 240 241 244 public void setXMLspace(String space) { 245 setAttributeNS(XMLSupport.XML_NAMESPACE_URI, 246 XMLSupport.XML_SPACE_ATTRIBUTE, 247 space); 248 } 249 250 252 256 public SVGStringList getRequiredFeatures() { 257 return SVGTestsSupport.getRequiredFeatures(this); 258 } 259 260 264 public SVGStringList getRequiredExtensions() { 265 return SVGTestsSupport.getRequiredExtensions(this); 266 } 267 268 272 public SVGStringList getSystemLanguage() { 273 return SVGTestsSupport.getSystemLanguage(this); 274 } 275 276 280 public boolean hasExtension(String extension) { 281 return SVGTestsSupport.hasExtension(this, extension); 282 } 283 } 284 | Popular Tags |