KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Copyright 2001-2002,2004 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 java.util.Collections JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.Vector JavaDoc;
23
24 import org.apache.batik.bridge.BridgeContext;
25 import org.apache.batik.bridge.BridgeExtension;
26 import org.w3c.dom.Element JavaDoc;
27
28 /**
29  * This is a Service interface for classes that want to extend the
30  * functionality of the Bridge, to support new tags in the rendering tree.
31  */

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

40     public float getPriority() { return 1f; }
41
42     /**
43      * This should return the list of extensions implemented
44      * by this BridgeExtension.
45      * @return An iterator containing strings one for each implemented
46      * extension.
47      */

48     public Iterator JavaDoc getImplementedExtensions() {
49         String JavaDoc [] extensions = {
50             "http://xml.apache.org/batik/ext/poly/1.0" ,
51             "http://xml.apache.org/batik/ext/star/1.0" ,
52             "http://xml.apache.org/batik/ext/histogramNormalization/1.0" ,
53             "http://xml.apache.org/batik/ext/colorSwitch/1.0" ,
54             "http://xml.apache.org/batik/ext/flowText/1.0" ,
55         };
56         Vector JavaDoc v = new Vector JavaDoc(extensions.length);
57         for (int i=0; i<extensions.length; i++) {
58             v.add(extensions[i]);
59         }
60         return Collections.unmodifiableList(v).iterator();
61     }
62
63     /**
64      * This should return the individual or company name responsible
65      * for the this implementation of the extension.
66      */

67     public String JavaDoc getAuthor() {
68         return "Thomas DeWeese";
69     }
70
71     /**
72      * This should contain a contact address (usually an e-mail address).
73      */

74     public String JavaDoc getContactAddress() {
75         return "deweese@apache.org";
76     }
77
78     /**
79      * This should return a URL where information can be obtained on
80      * this extension.
81      */

82     public String JavaDoc getURL() {
83         return "http://xml.apache.org/batik";
84     }
85
86     /**
87      * Human readable description of the extension.
88      * Perhaps that should be a resource for internationalization?
89      * (although I suppose it could be done internally)
90      */

91     public String JavaDoc getDescription() {
92         return "Example extension to standard SVG shape tags";
93     }
94
95     /**
96      * This method should update the BridgeContext with support
97      * for the tags in this extension. In some rare cases it may
98      * be necessary to replace existing tag handlers, although this
99      * is discouraged.
100      *
101      * @param ctx The BridgeContext instance to be updated
102      */

103     public void registerTags(BridgeContext ctx) {
104         ctx.putBridge(new BatikRegularPolygonElementBridge());
105         ctx.putBridge(new BatikStarElementBridge());
106         ctx.putBridge(new BatikHistogramNormalizationElementBridge());
107         ctx.putBridge(new BatikFlowTextElementBridge());
108         ctx.putBridge(new ColorSwitchBridge());
109     }
110
111     /**
112      * Whether the presence of the specified element should cause
113      * the document to be dynamic. If this element isn't handled
114      * by this BridgeExtension, just return false.
115      *
116      * @param e The element to check.
117      */

118     public boolean isDynamicElement(Element JavaDoc e) {
119         return false;
120     }
121 }
122
Popular Tags