KickJava   Java API By Example, From Geeks To Geeks.

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


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.bridge;
19
20 import java.awt.geom.Rectangle2D JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import org.apache.batik.ext.awt.image.renderable.Filter;
24 import org.apache.batik.ext.awt.image.renderable.TileRable8Bit;
25 import org.apache.batik.gvt.GraphicsNode;
26 import org.w3c.dom.Element JavaDoc;
27
28 /**
29  * Bridge class for the <feTile> element.
30  *
31  * @author <a HREF="mailto:tkormann@apache.org">Thierry Kormann</a>
32  * @version $Id: SVGFeTileElementBridge.java,v 1.13 2004/08/18 07:12:34 vhardy Exp $
33  */

34 public class SVGFeTileElementBridge
35     extends AbstractSVGFilterPrimitiveElementBridge {
36
37
38     /**
39      * Constructs a new bridge for the &lt;feTile> element.
40      */

41     public SVGFeTileElementBridge() {}
42
43     /**
44      * Returns 'feTile'.
45      */

46     public String JavaDoc getLocalName() {
47         return SVG_FE_TILE_TAG;
48     }
49
50     /**
51      * Creates a <tt>Filter</tt> primitive according to the specified
52      * parameters.
53      *
54      * @param ctx the bridge context to use
55      * @param filterElement the element that defines a filter
56      * @param filteredElement the element that references the filter
57      * @param filteredNode the graphics node to filter
58      *
59      * @param inputFilter the <tt>Filter</tt> that represents the current
60      * filter input if the filter chain.
61      * @param filterRegion the filter area defined for the filter chain
62      * the new node will be part of.
63      * @param filterMap a map where the mediator can map a name to the
64      * <tt>Filter</tt> it creates. Other <tt>FilterBridge</tt>s
65      * can then access a filter node from the filterMap if they
66      * know its name.
67      */

68     public Filter createFilter(BridgeContext ctx,
69                                Element JavaDoc filterElement,
70                                Element JavaDoc filteredElement,
71                                GraphicsNode filteredNode,
72                                Filter inputFilter,
73                                Rectangle2D JavaDoc filterRegion,
74                                Map JavaDoc filterMap) {
75
76
77         // Get the tiled region. For feTile, the default for the
78
// filter primitive subregion is the parent filter region.
79
Rectangle2D JavaDoc defaultRegion = filterRegion;
80         Rectangle2D JavaDoc primitiveRegion
81             = SVGUtilities.convertFilterPrimitiveRegion(filterElement,
82                                                         filteredElement,
83                                                         filteredNode,
84                                                         defaultRegion,
85                                                         filterRegion,
86                                                         ctx);
87
88         // 'in' attribute
89
Filter in = getIn(filterElement,
90                           filteredElement,
91                           filteredNode,
92                           inputFilter,
93                           filterMap,
94                           ctx);
95         if (in == null) {
96             return null; // disable the filter
97
}
98
99         Filter filter
100             = new TileRable8Bit(in, primitiveRegion, in.getBounds2D(), false);
101
102         // handle the 'color-interpolation-filters' property
103
handleColorInterpolationFilters(filter, filterElement);
104
105         // update the filter Map
106
updateFilterMap(filterElement, filter, filterMap);
107
108         return filter;
109     }
110 }
111
Popular Tags