filteredElement,
filteredNode,
uctx);
// Build a ConcreteFilterChainRable
FilterChainRable filterChain
= new ConcreteFilterChainRable(sourceGraphic, filterRegion);
// parse the filter resolution attribute
String resStr = filterElement.getAttributeNS(null, ATTR_FILTER_RES);
Float [] filterResolution = SVGUtilities.buildFloatPair(resStr);
float filterResolutionX = -1; // -1 means undefined
if (filterResolution[0] != null) {
filterResolutionX = filterResolution[0].floatValue();
if (filterResolutionX == 0) {
return null; // zero value disable rendering of the filter
}
if (filterResolutionX < 0) {
// A negative value is an error
throw new IllegalAttributeValueException(
Messages.formatMessage("filter.filterResX.invalid", null));
}
}
float filterResolutionY = filterResolutionX; // default is filterResX
if (filterResolution[1] != null) {
filterResolutionY = filterResolution[1].floatValue();
if (filterResolutionY == 0) {
return null; // zero value disable rendering of the filter
}
if (filterResolutionY < 0) {
// A negative value is an error
throw new IllegalAttributeValueException(
Messages.formatMessage("filter.filterResY.invalid", null));
}
}
// Set resolution in filterChain
filterChain.setFilterResolutionX((int)filterResolutionX);
filterChain.setFilterResolutionY((int)filterResolutionY);
// Now build the filter chain. Create a map for filter nodes
// to advertise themselves as named sources.
Map filterNodeMap = new HashMap();
if (in == null) {
// For the filter element, the in parameter is overridden
in = sourceGraphic;
filterNodeMap.put(VALUE_SOURCE_GRAPHIC, sourceGraphic);
}
for (Node child=filterElement.getFirstChild();
child != null;
child = child.getNextSibling()) {
if (child.getNodeType() != Node.ELEMENT_NODE) {
continue; // skip node that is not an Element
}
Element elt = (Element)child;
Bridge bridge = bridgeContext.getBridge(elt);
if (bridge == null || !(bridge instanceof FilterPrimitiveBridge)) {
continue;
/*
throw new IllegalAttributeValueException(
Messages.formatMessage("filter.subelement.illegal",
new Object[] {elt.getLocalName()}));*/
}
FilterPrimitiveBridge filterBridge =
(FilterPrimitiveBridge)bridge;
Filter filterNode = filterBridge.create(filteredNode,
bridgeContext,
elt,
filteredElement,
in,
filterRegion,
filterNodeMap);
if (filterNode == null) {
throw new IllegalAttributeValueException(
Messages.formatMessage("filter.subelement.invalid",
new Object[] {elt.getLocalName()}));
}
in = filterNode;
}
// Set the source on the filter node
if(in != sourceGraphic){
filterChain.setSource(in);
} else {
// No child filter node. Disable filter
//filterChain.setSource(null);
return null;
}