1 18 package org.apache.batik.bridge; 19 20 import java.awt.geom.AffineTransform ; 21 import java.awt.geom.Rectangle2D ; 22 import java.util.Map ; 23 24 import org.apache.batik.ext.awt.image.PadMode; 25 import org.apache.batik.ext.awt.image.renderable.AffineRable8Bit; 26 import org.apache.batik.ext.awt.image.renderable.Filter; 27 import org.apache.batik.ext.awt.image.renderable.PadRable; 28 import org.apache.batik.ext.awt.image.renderable.PadRable8Bit; 29 import org.apache.batik.gvt.GraphicsNode; 30 import org.w3c.dom.Element ; 31 32 38 public class SVGFeOffsetElementBridge 39 extends AbstractSVGFilterPrimitiveElementBridge { 40 41 44 public SVGFeOffsetElementBridge() {} 45 46 49 public String getLocalName() { 50 return SVG_FE_OFFSET_TAG; 51 } 52 53 71 public Filter createFilter(BridgeContext ctx, 72 Element filterElement, 73 Element filteredElement, 74 GraphicsNode filteredNode, 75 Filter inputFilter, 76 Rectangle2D filterRegion, 77 Map filterMap) { 78 79 80 Filter in = getIn(filterElement, 82 filteredElement, 83 filteredNode, 84 inputFilter, 85 filterMap, 86 ctx); 87 if (in == null) { 88 return null; } 90 91 Rectangle2D defaultRegion = in.getBounds2D(); 95 Rectangle2D primitiveRegion 96 = SVGUtilities.convertFilterPrimitiveRegion(filterElement, 97 filteredElement, 98 filteredNode, 99 defaultRegion, 100 filterRegion, 101 ctx); 102 103 float dx = convertNumber(filterElement, SVG_DX_ATTRIBUTE, 0); 104 float dy = convertNumber(filterElement, SVG_DY_ATTRIBUTE, 0); 105 AffineTransform at = AffineTransform.getTranslateInstance(dx, dy); 106 107 PadRable pad = new PadRable8Bit(in, primitiveRegion, PadMode.ZERO_PAD); 111 Filter filter = new AffineRable8Bit(pad, at); 112 filter = new PadRable8Bit(filter, primitiveRegion, PadMode.ZERO_PAD); 113 114 handleColorInterpolationFilters(filter, filterElement); 116 117 updateFilterMap(filterElement, filter, filterMap); 119 120 return filter; 121 } 122 } 123 | Popular Tags |