Filter inputFilter,
Rectangle2D filterRegion,
Map filterMap) {
// 'in' attribute
Filter in = getIn(filterElement,
filteredElement,
filteredNode,
inputFilter,
filterMap,
ctx);
if (in == null) {
return null; // disable the filter
}
// Default region is the size of in (if in is SourceGraphic or
// SourceAlpha it will already include a pad/crop to the
// proper filter region size).
Rectangle2D defaultRegion = in.getBounds2D();
Rectangle2D primitiveRegion
= SVGUtilities.convertFilterPrimitiveRegion(filterElement,
filteredElement,
filteredNode,
defaultRegion,
filterRegion,
ctx);
// Now, extract the various transfer functions. They are
// defined in the filterElement's children.
// Functions are ordered as follow: r, g, b, a.
ComponentTransferFunction funcR = null;
ComponentTransferFunction funcG = null;
ComponentTransferFunction funcB = null;
ComponentTransferFunction funcA = null;
for (Node n = filterElement.getFirstChild();
n != null;
n = n.getNextSibling()) {
if (n.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
Element e = (Element)n;
Bridge bridge = ctx.getBridge(e);
if (bridge == null || !(bridge instanceof SVGFeFuncElementBridge)) {
continue;
}
SVGFeFuncElementBridge funcBridge
= (SVGFeFuncElementBridge)bridge;
ComponentTransferFunction func
= funcBridge.createComponentTransferFunction(filterElement, e);
if (funcBridge instanceof SVGFeFuncRElementBridge) {
funcR = func;
} else if (funcBridge instanceof SVGFeFuncGElementBridge) {
funcG = func;
} else if (funcBridge instanceof SVGFeFuncBElementBridge) {
funcB = func;
} else if (funcBridge instanceof SVGFeFuncAElementBridge) {
funcA = func;
}
}
Filter filter = new ComponentTransferRable8Bit
(in, funcA, funcR, funcG, funcB);
// handle the 'color-interpolation-filters' property
handleColorInterpolationFilters(filter, filterElement);