KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > bridge > SVGBridgeExtension


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

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

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

46     public Iterator JavaDoc getImplementedExtensions() {
47         return Collections.EMPTY_LIST.iterator();
48     }
49
50     /**
51      * This should return the individual or company name responsible
52      * for the this implementation of the extension.
53      */

54     public String JavaDoc getAuthor() {
55         return "The Apache Batik Team.";
56     }
57
58     /**
59      * This should contain a contact address (usually an e-mail address).
60      */

61     public String JavaDoc getContactAddress() {
62         return "batik-dev@xmlgraphics.apache.org";
63     }
64
65     /**
66      * This should return a URL where information can be obtained on
67      * this extension.
68      */

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

78     public String JavaDoc getDescription() {
79         return "The required SVG 1.0 tags";
80     }
81
82     /**
83      * This method should update the BridgeContext with support
84      * for the tags in this extension. In some rare cases it may
85      * be necessary to replace existing tag handlers, although this
86      * is discouraged.
87      *
88      * @param ctx The BridgeContext instance to be updated
89      */

90     public void registerTags(BridgeContext ctx) {
91         // bridges to handle elements in the SVG namespace
92

93         ctx.putBridge(new SVGAElementBridge());
94         ctx.putBridge(new SVGAltGlyphElementBridge());
95         ctx.putBridge(new SVGCircleElementBridge());
96         ctx.putBridge(new SVGClipPathElementBridge());
97         ctx.putBridge(new SVGColorProfileElementBridge());
98         ctx.putBridge(new SVGDescElementBridge());
99         ctx.putBridge(new SVGEllipseElementBridge());
100         ctx.putBridge(new SVGFeBlendElementBridge());
101         ctx.putBridge(new SVGFeColorMatrixElementBridge());
102         ctx.putBridge(new SVGFeComponentTransferElementBridge());
103         ctx.putBridge(new SVGFeCompositeElementBridge());
104         ctx.putBridge(new SVGFeComponentTransferElementBridge.SVGFeFuncAElementBridge());
105         ctx.putBridge(new SVGFeComponentTransferElementBridge.SVGFeFuncRElementBridge());
106         ctx.putBridge(new SVGFeComponentTransferElementBridge.SVGFeFuncGElementBridge());
107         ctx.putBridge(new SVGFeComponentTransferElementBridge.SVGFeFuncBElementBridge());
108         ctx.putBridge(new SVGFeConvolveMatrixElementBridge());
109         ctx.putBridge(new SVGFeDiffuseLightingElementBridge());
110         ctx.putBridge(new SVGFeDisplacementMapElementBridge());
111         ctx.putBridge(new AbstractSVGLightingElementBridge.SVGFeDistantLightElementBridge());
112         ctx.putBridge(new SVGFeFloodElementBridge());
113         ctx.putBridge(new SVGFeGaussianBlurElementBridge());
114         ctx.putBridge(new SVGFeImageElementBridge());
115         ctx.putBridge(new SVGFeMergeElementBridge());
116         ctx.putBridge(new SVGFeMergeElementBridge.SVGFeMergeNodeElementBridge());
117         ctx.putBridge(new SVGFeMorphologyElementBridge());
118         ctx.putBridge(new SVGFeOffsetElementBridge());
119         ctx.putBridge(new AbstractSVGLightingElementBridge.SVGFePointLightElementBridge());
120         ctx.putBridge(new SVGFeSpecularLightingElementBridge());
121         ctx.putBridge(new AbstractSVGLightingElementBridge.SVGFeSpotLightElementBridge());
122         ctx.putBridge(new SVGFeTileElementBridge());
123         ctx.putBridge(new SVGFeTurbulenceElementBridge());
124         ctx.putBridge(new SVGFontElementBridge());
125         ctx.putBridge(new SVGFontFaceElementBridge());
126         ctx.putBridge(new SVGFilterElementBridge());
127         ctx.putBridge(new SVGGElementBridge());
128         ctx.putBridge(new SVGGlyphElementBridge());
129         ctx.putBridge(new SVGHKernElementBridge());
130         ctx.putBridge(new SVGImageElementBridge());
131         ctx.putBridge(new SVGLineElementBridge());
132         ctx.putBridge(new SVGLinearGradientElementBridge());
133         ctx.putBridge(new SVGMarkerElementBridge());
134         ctx.putBridge(new SVGMaskElementBridge());
135         ctx.putBridge(new SVGMissingGlyphElementBridge());
136         ctx.putBridge(new SVGPathElementBridge());
137         ctx.putBridge(new SVGPatternElementBridge());
138         ctx.putBridge(new SVGPolylineElementBridge());
139         ctx.putBridge(new SVGPolygonElementBridge());
140         ctx.putBridge(new SVGRadialGradientElementBridge());
141         ctx.putBridge(new SVGRectElementBridge());
142         ctx.putBridge(new AbstractSVGGradientElementBridge.SVGStopElementBridge());
143         ctx.putBridge(new SVGSVGElementBridge());
144         ctx.putBridge(new SVGSwitchElementBridge());
145         ctx.putBridge(new SVGTextElementBridge());
146         ctx.putBridge(new SVGTextPathElementBridge());
147         ctx.putBridge(new SVGTitleElementBridge());
148         ctx.putBridge(new SVGUseElementBridge());
149         ctx.putBridge(new SVGVKernElementBridge());
150
151     }
152
153     /**
154      * Whether the presence of the specified element should cause
155      * the document to be dynamic. If this element isn't handled
156      * by this BridgeExtension, just return false.
157      *
158      * @param e The element to check.
159      */

160     public boolean isDynamicElement(Element JavaDoc e) {
161         String JavaDoc ns = e.getNamespaceURI();
162         if (!SVGConstants.SVG_NAMESPACE_URI.equals(ns)) {
163             return false;
164         }
165         String JavaDoc ln = e.getLocalName();
166         if (ln.equals(SVGConstants.SVG_SCRIPT_TAG)
167                 || ln.startsWith("animate")
168                 || ln.equals("set")) {
169             return true;
170         }
171         return false;
172     }
173 }
174
Popular Tags