MatchResult result = COLORNAME.exec(cssText);
if (result != null && result.getGroupCount() == 2) {
// color name
rgbColor = getNamedColor(result.getGroup(1));
if (rgbColor == null) {
throw new JavaScriptException("Unknown color keyword: " + cssText);
}
iccColor = COLORNAME.getLastIndex() == cssText.length() ? null : cssText.substring(COLORNAME.getLastIndex());
}
if (rgbColor == null) {
RGB255.setLastIndex(0);
result = RGB255.exec(cssText);
if (result != null && result.getGroupCount() == 4) {
rgbColor = result.getGroup(0);
iccColor = RGB255.getLastIndex() == cssText.length() ? null : cssText.substring(RGB255.getLastIndex());
}
}
if (rgbColor == null) {
RGBPCT.setLastIndex(0);
result = RGBPCT.exec(cssText);
if (result != null && result.getGroupCount() == 4) {
rgbColor = result.getGroup(0);
iccColor = RGBPCT.getLastIndex() == cssText.length() ? null : cssText.substring(RGBPCT.getLastIndex());
}
}
if (rgbColor == null) {
RGBHEX.setLastIndex(0);
result = RGBHEX.exec(cssText);
if (result != null && result.getGroupCount() == 2) {
rgbColor = result.getGroup(0);
iccColor = RGBHEX.getLastIndex() == cssText.length() ? null : cssText.substring(RGBHEX.getLastIndex());
}
}
}
short paintType;
if (rgbColor != null) {
if (uri != null) {
paintType = iccColor == null ? OMSVGPaint.SVG_PAINTTYPE_URI_RGBCOLOR : OMSVGPaint.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR;
} else {
paintType = iccColor == null ? OMSVGPaint.SVG_PAINTTYPE_RGBCOLOR : OMSVGPaint.SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR;
}
} else {
if (uri != null) {
paintType = OMSVGPaint.SVG_PAINTTYPE_URI;
} else {
throw new JavaScriptException("Invalid paint spec: " + cssText);
}
}
OMSVGPaint paint = new OMSVGPaint(paintType);
paint.setPaint(paintType, uri, rgbColor, iccColor);
return paint;