001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.css.engine.value.svg;
020:
021: import org.apache.batik.css.engine.CSSEngine;
022: import org.apache.batik.css.engine.value.LengthManager;
023: import org.apache.batik.css.engine.value.Value;
024: import org.apache.batik.css.engine.value.ValueManager;
025: import org.apache.batik.util.CSSConstants;
026: import org.apache.batik.util.SVGTypes;
027:
028: import org.w3c.css.sac.LexicalUnit;
029: import org.w3c.dom.DOMException;
030: import org.w3c.dom.css.CSSPrimitiveValue;
031:
032: /**
033: * This class provides a manager for the 'kerning' property values.
034: *
035: * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
036: * @version $Id: KerningManager.java 475685 2006-11-16 11:16:05Z cam $
037: */
038: public class KerningManager extends LengthManager {
039:
040: /**
041: * Implements {@link ValueManager#isInheritedProperty()}.
042: */
043: public boolean isInheritedProperty() {
044: return true;
045: }
046:
047: /**
048: * Implements {@link ValueManager#getPropertyName()}.
049: */
050: public String getPropertyName() {
051: return CSSConstants.CSS_KERNING_PROPERTY;
052: }
053:
054: /**
055: * Implements {@link ValueManager#isAnimatableProperty()}.
056: */
057: public boolean isAnimatableProperty() {
058: return true;
059: }
060:
061: /**
062: * Implements {@link ValueManager#isAdditiveProperty()}.
063: */
064: public boolean isAdditiveProperty() {
065: return true;
066: }
067:
068: /**
069: * Implements {@link ValueManager#getPropertyType()}.
070: */
071: public int getPropertyType() {
072: return SVGTypes.TYPE_KERNING_VALUE;
073: }
074:
075: /**
076: * Implements {@link ValueManager#getDefaultValue()}.
077: */
078: public Value getDefaultValue() {
079: return SVGValueConstants.AUTO_VALUE;
080: }
081:
082: /**
083: * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
084: */
085: public Value createValue(LexicalUnit lu, CSSEngine engine)
086: throws DOMException {
087: switch (lu.getLexicalUnitType()) {
088: case LexicalUnit.SAC_INHERIT:
089: return SVGValueConstants.INHERIT_VALUE;
090:
091: case LexicalUnit.SAC_IDENT:
092: if (lu.getStringValue().equalsIgnoreCase(
093: CSSConstants.CSS_AUTO_VALUE)) {
094: return SVGValueConstants.AUTO_VALUE;
095: }
096: throw createInvalidIdentifierDOMException(lu
097: .getStringValue());
098: }
099: return super .createValue(lu, engine);
100: }
101:
102: /**
103: * Implements {@link
104: * ValueManager#createStringValue(short,String,CSSEngine)}.
105: */
106: public Value createStringValue(short type, String value,
107: CSSEngine engine) throws DOMException {
108: if (type != CSSPrimitiveValue.CSS_IDENT) {
109: throw createInvalidStringTypeDOMException(type);
110: }
111: if (value.equalsIgnoreCase(CSSConstants.CSS_AUTO_VALUE)) {
112: return SVGValueConstants.AUTO_VALUE;
113: }
114: throw createInvalidIdentifierDOMException(value);
115: }
116:
117: /**
118: * Indicates the orientation of the property associated with
119: * this manager.
120: */
121: protected int getOrientation() {
122: return HORIZONTAL_ORIENTATION;
123: }
124:
125: }
|