KickJava   Java API By Example, From Geeks To Geeks.

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


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: AbstractSVGFilterConverter.java,v 1.9 2004/08/18 07:14:58 vhardy Exp $
35  */

36 public abstract class AbstractSVGFilterConverter
37     implements SVGFilterConverter, 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 an be used by the SVGConverter extentions
57      * to create Elements and other types of DOM objects.
58      */

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

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

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