1
19 package org.apache.batik.css.engine.value.css2;
20
21 import org.apache.batik.css.engine.CSSEngine;
22 import org.apache.batik.css.engine.value.AbstractValueManager;
23 import org.apache.batik.css.engine.value.FloatValue;
24 import org.apache.batik.css.engine.value.Value;
25 import org.apache.batik.css.engine.value.ValueConstants;
26 import org.apache.batik.css.engine.value.ValueManager;
27 import org.apache.batik.util.CSSConstants;
28 import org.apache.batik.util.SVGTypes;
29
30 import org.w3c.css.sac.LexicalUnit;
31 import org.w3c.dom.DOMException;
32 import org.w3c.dom.css.CSSPrimitiveValue;
33
34
40 public class FontSizeAdjustManager extends AbstractValueManager {
41
42
45 public boolean isInheritedProperty() {
46 return true;
47 }
48
49
52 public boolean isAnimatableProperty() {
53 return true;
54 }
55
56
59 public boolean isAdditiveProperty() {
60 return false;
61 }
62
63
66 public int getPropertyType() {
67 return SVGTypes.TYPE_FONT_SIZE_ADJUST_VALUE;
68 }
69
70
73 public String getPropertyName() {
74 return CSSConstants.CSS_FONT_SIZE_ADJUST_PROPERTY;
75 }
76
77
80 public Value getDefaultValue() {
81 return ValueConstants.NONE_VALUE;
82 }
83
84
87 public Value createValue(LexicalUnit lu, CSSEngine engine)
88 throws DOMException {
89 switch (lu.getLexicalUnitType()) {
90 case LexicalUnit.SAC_INHERIT:
91 return ValueConstants.INHERIT_VALUE;
92
93 case LexicalUnit.SAC_INTEGER:
94 return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
95 lu.getIntegerValue());
96
97 case LexicalUnit.SAC_REAL:
98 return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
99 lu.getFloatValue());
100
101 case LexicalUnit.SAC_IDENT:
102 if (lu.getStringValue().equalsIgnoreCase
103 (CSSConstants.CSS_NONE_VALUE)) {
104 return ValueConstants.NONE_VALUE;
105 }
106 throw createInvalidIdentifierDOMException(lu.getStringValue());
107 }
108 throw createInvalidLexicalUnitDOMException(lu.getLexicalUnitType());
109 }
110
111
115 public Value createStringValue(short type, String value, CSSEngine engine)
116 throws DOMException {
117 if (type != CSSPrimitiveValue.CSS_IDENT) {
118 throw createInvalidStringTypeDOMException(type);
119 }
120 if (value.equalsIgnoreCase(CSSConstants.CSS_NONE_VALUE)) {
121 return ValueConstants.NONE_VALUE;
122 }
123 throw createInvalidIdentifierDOMException(value);
124 }
125
126
129 public Value createFloatValue(short type, float floatValue)
130 throws DOMException {
131 if (type == CSSPrimitiveValue.CSS_NUMBER) {
132 return new FloatValue(type, floatValue);
133 }
134 throw createInvalidFloatTypeDOMException(type);
135 }
136 }
137