public class ColorFormatter extends Object
Color
class) are converted directly to or from symbolic names
such as "green" or "magenta". Other colors are converted to or from RGB
specifications in the format #RRGGBB - a '#' followed by 6 hexadecimal
digits.Color
Modifier and Type | Field and Description |
---|---|
static Color[] |
basicColors
A list of basic colors.
|
private static String[] |
colorNames |
Modifier | Constructor and Description |
---|---|
private |
ColorFormatter() |
Modifier and Type | Method and Description |
---|---|
static Color |
colorForName(String name)
Get a color for a name.
|
static String |
format(Color color)
Format a color as a string.
|
static String |
nameForColor(Color c)
Get a name for a color.
|
static Color |
parse(String name)
Parse a color representation, returning an appropriate
Color
object. |
private static String[] colorNames
public static Color[] basicColors
private ColorFormatter()
public static String nameForColor(Color c)
Color
class: black, blue,
cyan, gray, green, magenta, orange, pink, red, white, or yellow.c
- The color.null
if c
is
not one of the colors listed above.nameForColor(java.awt.Color)
public static Color colorForName(String name)
Color
class.name
- The name of the color.Color
object for the given name, or
null
if name
does not identify one of the
colors listed above.colorForName(java.lang.String)
public static String format(Color color)
Color
class), or a hex representation of
the color in the format #RRGGBB.color
- The Color
to parse.parse(java.lang.String)
public static Color parse(String name) throws ParsingException
Color
object.name
- The name of the color; one of the strings black, blue,
cyan, gray, green, magenta, orange, pink, red, white, yellow, or an
RGB color specification of the form #RRGGBB.Color
object.ParsingException
- If name
is an
invalid color representation.format(java.awt.Color)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses