DtColor.SRGB_BLUE_COMPONENT, true);
} else {
red = 0;
green = 0;
blue = 0;
throw new PropertyException("Unknown color format. Must "
+ "be #RGB or #RRGGBB");
}
} else if (value.startsWith("rgb(")) {
final int poss = value.indexOf("(");
final int pose = value.indexOf(")");
if (poss != -1 && pose != -1) {
value = value.substring(poss + 1, pose);
final StringTokenizer st = new StringTokenizer(value, ",");
if (st.hasMoreTokens()) {
final String str = st.nextToken().trim();
if (str.endsWith("%")) {
red =
Integer.parseInt(str.substring(0, str.length()
- 1))
* WKConstants.MAX_8_BIT_UNSIGNED_INT
/ WKConstants.PERCENT_CONVERSION;
} else {
red = Integer.parseInt(str)
/ WKConstants.MAX_8_BIT_UNSIGNED_INT;
}
}
if (st.hasMoreTokens()) {
final String str = st.nextToken().trim();
if (str.endsWith("%")) {
green =
Integer.parseInt(str.substring(0, str.length()
- 1))
* WKConstants.MAX_8_BIT_UNSIGNED_INT
/ WKConstants.PERCENT_CONVERSION;
} else {
green = Integer.parseInt(str)
/ WKConstants.MAX_8_BIT_UNSIGNED_INT;
}
}
if (st.hasMoreTokens()) {
final String str = st.nextToken().trim();
if (str.endsWith("%")) {
blue =
Integer.parseInt(str.substring(0, str.length()
- 1))
* WKConstants.MAX_8_BIT_UNSIGNED_INT
/ WKConstants.PERCENT_CONVERSION;
} else {
blue = Integer.parseInt(str)
/ WKConstants.MAX_8_BIT_UNSIGNED_INT;
}
}
}
} else if (value.startsWith("url(")) {
// refers to a gradient
} else {
if (value.toLowerCase().equals("transparent")) {
red = 0;
green = 0;
blue = 0;
alpha = 1;
} else {
final DtColor foundColor = mapNameToColorRGB(
value.toLowerCase());
if (foundColor == null) {
red = 0;
green = 0;
blue = 0;
throw new PropertyException("Unknown colour name: "
+ value);
}
return foundColor;
}
}