public class ColorLookup
extends java.lang.Object
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE colorlookup SYSTEM "http://coastwatch.noaa.gov/xml/colorlookup.dtd"> <colorlookup> <color name="snow" r="255" g="250" b="250" /> <color name="ghost white" r="248" g="248" b="255" /> <color name="GhostWhite" r="248" g="248" b="255" /> <color name="white smoke" r="245" g="245" b="245" /> ... </colorlookup>
Constructor and Description |
---|
ColorLookup()
Creates a new color lookup based on a predefined color names
file.
|
ColorLookup(java.io.File file)
Constructs a new color lookup from the specified file.
|
ColorLookup(java.io.InputStream stream)
Constructs a new color lookup from an input stream.
|
Modifier and Type | Method and Description |
---|---|
java.awt.Color |
convert(java.lang.String name)
Converts a color name or hexadecimal value to an object.
|
java.awt.Color |
getColor(java.lang.String name)
Gets the color associated with a name.
|
static ColorLookup |
getInstance()
Creates a static instance of this class using the default
constructor.
|
public ColorLookup() throws java.io.IOException
java.io.IOException
- if an error occurred reading the predefined
color names file. Under normal circimstances, this should never
happen.public ColorLookup(java.io.File file) throws java.io.FileNotFoundException, java.io.IOException
file
- the file to read.java.io.FileNotFoundException
- if the file is not valid.java.io.IOException
- if the file had input format errors.public ColorLookup(java.io.InputStream stream) throws java.io.FileNotFoundException, java.io.IOException
stream
- the input stream to read palette data from.java.io.IOException
- if the file had input format errors.java.io.FileNotFoundException
public static ColorLookup getInstance()
public java.awt.Color getColor(java.lang.String name)
name
- the color name.public java.awt.Color convert(java.lang.String name)
name
- the color name or hexadecimal value with "0x"
prepended. If a color name is used, the name may be extended
with an optional colon ":" and transparency value in percent. A
transparency of 0 is completely opaque and 100 is completely
transparent.java.lang.RuntimeException
- if the value cannot be converted.