// Extract the matrix type. Interpret the values accordingly.
//
String typeStr = filterElement.getAttributeNS(null, ATTR_TYPE);
int type = convertType(typeStr);
String valuesStr = filterElement.getAttributeNS(null, ATTR_VALUES);
ColorMatrixRable colorMatrix;
switch(type){
case ColorMatrixRable.TYPE_MATRIX:
float matrix[][] = convertValuesToMatrix(valuesStr);
colorMatrix = ConcreteColorMatrixRable.buildMatrix(matrix);
break;
case ColorMatrixRable.TYPE_SATURATE:
float s = 1;
if (valuesStr.length() > 0) {
s = CSSUtilities.convertRatio(valuesStr);
}
colorMatrix = ConcreteColorMatrixRable.buildSaturate(s);
break;
case ColorMatrixRable.TYPE_HUE_ROTATE:
float a = 0; // default is 0
if (valuesStr.length() > 0) {
a = (float) (SVGUtilities.convertSVGNumber(ATTR_VALUES, valuesStr) * Math.PI/180);
}
colorMatrix = ConcreteColorMatrixRable.buildHueRotate(a);
break;
case ColorMatrixRable.TYPE_LUMINANCE_TO_ALPHA:
colorMatrix = ConcreteColorMatrixRable.buildLuminanceToAlpha();
break;
default:
/* Never happen: Bad type is catched previously */
throw new Error();
}
colorMatrix.setSource(in);
filter = new ConcretePadRable(colorMatrix,
primitiveRegion,
PadMode.ZERO_PAD);