KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > css > engine > value > css2 > FontSizeAdjustManager


1 /*
2
3    Copyright 2002-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

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 JavaDoc;
29 import org.w3c.dom.css.CSSPrimitiveValue;
30
31 /**
32  * This class provides a manager for the 'font-size-adjust' property values.
33  *
34  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
35  * @version $Id: FontSizeAdjustManager.java,v 1.5 2005/03/27 08:58:31 cam Exp $
36  */

37 public class FontSizeAdjustManager extends AbstractValueManager {
38
39     /**
40      * Implements {@link ValueManager#isInheritedProperty()}.
41      */

42     public boolean isInheritedProperty() {
43     return true;
44     }
45
46     /**
47      * Implements {@link ValueManager#getPropertyName()}.
48      */

49     public String JavaDoc getPropertyName() {
50     return CSSConstants.CSS_FONT_SIZE_ADJUST_PROPERTY;
51     }
52     
53     /**
54      * Implements {@link ValueManager#getDefaultValue()}.
55      */

56     public Value getDefaultValue() {
57         return ValueConstants.NONE_VALUE;
58     }
59
60     /**
61      * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
62      */

63     public Value createValue(LexicalUnit lu, CSSEngine engine)
64         throws DOMException JavaDoc {
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     /**
88      * Implements {@link
89      * ValueManager#createStringValue(short,String,CSSEngine)}.
90      */

91     public Value createStringValue(short type, String JavaDoc value, CSSEngine engine)
92         throws DOMException JavaDoc {
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     /**
103      * Implements {@link ValueManager#createFloatValue(short,float)}.
104      */

105     public Value createFloatValue(short type, float floatValue)
106         throws DOMException JavaDoc {
107     if (type == CSSPrimitiveValue.CSS_NUMBER) {
108         return new FloatValue(type, floatValue);
109     }
110         throw createInvalidFloatTypeDOMException(type);
111     }
112 }
113
Popular Tags