KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > css > engine > value > svg > KerningManager


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.svg;
19
20 import org.apache.batik.css.engine.CSSEngine;
21 import org.apache.batik.css.engine.value.LengthManager;
22 import org.apache.batik.css.engine.value.Value;
23 import org.apache.batik.css.engine.value.ValueManager;
24 import org.apache.batik.util.CSSConstants;
25 import org.w3c.css.sac.LexicalUnit;
26 import org.w3c.dom.DOMException JavaDoc;
27 import org.w3c.dom.css.CSSPrimitiveValue;
28
29 /**
30  * This class provides a manager for the 'kerning' property values.
31  *
32  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
33  * @version $Id: KerningManager.java,v 1.5 2005/03/27 08:58:31 cam Exp $
34  */

35 public class KerningManager extends LengthManager {
36     
37     /**
38      * Implements {@link ValueManager#isInheritedProperty()}.
39      */

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

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

54     public Value getDefaultValue() {
55         return SVGValueConstants.AUTO_VALUE;
56     }
57
58     /**
59      * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
60      */

61     public Value createValue(LexicalUnit lu, CSSEngine engine)
62         throws DOMException JavaDoc {
63     switch (lu.getLexicalUnitType()) {
64     case LexicalUnit.SAC_INHERIT:
65             return SVGValueConstants.INHERIT_VALUE;
66
67         case LexicalUnit.SAC_IDENT:
68             if (lu.getStringValue().equalsIgnoreCase
69                 (CSSConstants.CSS_AUTO_VALUE)) {
70                 return SVGValueConstants.AUTO_VALUE;
71             }
72             throw createInvalidIdentifierDOMException(lu.getStringValue());
73         }
74         return super.createValue(lu, engine);
75     }
76
77     /**
78      * Implements {@link
79      * ValueManager#createStringValue(short,String,CSSEngine)}.
80      */

81     public Value createStringValue(short type, String JavaDoc value, CSSEngine engine)
82     throws DOMException JavaDoc {
83     if (type != CSSPrimitiveValue.CSS_IDENT) {
84             throw createInvalidStringTypeDOMException(type);
85     }
86     if (value.equalsIgnoreCase(CSSConstants.CSS_AUTO_VALUE)) {
87             return SVGValueConstants.AUTO_VALUE;
88         }
89         throw createInvalidIdentifierDOMException(value);
90     }
91
92     /**
93      * Indicates the orientation of the property associated with
94      * this manager.
95      */

96     protected int getOrientation() {
97         return HORIZONTAL_ORIENTATION;
98     }
99
100 }
101
Popular Tags