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);
int type = convertType(filterElement);
ColorMatrixRable colorMatrix;
switch (type) {
case ColorMatrixRable.TYPE_HUE_ROTATE:
float a = convertValuesToHueRotate(filterElement);
colorMatrix = ColorMatrixRable8Bit.buildHueRotate(a);
break;
case ColorMatrixRable.TYPE_LUMINANCE_TO_ALPHA:
colorMatrix = ColorMatrixRable8Bit.buildLuminanceToAlpha();
break;
case ColorMatrixRable.TYPE_MATRIX:
float [][] matrix = convertValuesToMatrix(filterElement);
colorMatrix = ColorMatrixRable8Bit.buildMatrix(matrix);
break;
case ColorMatrixRable.TYPE_SATURATE:
float s = convertValuesToSaturate(filterElement);
colorMatrix = ColorMatrixRable8Bit.buildSaturate(s);
break;
default:
throw new Error(); // can't be reached
}
colorMatrix.setSource(in);
// handle the 'color-interpolation-filters' property
handleColorInterpolationFilters(colorMatrix, filterElement);
Filter filter
= new PadRable8Bit(colorMatrix, primitiveRegion, PadMode.ZERO_PAD);
// update the filter Map
updateFilterMap(filterElement, filter, filterMap);