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.awt.geom.Rectangle2D;
022: import java.util.Map;
023:
024: import org.apache.batik.ext.awt.image.renderable.Filter;
025: import org.apache.batik.ext.awt.image.renderable.TileRable8Bit;
026: import org.apache.batik.gvt.GraphicsNode;
027: import org.w3c.dom.Element;
028:
029: /**
030: * Bridge class for the <feTile> element.
031: *
032: * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
033: * @version $Id: SVGFeTileElementBridge.java 475477 2006-11-15 22:44:28Z cam $
034: */
035: public class SVGFeTileElementBridge extends
036: AbstractSVGFilterPrimitiveElementBridge {
037:
038: /**
039: * Constructs a new bridge for the <feTile> element.
040: */
041: public SVGFeTileElementBridge() {
042: }
043:
044: /**
045: * Returns 'feTile'.
046: */
047: public String getLocalName() {
048: return SVG_FE_TILE_TAG;
049: }
050:
051: /**
052: * Creates a <tt>Filter</tt> primitive according to the specified
053: * parameters.
054: *
055: * @param ctx the bridge context to use
056: * @param filterElement the element that defines a filter
057: * @param filteredElement the element that references the filter
058: * @param filteredNode the graphics node to filter
059: *
060: * @param inputFilter the <tt>Filter</tt> that represents the current
061: * filter input if the filter chain.
062: * @param filterRegion the filter area defined for the filter chain
063: * the new node will be part of.
064: * @param filterMap a map where the mediator can map a name to the
065: * <tt>Filter</tt> it creates. Other <tt>FilterBridge</tt>s
066: * can then access a filter node from the filterMap if they
067: * know its name.
068: */
069: public Filter createFilter(BridgeContext ctx,
070: Element filterElement, Element filteredElement,
071: GraphicsNode filteredNode, Filter inputFilter,
072: Rectangle2D filterRegion, Map filterMap) {
073:
074: // Get the tiled region. For feTile, the default for the
075: // filter primitive subregion is the parent filter region.
076: Rectangle2D defaultRegion = filterRegion;
077: Rectangle2D primitiveRegion = SVGUtilities
078: .convertFilterPrimitiveRegion(filterElement,
079: filteredElement, filteredNode, defaultRegion,
080: filterRegion, ctx);
081:
082: // 'in' attribute
083: Filter in = getIn(filterElement, filteredElement, filteredNode,
084: inputFilter, filterMap, ctx);
085: if (in == null) {
086: return null; // disable the filter
087: }
088:
089: Filter filter = new TileRable8Bit(in, primitiveRegion, in
090: .getBounds2D(), false);
091:
092: // handle the 'color-interpolation-filters' property
093: handleColorInterpolationFilters(filter, filterElement);
094:
095: // update the filter Map
096: updateFilterMap(filterElement, filter, filterMap);
097:
098: return filter;
099: }
100: }
|