KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > extension > svg > BatikDomExtension


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.extension.svg;
19
20 import org.apache.batik.css.engine.value.LengthManager;
21 import org.apache.batik.css.engine.value.svg.OpacityManager;
22 import org.apache.batik.css.engine.value.svg.SVGColorManager;
23 import org.apache.batik.dom.AbstractDocument;
24 import org.apache.batik.dom.DomExtension;
25 import org.apache.batik.dom.ExtensibleDOMImplementation;
26 import org.apache.batik.dom.svg.SVGDOMImplementation;
27 import org.w3c.dom.Document JavaDoc;
28 import org.w3c.dom.Element JavaDoc;
29
30 /**
31  * This is a Service interface for classes that want to extend the
32  * functionality of the Dom, to support new tags in the rendering tree.
33  */

34 public class BatikDomExtension
35     implements DomExtension, BatikExtConstants {
36
37     /**
38      * Return the priority of this Extension. Extensions are
39      * registered from lowest to highest priority. So if for some
40      * reason you need to come before/after another existing extension
41      * make sure your priority is lower/higher than theirs.
42      */

43     public float getPriority() { return 1f; }
44
45     /**
46      * This should return the individual or company name responsible
47      * for the this implementation of the extension.
48      */

49     public String JavaDoc getAuthor() {
50         return "Thomas DeWeese";
51     }
52
53     /**
54      * This should contain a contact address (usually an e-mail address).
55      */

56     public String JavaDoc getContactAddress() {
57         return "deweese@apache.org";
58     }
59
60     /**
61      * This should return a URL where information can be obtained on
62      * this extension.
63      */

64     public String JavaDoc getURL() {
65         return "http://xml.apache.org/batik";
66     }
67
68     /**
69      * Human readable description of the extension.
70      * Perhaps that should be a resource for internationalization?
71      * (although I suppose it could be done internally)
72      */

73     public String JavaDoc getDescription() {
74         return "Example extension to standard SVG shape tags";
75     }
76
77     /**
78      * This method should update the DomContext with support
79      * for the tags in this extension. In some rare cases it may
80      * be necessary to replace existing tag handlers, although this
81      * is discouraged.
82      *
83      * @param di The ExtensibleDOMImplementation to register the
84      * extension elements with.
85      */

86     public void registerTags(ExtensibleDOMImplementation di) {
87         di.registerCustomElementFactory
88             (BATIK_EXT_NAMESPACE_URI,
89              BATIK_EXT_REGULAR_POLYGON_TAG,
90              new BatikRegularPolygonElementFactory());
91
92         di.registerCustomElementFactory
93             (BATIK_EXT_NAMESPACE_URI,
94              BATIK_EXT_STAR_TAG,
95              new BatikStarElementFactory());
96
97         di.registerCustomElementFactory
98             (BATIK_EXT_NAMESPACE_URI,
99              BATIK_EXT_HISTOGRAM_NORMALIZATION_TAG,
100              new BatikHistogramNormalizationElementFactory());
101
102         di.registerCustomElementFactory
103             (BATIK_EXT_NAMESPACE_URI,
104              BATIK_EXT_COLOR_SWITCH_TAG,
105              new ColorSwitchElementFactory());
106
107         di.registerCustomElementFactory
108             (BATIK_12_NAMESPACE_URI,
109              BATIK_EXT_FLOW_TEXT_TAG,
110              new FlowTextElementFactory());
111
112         di.registerCustomElementFactory
113             (BATIK_12_NAMESPACE_URI,
114              BATIK_EXT_FLOW_DIV_TAG,
115              new FlowDivElementFactory());
116
117         di.registerCustomElementFactory
118             (BATIK_12_NAMESPACE_URI,
119              BATIK_EXT_FLOW_PARA_TAG,
120              new FlowParaElementFactory());
121
122         di.registerCustomElementFactory
123             (BATIK_12_NAMESPACE_URI,
124              BATIK_EXT_FLOW_REGION_BREAK_TAG,
125              new FlowRegionBreakElementFactory());
126
127         di.registerCustomElementFactory
128             (BATIK_12_NAMESPACE_URI,
129              BATIK_EXT_FLOW_REGION_TAG,
130              new FlowRegionElementFactory());
131
132         di.registerCustomElementFactory
133             (BATIK_12_NAMESPACE_URI,
134              BATIK_EXT_FLOW_LINE_TAG,
135              new FlowLineElementFactory());
136
137         di.registerCustomElementFactory
138             (BATIK_12_NAMESPACE_URI,
139              BATIK_EXT_FLOW_SPAN_TAG,
140              new FlowSpanElementFactory());
141     }
142
143     /**
144      * To create a 'regularPolygon' element.
145      */

146     protected static class BatikRegularPolygonElementFactory
147         implements ExtensibleDOMImplementation.ElementFactory {
148         public BatikRegularPolygonElementFactory() {}
149         /**
150          * Creates an instance of the associated element type.
151          */

152         public Element JavaDoc create(String JavaDoc prefix, Document doc) {
153             return new BatikRegularPolygonElement
154                 (prefix, (AbstractDocument)doc);
155         }
156     }
157
158
159     /**
160      * To create a 'star' element.
161      */

162     protected static class BatikStarElementFactory
163         implements ExtensibleDOMImplementation.ElementFactory {
164         public BatikStarElementFactory() {}
165         /**
166          * Creates an instance of the associated element type.
167          */

168         public Element JavaDoc create(String JavaDoc prefix, Document doc) {
169             return new BatikStarElement(prefix, (AbstractDocument)doc);
170         }
171     }
172
173     /**
174      * To create a 'histogramNormalization' element.
175      */

176     protected static class BatikHistogramNormalizationElementFactory
177         implements ExtensibleDOMImplementation.ElementFactory {
178         public BatikHistogramNormalizationElementFactory() {}
179         /**
180          * Creates an instance of the associated element type.
181          */

182         public Element JavaDoc create(String JavaDoc prefix, Document doc) {
183             return new BatikHistogramNormalizationElement
184                 (prefix, (AbstractDocument)doc);
185         }
186     }
187
188     /**
189      * To create a 'colorSwitch' element.
190      */

191     protected static class ColorSwitchElementFactory
192         implements ExtensibleDOMImplementation.ElementFactory {
193         public ColorSwitchElementFactory() {
194         }
195         /**
196          * Creates an instance of the associated element type.
197          */

198         public Element JavaDoc create(String JavaDoc prefix, Document doc) {
199             return new ColorSwitchElement(prefix, (AbstractDocument)doc);
200         }
201     }
202
203     /**
204      * To create a 'flowText' element.
205      */

206     protected static class FlowTextElementFactory
207         implements SVGDOMImplementation.ElementFactory {
208         public FlowTextElementFactory() {
209         }
210         /**
211          * Creates an instance of the associated element type.
212          */

213         public Element JavaDoc create(String JavaDoc prefix, Document doc) {
214             return new FlowTextElement(prefix, (AbstractDocument)doc);
215         }
216     }
217
218     /**
219      * To create a 'flowDiv' element.
220      */

221     protected static class FlowDivElementFactory
222         implements SVGDOMImplementation.ElementFactory {
223         public FlowDivElementFactory() {
224         }
225         /**
226          * Creates an instance of the associated element type.
227          */

228         public Element JavaDoc create(String JavaDoc prefix, Document doc) {
229             return new FlowDivElement(prefix, (AbstractDocument)doc);
230         }
231     }
232
233     /**
234      * To create a 'flowPara' element.
235      */

236     protected static class FlowParaElementFactory
237         implements SVGDOMImplementation.ElementFactory {
238         public FlowParaElementFactory() {
239         }
240         /**
241          * Creates an instance of the associated element type.
242          */

243         public Element JavaDoc create(String JavaDoc prefix, Document doc) {
244             return new FlowParaElement(prefix, (AbstractDocument)doc);
245         }
246     }
247
248     /**
249      * To create a 'flowRegionBreak' element.
250      */

251     protected static class FlowRegionBreakElementFactory
252         implements SVGDOMImplementation.ElementFactory {
253         public FlowRegionBreakElementFactory() {
254         }
255         /**
256          * Creates an instance of the associated element type.
257          */

258         public Element JavaDoc create(String JavaDoc prefix, Document doc) {
259             return new FlowRegionBreakElement(prefix, (AbstractDocument)doc);
260         }
261     }
262
263     /**
264      * To create a 'flowRegion' element.
265      */

266     protected static class FlowRegionElementFactory
267         implements SVGDOMImplementation.ElementFactory {
268         public FlowRegionElementFactory() {
269         }
270         /**
271          * Creates an instance of the associated element type.
272          */

273         public Element JavaDoc create(String JavaDoc prefix, Document doc) {
274             return new FlowRegionElement(prefix, (AbstractDocument)doc);
275         }
276      }
277  
278     /**
279      * To create a 'flowLine' element.
280      */

281     protected static class FlowLineElementFactory
282         implements SVGDOMImplementation.ElementFactory {
283         public FlowLineElementFactory() {
284         }
285         /**
286          * Creates an instance of the associated element type.
287          */

288         public Element JavaDoc create(String JavaDoc prefix, Document doc) {
289             return new FlowLineElement(prefix, (AbstractDocument)doc);
290         }
291     }
292  
293     /**
294      * To create a 'flowSpan' element.
295      */

296     protected static class FlowSpanElementFactory
297         implements SVGDOMImplementation.ElementFactory {
298         public FlowSpanElementFactory() {
299         }
300         /**
301          * Creates an instance of the associated element type.
302          */

303         public Element JavaDoc create(String JavaDoc prefix, Document doc) {
304             return new FlowSpanElement(prefix, (AbstractDocument)doc);
305         }
306     }
307 }
308
309
310
Popular Tags