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.AbstractValueManager;
023: import org.apache.batik.css.engine.value.URIValue;
024: import org.apache.batik.css.engine.value.Value;
025: import org.apache.batik.css.engine.value.ValueConstants;
026: import org.apache.batik.css.engine.value.ValueManager;
027: import org.apache.batik.util.CSSConstants;
028: import org.apache.batik.util.SVGTypes;
029:
030: import org.w3c.css.sac.LexicalUnit;
031: import org.w3c.dom.DOMException;
032: import org.w3c.dom.css.CSSPrimitiveValue;
033:
034: /**
035: * This class provides a manager for the 'marker-*' property values.
036: *
037: * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
038: * @version $Id: MarkerManager.java 475685 2006-11-16 11:16:05Z cam $
039: */
040: public class MarkerManager extends AbstractValueManager {
041:
042: /**
043: * The handled property.
044: */
045: protected String property;
046:
047: /**
048: * Creates a new MarkerManager.
049: */
050: public MarkerManager(String prop) {
051: property = prop;
052: }
053:
054: /**
055: * Implements {@link ValueManager#isInheritedProperty()}.
056: */
057: public boolean isInheritedProperty() {
058: return true;
059: }
060:
061: /**
062: * Implements {@link ValueManager#isAnimatableProperty()}.
063: */
064: public boolean isAnimatableProperty() {
065: return true;
066: }
067:
068: /**
069: * Implements {@link ValueManager#isAdditiveProperty()}.
070: */
071: public boolean isAdditiveProperty() {
072: return false;
073: }
074:
075: /**
076: * Implements {@link ValueManager#getPropertyType()}.
077: */
078: public int getPropertyType() {
079: return SVGTypes.TYPE_URI_OR_IDENT;
080: }
081:
082: /**
083: * Implements {@link ValueManager#getPropertyName()}.
084: */
085: public String getPropertyName() {
086: return property;
087: }
088:
089: /**
090: * Implements {@link ValueManager#getDefaultValue()}.
091: */
092: public Value getDefaultValue() {
093: return ValueConstants.NONE_VALUE;
094: }
095:
096: /**
097: * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
098: */
099: public Value createValue(LexicalUnit lu, CSSEngine engine)
100: throws DOMException {
101: switch (lu.getLexicalUnitType()) {
102: case LexicalUnit.SAC_INHERIT:
103: return ValueConstants.INHERIT_VALUE;
104:
105: case LexicalUnit.SAC_URI:
106: return new URIValue(lu.getStringValue(), resolveURI(engine
107: .getCSSBaseURI(), lu.getStringValue()));
108:
109: case LexicalUnit.SAC_IDENT:
110: if (lu.getStringValue().equalsIgnoreCase(
111: CSSConstants.CSS_NONE_VALUE)) {
112: return ValueConstants.NONE_VALUE;
113: }
114: }
115: throw createInvalidLexicalUnitDOMException(lu
116: .getLexicalUnitType());
117: }
118:
119: /**
120: * Implements {@link
121: * ValueManager#createStringValue(short,String,CSSEngine)}.
122: */
123: public Value createStringValue(short type, String value,
124: CSSEngine engine) throws DOMException {
125: switch (type) {
126: case CSSPrimitiveValue.CSS_IDENT:
127: if (value.equalsIgnoreCase(CSSConstants.CSS_NONE_VALUE)) {
128: return ValueConstants.NONE_VALUE;
129: }
130: break;
131:
132: case CSSPrimitiveValue.CSS_URI:
133: return new URIValue(value, resolveURI(engine
134: .getCSSBaseURI(), value));
135: }
136: throw createInvalidStringTypeDOMException(type);
137: }
138: }
|