String colorName = args[4].getString();
Declarations decls = (pInfo.getFO() != null
? pInfo.getFO().getRoot().getDeclarations()
: null);
ColorProfile cp = null;
if (decls != null) {
cp = decls.getColorProfile(colorProfileName);
}
if (cp == null) {
PropertyException pe = new PropertyException("The " + colorProfileName
+ " color profile was not declared");
pe.setPropertyInfo(pInfo);
throw pe;
}
float red = 0;
float green = 0;
float blue = 0;
red = args[0].getNumber().floatValue();
green = args[1].getNumber().floatValue();
blue = args[2].getNumber().floatValue();
/* Verify rgb replacement arguments */
if ((red < 0 || red > 255)
|| (green < 0 || green > 255)
|| (blue < 0 || blue > 255)) {
throw new PropertyException("sRGB color values out of range. "
+ "Arguments to rgb-named-color() must be [0..255] or [0%..100%]");
}
// rgb-named-color is replaced with fop-rgb-named-color which has an extra argument
// containing the color profile src attribute as it is defined in the color-profile
// declarations element.
StringBuffer sb = new StringBuffer();
sb.append("fop-rgb-named-color(");
sb.append(red / 255f);
sb.append(',').append(green / 255f);
sb.append(',').append(blue / 255f);
sb.append(',').append(colorProfileName);
sb.append(',').append(cp.getSrc());
sb.append(", '").append(colorName).append('\'');
sb.append(")");
return ColorProperty.getInstance(pInfo.getUserAgent(), sb.toString());
}