KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > css > engine > value > svg12 > MarginLengthManager


1 /*
2
3    Copyright 2004 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
19 package org.apache.batik.css.engine.value.svg12;
20
21 import org.apache.batik.css.engine.CSSEngine;
22 import org.apache.batik.css.engine.value.LengthManager;
23 import org.apache.batik.css.engine.value.Value;
24 import org.apache.batik.css.engine.value.ValueManager;
25 import org.apache.batik.css.engine.value.svg.SVGValueConstants;
26 import org.w3c.css.sac.LexicalUnit;
27 import org.w3c.dom.DOMException JavaDoc;
28
29 /**
30  * This class provides a factory for the 'margin-*' properties values.
31  *
32  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
33  * @version $Id: MarginLengthManager.java,v 1.2 2005/03/27 08:58:31 cam Exp $
34  */

35 public class MarginLengthManager extends LengthManager {
36
37     protected String JavaDoc prop;
38
39     public MarginLengthManager(String JavaDoc prop) {
40         this.prop = prop;
41     }
42     
43     /**
44      * Implements {@link ValueManager#isInheritedProperty()}.
45      */

46     public boolean isInheritedProperty() {
47     return true;
48     }
49
50     /**
51      * Implements {@link ValueManager#getPropertyName()}.
52      */

53     public String JavaDoc getPropertyName() {
54     return prop;
55     }
56     
57     /**
58      * Implements {@link ValueManager#getDefaultValue()}.
59      */

60     public Value getDefaultValue() {
61         return SVGValueConstants.NUMBER_0;
62     }
63
64     /**
65      * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
66      */

67     public Value createValue(LexicalUnit lu, CSSEngine engine)
68         throws DOMException JavaDoc {
69         if (lu.getLexicalUnitType() == LexicalUnit.SAC_INHERIT) {
70             return SVGValueConstants.INHERIT_VALUE;
71         }
72         return super.createValue(lu, engine);
73     }
74
75
76     /**
77      * Indicates the orientation of the property associated with
78      * this manager.
79      */

80     protected int getOrientation() {
81         // Margins are always wrt to block width, event for top/bottom.
82
return HORIZONTAL_ORIENTATION;
83     }
84 }
85
Popular Tags