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 class OpacityManager extends AbstractValueManager { 36 37 40 protected boolean inherited; 41 42 45 protected String property; 46 47 50 public OpacityManager(String prop, boolean inherit) { 51 property = prop; 52 inherited = inherit; 53 } 54 55 58 public boolean isInheritedProperty() { 59 return inherited; 60 } 61 62 65 public String getPropertyName() { 66 return property; 67 } 68 69 72 public Value getDefaultValue() { 73 return SVGValueConstants.NUMBER_1; 74 } 75 76 79 public Value createValue(LexicalUnit lu, CSSEngine engine) 80 throws DOMException { 81 switch (lu.getLexicalUnitType()) { 82 case LexicalUnit.SAC_INHERIT: 83 return SVGValueConstants.INHERIT_VALUE; 84 85 case LexicalUnit.SAC_INTEGER: 86 return new FloatValue(CSSPrimitiveValue.CSS_NUMBER, 87 lu.getIntegerValue()); 88 89 case LexicalUnit.SAC_REAL: 90 return new FloatValue(CSSPrimitiveValue.CSS_NUMBER, 91 lu.getFloatValue()); 92 } 93 throw createInvalidLexicalUnitDOMException(lu.getLexicalUnitType()); 94 } 95 96 99 public Value createFloatValue(short type, float floatValue) 100 throws DOMException { 101 if (type == CSSPrimitiveValue.CSS_NUMBER) { 102 return new FloatValue(type, floatValue); 103 } 104 throw createInvalidFloatTypeDOMException(type); 105 } 106 } 107 | Popular Tags |