01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19: package org.apache.batik.bridge;
20:
21: import java.awt.Color;
22: import java.awt.geom.Rectangle2D;
23: import java.util.Map;
24:
25: import org.apache.batik.ext.awt.image.renderable.Filter;
26: import org.apache.batik.ext.awt.image.renderable.FloodRable8Bit;
27: import org.apache.batik.gvt.GraphicsNode;
28: import org.w3c.dom.Element;
29:
30: /**
31: * Bridge class for the <feFlood> element.
32: *
33: * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
34: * @version $Id: SVGFeFloodElementBridge.java 475477 2006-11-15 22:44:28Z cam $
35: */
36: public class SVGFeFloodElementBridge extends
37: AbstractSVGFilterPrimitiveElementBridge {
38:
39: /**
40: * Constructs a new bridge for the <feFlood> element.
41: */
42: public SVGFeFloodElementBridge() {
43: }
44:
45: /**
46: * Returns 'feFlood'.
47: */
48: public String getLocalName() {
49: return SVG_FE_FLOOD_TAG;
50: }
51:
52: /**
53: * Creates a <tt>Filter</tt> primitive according to the specified
54: * parameters.
55: *
56: * @param ctx the bridge context to use
57: * @param filterElement the element that defines a filter
58: * @param filteredElement the element that references the filter
59: * @param filteredNode the graphics node to filter
60: *
61: * @param inputFilter the <tt>Filter</tt> that represents the current
62: * filter input if the filter chain.
63: * @param filterRegion the filter area defined for the filter chain
64: * the new node will be part of.
65: * @param filterMap a map where the mediator can map a name to the
66: * <tt>Filter</tt> it creates. Other <tt>FilterBridge</tt>s
67: * can then access a filter node from the filterMap if they
68: * know its name.
69: */
70: public Filter createFilter(BridgeContext ctx,
71: Element filterElement, Element filteredElement,
72: GraphicsNode filteredNode, Filter inputFilter,
73: Rectangle2D filterRegion, Map filterMap) {
74:
75: Rectangle2D primitiveRegion = SVGUtilities
76: .convertFilterPrimitiveRegion(filterElement,
77: filteredElement, filteredNode, filterRegion,
78: filterRegion, ctx);
79:
80: Color color = CSSUtilities
81: .convertFloodColor(filterElement, ctx);
82:
83: Filter filter = new FloodRable8Bit(primitiveRegion, color);
84:
85: // handle the 'color-interpolation-filters' property
86: handleColorInterpolationFilters(filter, filterElement);
87:
88: // update the filter Map
89: updateFilterMap(filterElement, filter, filterMap);
90:
91: return filter;
92: }
93: }
|