001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.bridge;
020:
021: import java.util.Collections;
022: import java.util.Iterator;
023:
024: import org.apache.batik.util.SVGConstants;
025: import org.w3c.dom.Element;
026:
027: /**
028: * This is a Service interface for classes that want to extend the
029: * functionality of the Bridge, to support new tags in the rendering tree.
030: *
031: * @author <a href="mailto:thomas.deweese@kodak.com">Thomas DeWeese</a>
032: * @version $Id: SVGBridgeExtension.java 475477 2006-11-15 22:44:28Z cam $
033: */
034: public class SVGBridgeExtension implements BridgeExtension {
035:
036: /**
037: * Return the priority of this Extension. Extensions are
038: * registered from lowest to highest priority. So if for some
039: * reason you need to come before/after another existing extension
040: * make sure your priority is lower/higher than theirs.
041: */
042: public float getPriority() {
043: return 0f;
044: }
045:
046: /**
047: * This should return the list of extensions implemented
048: * by this BridgeExtension.
049: * @return An iterator containing strings one for each implemented
050: * extension.
051: */
052: public Iterator getImplementedExtensions() {
053: return Collections.EMPTY_LIST.iterator();
054: }
055:
056: /**
057: * This should return the individual or company name responsible
058: * for the this implementation of the extension.
059: */
060: public String getAuthor() {
061: return "The Apache Batik Team.";
062: }
063:
064: /**
065: * This should contain a contact address (usually an e-mail address).
066: */
067: public String getContactAddress() {
068: return "batik-dev@xmlgraphics.apache.org";
069: }
070:
071: /**
072: * This should return a URL where information can be obtained on
073: * this extension.
074: */
075: public String getURL() {
076: return "http://xml.apache.org/batik";
077: }
078:
079: /**
080: * Human readable description of the extension.
081: * Perhaps that should be a resource for internationalization?
082: * (although I suppose it could be done internally)
083: */
084: public String getDescription() {
085: return "The required SVG 1.0 tags";
086: }
087:
088: /**
089: * This method should update the BridgeContext with support
090: * for the tags in this extension. In some rare cases it may
091: * be necessary to replace existing tag handlers, although this
092: * is discouraged.
093: *
094: * @param ctx The BridgeContext instance to be updated
095: */
096: public void registerTags(BridgeContext ctx) {
097: // bridges to handle elements in the SVG namespace
098:
099: ctx.putBridge(new SVGAElementBridge());
100: ctx.putBridge(new SVGAltGlyphElementBridge());
101: ctx.putBridge(new SVGCircleElementBridge());
102: ctx.putBridge(new SVGClipPathElementBridge());
103: ctx.putBridge(new SVGColorProfileElementBridge());
104: ctx.putBridge(new SVGDescElementBridge());
105: ctx.putBridge(new SVGEllipseElementBridge());
106: ctx.putBridge(new SVGFeBlendElementBridge());
107: ctx.putBridge(new SVGFeColorMatrixElementBridge());
108: ctx.putBridge(new SVGFeComponentTransferElementBridge());
109: ctx.putBridge(new SVGFeCompositeElementBridge());
110: ctx
111: .putBridge(new SVGFeComponentTransferElementBridge.SVGFeFuncAElementBridge());
112: ctx
113: .putBridge(new SVGFeComponentTransferElementBridge.SVGFeFuncRElementBridge());
114: ctx
115: .putBridge(new SVGFeComponentTransferElementBridge.SVGFeFuncGElementBridge());
116: ctx
117: .putBridge(new SVGFeComponentTransferElementBridge.SVGFeFuncBElementBridge());
118: ctx.putBridge(new SVGFeConvolveMatrixElementBridge());
119: ctx.putBridge(new SVGFeDiffuseLightingElementBridge());
120: ctx.putBridge(new SVGFeDisplacementMapElementBridge());
121: ctx
122: .putBridge(new AbstractSVGLightingElementBridge.SVGFeDistantLightElementBridge());
123: ctx.putBridge(new SVGFeFloodElementBridge());
124: ctx.putBridge(new SVGFeGaussianBlurElementBridge());
125: ctx.putBridge(new SVGFeImageElementBridge());
126: ctx.putBridge(new SVGFeMergeElementBridge());
127: ctx
128: .putBridge(new SVGFeMergeElementBridge.SVGFeMergeNodeElementBridge());
129: ctx.putBridge(new SVGFeMorphologyElementBridge());
130: ctx.putBridge(new SVGFeOffsetElementBridge());
131: ctx
132: .putBridge(new AbstractSVGLightingElementBridge.SVGFePointLightElementBridge());
133: ctx.putBridge(new SVGFeSpecularLightingElementBridge());
134: ctx
135: .putBridge(new AbstractSVGLightingElementBridge.SVGFeSpotLightElementBridge());
136: ctx.putBridge(new SVGFeTileElementBridge());
137: ctx.putBridge(new SVGFeTurbulenceElementBridge());
138: ctx.putBridge(new SVGFontElementBridge());
139: ctx.putBridge(new SVGFontFaceElementBridge());
140: ctx.putBridge(new SVGFilterElementBridge());
141: ctx.putBridge(new SVGGElementBridge());
142: ctx.putBridge(new SVGGlyphElementBridge());
143: ctx.putBridge(new SVGHKernElementBridge());
144: ctx.putBridge(new SVGImageElementBridge());
145: ctx.putBridge(new SVGLineElementBridge());
146: ctx.putBridge(new SVGLinearGradientElementBridge());
147: ctx.putBridge(new SVGMarkerElementBridge());
148: ctx.putBridge(new SVGMaskElementBridge());
149: ctx.putBridge(new SVGMissingGlyphElementBridge());
150: ctx.putBridge(new SVGPathElementBridge());
151: ctx.putBridge(new SVGPatternElementBridge());
152: ctx.putBridge(new SVGPolylineElementBridge());
153: ctx.putBridge(new SVGPolygonElementBridge());
154: ctx.putBridge(new SVGRadialGradientElementBridge());
155: ctx.putBridge(new SVGRectElementBridge());
156: ctx
157: .putBridge(new AbstractSVGGradientElementBridge.SVGStopElementBridge());
158: ctx.putBridge(new SVGSVGElementBridge());
159: ctx.putBridge(new SVGSwitchElementBridge());
160: ctx.putBridge(new SVGTextElementBridge());
161: ctx.putBridge(new SVGTextPathElementBridge());
162: ctx.putBridge(new SVGTitleElementBridge());
163: ctx.putBridge(new SVGUseElementBridge());
164: ctx.putBridge(new SVGVKernElementBridge());
165: ctx.putBridge(new SVGSetElementBridge());
166: ctx.putBridge(new SVGAnimateElementBridge());
167: ctx.putBridge(new SVGAnimateColorElementBridge());
168: ctx.putBridge(new SVGAnimateTransformElementBridge());
169: ctx.putBridge(new SVGAnimateMotionElementBridge());
170: }
171:
172: /**
173: * Whether the presence of the specified element should cause
174: * the document to be dynamic. If this element isn't handled
175: * by this BridgeExtension, just return false.
176: *
177: * @param e The element to check.
178: */
179: public boolean isDynamicElement(Element e) {
180: String ns = e.getNamespaceURI();
181: if (!SVGConstants.SVG_NAMESPACE_URI.equals(ns)) {
182: return false;
183: }
184: String ln = e.getLocalName();
185: if (ln.equals(SVGConstants.SVG_SCRIPT_TAG)
186: || ln.startsWith("animate")
187: || ln.equals(SVGConstants.SVG_SET_TAG)) {
188: return true;
189: }
190: return false;
191: }
192: }
|