if (poss != -1 && pose != -1) {
try {
String[] args = value.substring(poss + 1, pose).split(",");
if (args.length != 6) {
throw new PropertyException("cie-lab-color() function must have 6 arguments");
}
//Set up fallback sRGB value
float red = parseComponent255(args[0], value);
float green = parseComponent255(args[1], value);
float blue = parseComponent255(args[2], value);
Color sRGB = new Color(red, green, blue);
float l = parseComponent(args[3], 0f, 100f, value);
float a = parseComponent(args[4], -127f, 127f, value);
float b = parseComponent(args[5], -127f, 127f, value);
//Assuming the XSL-FO spec uses the D50 white point
CIELabColorSpace cs = ColorSpaces.getCIELabColorSpaceD50();
//use toColor() to have components normalized
Color labColor = cs.toColor(l, a, b, 1.0f);
//Convert to ColorWithFallback
parsedColor = new ColorWithFallback(labColor, sRGB);
} catch (RuntimeException re) {
throw new PropertyException(re);
}
} else {
throw new PropertyException("Unknown color format: " + value
+ ". Must be cie-lab-color(r,g,b,Lightness,a-value,b-value)");
}
return parsedColor;
}