KickJava   Java API By Example, From Geeks To Geeks.

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


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.apache.batik.util.CSSConstants;
26 import org.w3c.css.sac.LexicalUnit;
27 import org.w3c.dom.DOMException JavaDoc;
28 import org.w3c.dom.css.CSSPrimitiveValue;
29
30 /**
31  * This class provides a factory for the 'stroke-miterlimit' property values.
32  *
33  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
34  * @version $Id: StrokeMiterlimitManager.java,v 1.5 2005/03/27 08:58:31 cam Exp $
35  */

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

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

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

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

62     public Value createValue(LexicalUnit lu, CSSEngine engine)
63         throws DOMException JavaDoc {
64     switch (lu.getLexicalUnitType()) {
65     case LexicalUnit.SAC_INHERIT:
66         return SVGValueConstants.INHERIT_VALUE;
67
68     case LexicalUnit.SAC_INTEGER:
69         return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
70                                   lu.getIntegerValue());
71
72     case LexicalUnit.SAC_REAL:
73         return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
74                                   lu.getFloatValue());
75
76     default:
77             throw createInvalidLexicalUnitDOMException
78                 (lu.getLexicalUnitType());
79         }
80     }
81
82     /**
83      * Implements {@link ValueManager#createFloatValue(short,float)}.
84      */

85     public Value createFloatValue(short unitType, float floatValue)
86     throws DOMException JavaDoc {
87     if (unitType == CSSPrimitiveValue.CSS_NUMBER) {
88         return new FloatValue(unitType, floatValue);
89     }
90         throw createInvalidFloatTypeDOMException(unitType);
91     }
92 }
93
Popular Tags