Methods Summary |
---|
static java.util.Iterator | colorNameIterator()Package-scope method to get list of all color names
if(colorNames == null) {
loadColorNames();
}
return colorNames.keySet().iterator();
|
public static jsp2_1.examples.elresolver.ColorImplicitObject$ColorRGB | fromColor(java.awt.Color color)Returns a color from a java.awt.Color object.
return new ColorRGB(color.getRed(), color.getGreen(), color.getBlue());
|
public static jsp2_1.examples.elresolver.ColorImplicitObject$ColorRGB | fromHex(java.lang.String hex)Returns a color from an HTML-style hex String, e.g. #f0f0f0
return fromColor(java.awt.Color.decode(hex));
|
public static jsp2_1.examples.elresolver.ColorImplicitObject$ColorRGB | fromName(java.lang.String name)Returns a color from a name. Uses the resource rgb.txt to load
color names.
if(colorNames == null) {
loadColorNames();
}
return (ColorRGB)colorNames.get(name);
|
private static synchronized void | loadColorNames()Loads colors from resource rgb.txt and converts them to
instances of ColorRGB.
if(colorNames == null) {
colorNames = new HashMap();
try {
BufferedReader in = new BufferedReader(new InputStreamReader(
ColorImplicitObject.class.getResourceAsStream(
"/jsp2_1/examples/elresolver/rgb.txt")));
String line;
while((line = in.readLine()) != null) {
if(!line.startsWith("!")) {
String colorText = line.substring(0, 12);
String colorName = line.substring(12).trim();
StringTokenizer st = new StringTokenizer(
colorText, " ");
int red = Integer.parseInt(st.nextToken().trim());
int green = Integer.parseInt(st.nextToken().trim());
int blue = Integer.parseInt(st.nextToken().trim());
colorNames.put(colorName, new ColorRGB(red, green,
blue));
}
}
in.close();
}
catch(IOException e) {
throw new RuntimeException("Could not load rgb.txt", e);
}
}
|
public java.lang.String | toString()
return "Color Implicit Object";
|