{
rgb = Integer.parseInt(value.substring(1), 16);
}
catch (NumberFormatException e)
{
throw new PropertyParseException(_INVALID_COLOR + value);
}
return _getSharedColor(rgb);
}
else if (length == 4)
{
// #RGB
int r = 0;
int g = 0;
int b = 0;
try
{
r = Integer.parseInt(value.substring(1, 2), 16);
g = Integer.parseInt(value.substring(2, 3), 16);
b = Integer.parseInt(value.substring(3, 4), 16);
}
catch (NumberFormatException e)
{
throw new PropertyParseException(_INVALID_COLOR + value);
}
int rgb = (((r << 20) & 0xf00000) |
((r << 16) & 0x0f0000) |
((g << 12) & 0x00f000) |
((g << 8) & 0x000f00) |
((b << 4) & 0x0000f0) |
(b & 0x00000f));
return _getSharedColor(rgb);
}
else
{
throw new PropertyParseException(_INVALID_COLOR + value);
}
}
// Handle rgb(r, g, b) values
if (value.startsWith("rgb"))
{
int startIndex = value.indexOf('\u0028'); // Start paren
int endIndex = value.indexOf('\u0029'); // End paren
if ((startIndex == -1) || (endIndex == -1) || (endIndex <= startIndex))
{
throw new PropertyParseException(_INVALID_COLOR + value);
}
// Tokenize on whitespace or commas
StringTokenizer tokens = new StringTokenizer(
value.substring(startIndex + 1, endIndex),
" \t,");
String redToken = null;
String blueToken = null;
String greenToken = null;
try
{
redToken = tokens.nextToken();
greenToken = tokens.nextToken();
blueToken = tokens.nextToken();
}
catch (NoSuchElementException e)
{
throw new PropertyParseException(_INVALID_COLOR + value);
}
int red = _parseColorComponent(value, redToken);
int green = _parseColorComponent(value, greenToken);
int blue = _parseColorComponent(value, blueToken);
return _getSharedColor(red, green, blue);
}
// Check for system color values. We can't actually return valid
// values for these, but we also don't want to throw a
// PropertyParseException if a system color is specified.
if (ArrayMap.get(_SYSTEM_COLORS, value) != null)
return null;
throw new PropertyParseException(_INVALID_COLOR + value);
}