KickJava   Java API By Example, From Geeks To Geeks.

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


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

35 public abstract class GlyphOrientationManager extends AbstractValueManager {
36     
37     /**
38      * Implements {@link
39      * org.apache.batik.css.engine.value.ValueManager#isInheritedProperty()}.
40      */

41     public boolean isInheritedProperty() {
42     return true;
43     }
44
45     /**
46      * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
47      */

48     public Value createValue(LexicalUnit lu, CSSEngine engine)
49         throws DOMException JavaDoc {
50         switch (lu.getLexicalUnitType()) {
51         case LexicalUnit.SAC_INHERIT:
52             return SVGValueConstants.INHERIT_VALUE;
53
54         case LexicalUnit.SAC_DEGREE:
55             return new FloatValue(CSSPrimitiveValue.CSS_DEG,
56                                   lu.getFloatValue());
57
58         case LexicalUnit.SAC_GRADIAN:
59             return new FloatValue(CSSPrimitiveValue.CSS_GRAD,
60                                   lu.getFloatValue());
61
62         case LexicalUnit.SAC_RADIAN:
63             return new FloatValue(CSSPrimitiveValue.CSS_RAD,
64                                   lu.getFloatValue());
65
66             // For SVG angle properties unit defaults to 'deg'.
67
case LexicalUnit.SAC_INTEGER:
68             {
69                 int n = lu.getIntegerValue();
70                 return new FloatValue(CSSPrimitiveValue.CSS_DEG, n);
71             }
72         case LexicalUnit.SAC_REAL:
73             {
74                 float n = lu.getFloatValue();
75                 return new FloatValue(CSSPrimitiveValue.CSS_DEG, n);
76             }
77         }
78     
79         throw createInvalidLexicalUnitDOMException(lu.getLexicalUnitType());
80     }
81
82     /**
83      * Implements {@link ValueManager#createFloatValue(short,float)}.
84      */

85     public Value createFloatValue(short type, float floatValue)
86         throws DOMException JavaDoc {
87     switch (type) {
88         case CSSPrimitiveValue.CSS_DEG:
89         case CSSPrimitiveValue.CSS_GRAD:
90         case CSSPrimitiveValue.CSS_RAD:
91             return new FloatValue(type, floatValue);
92     }
93         throw createInvalidFloatValueDOMException(floatValue);
94     }
95 }
96
Popular Tags