KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > svggen > AbstractSVGConverter


1 /*
2
3    Copyright 2001,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.svggen;
19
20 import java.util.HashMap JavaDoc;
21 import java.util.LinkedList JavaDoc;
22 import java.util.List JavaDoc;
23 import java.util.Map JavaDoc;
24
25 /**
26  * Abstract class with common utility methods used by subclasses
27  * for specific convertion operations. It holds a reference to a
28  * domFactory Document, which many implementations use, and provides
29  * a convenience method, to offers a convertion of double values
30  * to String that remove the trailing '.' character on integral
31  * values.
32  *
33  * @author <a HREF="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
34  * @version $Id: AbstractSVGConverter.java,v 1.10 2005/03/27 08:58:35 cam Exp $
35  */

36
37 public abstract class AbstractSVGConverter implements SVGConverter, ErrorConstants {
38     /**
39      * Used by converters to create Elements and other DOM objects
40      */

41     protected SVGGeneratorContext generatorContext;
42
43     /**
44      * Map of descriptions already processed by this converter. The
45      * key type is left to the implementations
46      */

47     protected Map JavaDoc descMap = new HashMap JavaDoc();
48
49     /**
50      * Set of definitions to interpret the values of the attributes
51      * generated by this converter since its creation
52      */

53     protected List JavaDoc defSet = new LinkedList JavaDoc();
54
55     /**
56      * @param generatorContext can be used by the SVGConverter extensions
57      * to create Elements and other types of DOM objects.
58      */

59     public AbstractSVGConverter(SVGGeneratorContext generatorContext) {
60         if (generatorContext == null)
61             throw new SVGGraphics2DRuntimeException(ERR_CONTEXT_NULL);
62
63         this.generatorContext = generatorContext;
64     }
65
66     /**
67      * @return set of definitions referenced by the attribute
68      * values created by the implementation since its
69      * creation. The return value should never be null.
70      * If no definition is needed, an empty set should be
71      * returned.
72      */

73     public List JavaDoc getDefinitionSet() {
74         return defSet;
75     }
76
77     /**
78      * Utility method for subclasses.
79      */

80     public final String JavaDoc doubleString(double value) {
81         return generatorContext.doubleString(value);
82     }
83 }
84
Popular Tags