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.value.AbstractValueManager; 22 import org.apache.batik.css.engine.value.FloatValue; 23 import org.apache.batik.css.engine.value.Value; 24 import org.apache.batik.css.engine.value.ValueManager; 25 import org.w3c.css.sac.LexicalUnit; 26 import org.w3c.dom.DOMException ; 27 import org.w3c.dom.css.CSSPrimitiveValue; 28 29 35 public abstract class GlyphOrientationManager extends AbstractValueManager { 36 37 41 public boolean isInheritedProperty() { 42 return true; 43 } 44 45 48 public Value createValue(LexicalUnit lu, CSSEngine engine) 49 throws DOMException { 50 switch (lu.getLexicalUnitType()) { 51 case LexicalUnit.SAC_INHERIT: 52 return SVGValueConstants.INHERIT_VALUE; 53 54 case LexicalUnit.SAC_DEGREE: 55 return new FloatValue(CSSPrimitiveValue.CSS_DEG, 56 lu.getFloatValue()); 57 58 case LexicalUnit.SAC_GRADIAN: 59 return new FloatValue(CSSPrimitiveValue.CSS_GRAD, 60 lu.getFloatValue()); 61 62 case LexicalUnit.SAC_RADIAN: 63 return new FloatValue(CSSPrimitiveValue.CSS_RAD, 64 lu.getFloatValue()); 65 66 case LexicalUnit.SAC_INTEGER: 68 { 69 int n = lu.getIntegerValue(); 70 return new FloatValue(CSSPrimitiveValue.CSS_DEG, n); 71 } 72 case LexicalUnit.SAC_REAL: 73 { 74 float n = lu.getFloatValue(); 75 return new FloatValue(CSSPrimitiveValue.CSS_DEG, n); 76 } 77 } 78 79 throw createInvalidLexicalUnitDOMException(lu.getLexicalUnitType()); 80 } 81 82 85 public Value createFloatValue(short type, float floatValue) 86 throws DOMException { 87 switch (type) { 88 case CSSPrimitiveValue.CSS_DEG: 89 case CSSPrimitiveValue.CSS_GRAD: 90 case CSSPrimitiveValue.CSS_RAD: 91 return new FloatValue(type, floatValue); 92 } 93 throw createInvalidFloatValueDOMException(floatValue); 94 } 95 } 96 | Popular Tags |