KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

41     public SVGFeFloodElementBridge() {}
42
43     /**
44      * Returns 'feFlood'.
45      */

46     public String JavaDoc getLocalName() {
47         return SVG_FE_FLOOD_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         Rectangle2D JavaDoc primitiveRegion
77             = SVGUtilities.convertFilterPrimitiveRegion(filterElement,
78                                                         filteredElement,
79                                                         filteredNode,
80                                                         filterRegion,
81                                                         filterRegion,
82                                                         ctx);
83
84         Color JavaDoc color = CSSUtilities.convertFloodColor(filterElement, ctx);
85
86         Filter filter = new FloodRable8Bit(primitiveRegion, color);
87
88         // handle the 'color-interpolation-filters' property
89
handleColorInterpolationFilters(filter, filterElement);
90
91         // update the filter Map
92
updateFilterMap(filterElement, filter, filterMap);
93
94         return filter;
95     }
96 }
97
Popular Tags