1 18 package org.apache.batik.css.engine.value.css2; 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.ValueConstants; 25 import org.apache.batik.css.engine.value.ValueManager; 26 import org.apache.batik.util.CSSConstants; 27 import org.w3c.css.sac.LexicalUnit; 28 import org.w3c.dom.DOMException ; 29 import org.w3c.dom.css.CSSPrimitiveValue; 30 31 37 public class FontSizeAdjustManager extends AbstractValueManager { 38 39 42 public boolean isInheritedProperty() { 43 return true; 44 } 45 46 49 public String getPropertyName() { 50 return CSSConstants.CSS_FONT_SIZE_ADJUST_PROPERTY; 51 } 52 53 56 public Value getDefaultValue() { 57 return ValueConstants.NONE_VALUE; 58 } 59 60 63 public Value createValue(LexicalUnit lu, CSSEngine engine) 64 throws DOMException { 65 switch (lu.getLexicalUnitType()) { 66 case LexicalUnit.SAC_INHERIT: 67 return ValueConstants.INHERIT_VALUE; 68 69 case LexicalUnit.SAC_INTEGER: 70 return new FloatValue(CSSPrimitiveValue.CSS_NUMBER, 71 lu.getIntegerValue()); 72 73 case LexicalUnit.SAC_REAL: 74 return new FloatValue(CSSPrimitiveValue.CSS_NUMBER, 75 lu.getFloatValue()); 76 77 case LexicalUnit.SAC_IDENT: 78 if (lu.getStringValue().equalsIgnoreCase 79 (CSSConstants.CSS_NONE_VALUE)) { 80 return ValueConstants.NONE_VALUE; 81 } 82 throw createInvalidIdentifierDOMException(lu.getStringValue()); 83 } 84 throw createInvalidLexicalUnitDOMException(lu.getLexicalUnitType()); 85 } 86 87 91 public Value createStringValue(short type, String value, CSSEngine engine) 92 throws DOMException { 93 if (type != CSSPrimitiveValue.CSS_IDENT) { 94 throw createInvalidStringTypeDOMException(type); 95 } 96 if (value.equalsIgnoreCase(CSSConstants.CSS_NONE_VALUE)) { 97 return ValueConstants.NONE_VALUE; 98 } 99 throw createInvalidIdentifierDOMException(value); 100 } 101 102 105 public Value createFloatValue(short type, float floatValue) 106 throws DOMException { 107 if (type == CSSPrimitiveValue.CSS_NUMBER) { 108 return new FloatValue(type, floatValue); 109 } 110 throw createInvalidFloatTypeDOMException(type); 111 } 112 } 113 | Popular Tags |