01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19: package org.apache.batik.svggen;
20:
21: import java.util.HashMap;
22: import java.util.LinkedList;
23: import java.util.List;
24: import java.util.Map;
25:
26: /**
27: * Abstract class with common utility methods used by subclasses
28: * for specific convertion operations. It holds a reference to a
29: * domFactory Document, which many implementations use, and provides
30: * a convenience method, to offers a convertion of double values
31: * to String that remove the trailing '.' character on integral
32: * values.
33: *
34: * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
35: * @version $Id: AbstractSVGFilterConverter.java 475477 2006-11-15 22:44:28Z cam $
36: */
37: public abstract class AbstractSVGFilterConverter implements
38: SVGFilterConverter, ErrorConstants {
39: /**
40: * Used by converters to create Elements and other DOM objects
41: */
42: protected SVGGeneratorContext generatorContext;
43:
44: /**
45: * Map of descriptions already processed by this converter. The
46: * key type is left to the implementations
47: */
48: protected Map descMap = new HashMap();
49:
50: /**
51: * Set of definitions to interpret the values of the attributes
52: * generated by this converter since its creation
53: */
54: protected List defSet = new LinkedList();
55:
56: /**
57: * @param generatorContext an be used by the SVGConverter extentions
58: * to create Elements and other types of DOM objects.
59: */
60: public AbstractSVGFilterConverter(
61: SVGGeneratorContext generatorContext) {
62: if (generatorContext == null)
63: throw new SVGGraphics2DRuntimeException(ERR_CONTEXT_NULL);
64: this .generatorContext = generatorContext;
65: }
66:
67: /**
68: * @return set of definitions referenced by the attribute
69: * values created by the implementation since its
70: * creation. The return value should never be null.
71: * If no definition is needed, an empty set should be
72: * returned.
73: */
74: public List getDefinitionSet() {
75: return defSet;
76: }
77:
78: /**
79: * Utility method for subclasses.
80: */
81: public final String doubleString(double value) {
82: return generatorContext.doubleString(value);
83: }
84: }
|