1 18 package org.apache.batik.css.engine.value.svg; 19 20 import org.apache.batik.css.engine.CSSEngine; 21 import org.apache.batik.css.engine.CSSStylableElement; 22 import org.apache.batik.css.engine.StyleMap; 23 import org.apache.batik.css.engine.value.LengthManager; 24 import org.apache.batik.css.engine.value.ListValue; 25 import org.apache.batik.css.engine.value.Value; 26 import org.apache.batik.css.engine.value.ValueManager; 27 import org.apache.batik.util.CSSConstants; 28 import org.w3c.css.sac.LexicalUnit; 29 import org.w3c.dom.DOMException ; 30 import org.w3c.dom.css.CSSPrimitiveValue; 31 import org.w3c.dom.css.CSSValue; 32 33 39 public class StrokeDasharrayManager extends LengthManager { 40 41 44 public boolean isInheritedProperty() { 45 return true; 46 } 47 48 51 public String getPropertyName() { 52 return CSSConstants.CSS_STROKE_DASHARRAY_PROPERTY; 53 } 54 55 58 public Value getDefaultValue() { 59 return SVGValueConstants.NONE_VALUE; 60 } 61 62 65 public Value createValue(LexicalUnit lu, CSSEngine engine) 66 throws DOMException { 67 switch (lu.getLexicalUnitType()) { 68 case LexicalUnit.SAC_INHERIT: 69 return SVGValueConstants.INHERIT_VALUE; 70 71 case LexicalUnit.SAC_IDENT: 72 if (lu.getStringValue().equalsIgnoreCase 73 (CSSConstants.CSS_NONE_VALUE)) { 74 return SVGValueConstants.NONE_VALUE; 75 } 76 throw createInvalidIdentifierDOMException(lu.getStringValue()); 77 78 default: 79 ListValue lv = new ListValue(' '); 80 do { 81 Value v = super.createValue(lu, engine); 82 lv.append(v); 83 lu = lu.getNextLexicalUnit(); 84 if (lu != null && 85 lu.getLexicalUnitType() == 86 LexicalUnit.SAC_OPERATOR_COMMA) { 87 lu = lu.getNextLexicalUnit(); 88 } 89 } while (lu != null); 90 return lv; 91 } 92 } 93 94 98 public Value createStringValue(short type, String value, CSSEngine engine) 99 throws DOMException { 100 if (type != CSSPrimitiveValue.CSS_IDENT) { 101 throw createInvalidStringTypeDOMException(type); 102 } 103 if (value.equalsIgnoreCase(CSSConstants.CSS_NONE_VALUE)) { 104 return SVGValueConstants.NONE_VALUE; 105 } 106 throw createInvalidIdentifierDOMException(value); 107 } 108 109 113 public Value computeValue(CSSStylableElement elt, 114 String pseudo, 115 CSSEngine engine, 116 int idx, 117 StyleMap sm, 118 Value value) { 119 switch (value.getCssValueType()) { 120 case CSSValue.CSS_PRIMITIVE_VALUE: 121 return value; 122 } 123 124 ListValue lv = (ListValue)value; 125 ListValue result = new ListValue(' '); 126 for (int i = 0; i < lv.getLength(); i++) { 127 result.append(super.computeValue(elt, pseudo, engine, idx, sm, 128 lv.item(i))); 129 } 130 return result; 131 } 132 133 137 protected int getOrientation() { 138 return BOTH_ORIENTATION; 139 } 140 } 141 | Popular Tags |