image
Class ColorDatabase

java.lang.Object
  extended by image.ColorDatabase

public class ColorDatabase
extends java.lang.Object

Manages color names and translation to implementation-dependent Color structures.

Available colors are listed in the following table. If an undefined color is used then a RuntimeException is thrown. Custom colors can be created using the static makeColor methods.

Alternatively clients can specify a 7 character string beginning with a '#' (hash-mark) followed by a 6 digit hexadecimal number that encodes the requested RGB color (Red, Green, Blue), e.g., "#FF0000" for Red, or "#00FF00" for Green. For advanced users, a 9 character string beginning with a '#' followed by an 8 digit hexadecimal number that encodes the requested ARGB color (Alpha, Red, Green, Blue), e.g., "#FFFF0000" for Opaque Red, or "#8800FF00" for Half-Transparent Green.

Color names are case-insensitive.

"orange red"     
"orangered"     
"tomato"     
"darkred"     
"red"     
"firebrick"     
"crimson"     
"deeppink"     
"maroon"     
"indian red"     
"indianred"     
"medium violet red"     
"mediumvioletred"     
"violet red"     
"violetred"     
"lightcoral"     
"hotpink"     
"palevioletred"     
"lightpink"     
"rosybrown"     
"pink"     
"orchid"     
"lavenderblush"     
"snow"     
"chocolate"     
"saddlebrown"     
"brown"     
"darkorange"     
"coral"     
"sienna"     
"orange"     
"salmon"     
"peru"     
"darkgoldenrod"     
"goldenrod"     
"sandybrown"     
"lightsalmon"     
"darksalmon"     
"gold"     
"yellow"     
"olive"     
"burlywood"     
"tan"     
"navajowhite"     
"peachpuff"     
"khaki"     
"darkkhaki"     
"moccasin"     
"wheat"     
"bisque"     
"palegoldenrod"     
"blanchedalmond"     
"medium goldenrod"     
"mediumgoldenrod"     
"papayawhip"     
"mistyrose"     
"lemonchiffon"     
"antiquewhite"     
"cornsilk"     
"lightgoldenrodyellow"     
"oldlace"     
"linen"     
"lightyellow"     
"seashell"     
"beige"     
"floralwhite"     
"ivory"     
"green"     
"lawngreen"     
"chartreuse"     
"green yellow"     
"greenyellow"     
"yellow green"     
"yellowgreen"     
"medium forest green"     
"olivedrab"     
"mediumforestgreen"     
"dark olive green"     
"darkolivegreen"     
"darkseagreen"     
"lime"     
"dark green"     
"darkgreen"     
"lime green"     
"limegreen"     
"forest green"     
"forestgreen"     
"spring green"     
"springgreen"     
"medium spring green"     
"mediumspringgreen"     
"sea green"     
"seagreen"     
"medium sea green"     
"mediumseagreen"     
"aquamarine"     
"lightgreen"     
"pale green"     
"palegreen"     
"medium aquamarine"     
"mediumaquamarine"     
"turquoise"     
"lightseagreen"     
"medium turquoise"     
"mediumturquoise"     
"honeydew"     
"mintcream"     
"royalblue"     
"dodgerblue"     
"deepskyblue"     
"cornflowerblue"     
"steel blue"     
"steelblue"     
"lightskyblue"     
"dark turquoise"     
"darkturquoise"     
"cyan"     
"aqua"     
"darkcyan"     
"teal"     
"sky blue"     
"skyblue"     
"cadet blue"     
"cadetblue"     
"dark slate gray"     
"darkslategray"     
"lightslategray"     
"slategray"     
"dark slate grey"     
"darkslategrey"     
"lightslategrey"     
"slategrey"     
"light steel blue"     
"lightsteelblue"     
"light blue"     
"lightblue"     
"powderblue"     
"paleturquoise"     
"lightcyan"     
"aliceblue"     
"azure"     
"medium blue"     
"mediumblue"     
"darkblue"     
"midnight blue"     
"midnightblue"     
"navy"     
"blue"     
"indigo"     
"blue violet"     
"blueviolet"     
"medium slate blue"     
"mediumslateblue"     
"slate blue"     
"slateblue"     
"purple"     
"dark slate blue"     
"darkslateblue"     
"darkviolet"     
"dark orchid"     
"darkorchid"     
"mediumpurple"     
"cornflower blue"     
"medium orchid"     
"mediumorchid"     
"magenta"     
"fuchsia"     
"darkmagenta"     
"violet"     
"plum"     
"lavender"     
"thistle"     
"ghostwhite"     
"white"     
"whitesmoke"     
"gainsboro"     
"light gray"     
"lightgray"     
"light grey"     
"lightgrey"     
"silver"     
"gray"     
"dark gray"     
"darkgray"     
"dim gray"     
"dimgray"     
"grey"     
"dark grey"     
"darkgrey"     
"dim grey"     
"dimgrey"     
"black"     


Nested Class Summary
static class ColorDatabase.InvalidColorException
          Thrown when an invalid color is used
 
Constructor Summary
ColorDatabase()
           
 
Method Summary
static java.awt.Color color(java.lang.String s)
          Get the Color represented by the given string
static int colorToARGB(double red, double green, double blue)
          Convert the given Color intensities into ARGB integer format.
static int colorToARGB(double alpha, double red, double green, double blue)
          Convert the given Alpha and Color intensities into ARGB integer format.
static int colorToARGB(int red, int green, int blue)
          Convert the given Color intensities into ARGB integer format.
static int colorToARGB(int alpha, int red, int green, int blue)
          Convert the given Alpha and Color intensities into ARGB integer format.
static int colorToARGB(java.lang.String c)
          Convert the given Color String into ARGB integer format.
static java.awt.Color makeAwtColor(double red, double green, double blue)
          Create a Color from the given Red/Green/Blue fractional intensities in [0..1.0].
static java.awt.Color makeAwtColor(double alpha, double red, double green, double blue)
          Create a Color from the given Alpha/Red/Green/Blue fractional intensities in [0..1.0].
static java.awt.Color makeAwtColor(int color)
          Create a Color from the given integer that encodes Alpha/Red/Green/Blue intensities.
static java.awt.Color makeAwtColor(int red, int green, int blue)
          Create a Color from the given Alpha/Red/Green/Blue intensities in [0..255].
static java.awt.Color makeAwtColor(int alpha, int red, int green, int blue)
          Create a Color from the given Alpha/Red/Green/Blue intensities in [0..255].
static java.lang.String makeColor(double red, double green, double blue)
          Create a color String from the given Red/Green/Blue fractional intensities in [0..1.0].
static java.lang.String makeColor(double alpha, double red, double green, double blue)
          Create a color String from the given Alpha/Red/Green/Blue fractional intensities in [0..1.0].
static java.lang.String makeColor(int color)
          Create a color String from the given integer that encodes Alpha/Red/Green/Blue intensities.
static java.lang.String makeColor(int red, int green, int blue)
          Create a color String from the given Alpha/Red/Green/Blue intensities in [0..255].
static java.lang.String makeColor(int alpha, int red, int green, int blue)
          Create a color String from the given Alpha/Red/Green/Blue intensities in [0..255].
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorDatabase

public ColorDatabase()
Method Detail

color

public static java.awt.Color color(java.lang.String s)
Get the Color represented by the given string


makeColor

public static java.lang.String makeColor(int red,
                                         int green,
                                         int blue)
Create a color String from the given Alpha/Red/Green/Blue intensities in [0..255].


makeColor

public static java.lang.String makeColor(int alpha,
                                         int red,
                                         int green,
                                         int blue)
Create a color String from the given Alpha/Red/Green/Blue intensities in [0..255].


makeColor

public static java.lang.String makeColor(double red,
                                         double green,
                                         double blue)
Create a color String from the given Red/Green/Blue fractional intensities in [0..1.0].


makeColor

public static java.lang.String makeColor(double alpha,
                                         double red,
                                         double green,
                                         double blue)
Create a color String from the given Alpha/Red/Green/Blue fractional intensities in [0..1.0].


makeAwtColor

public static java.awt.Color makeAwtColor(double red,
                                          double green,
                                          double blue)
Create a Color from the given Red/Green/Blue fractional intensities in [0..1.0].


makeAwtColor

public static java.awt.Color makeAwtColor(double alpha,
                                          double red,
                                          double green,
                                          double blue)
Create a Color from the given Alpha/Red/Green/Blue fractional intensities in [0..1.0].


makeAwtColor

public static java.awt.Color makeAwtColor(int red,
                                          int green,
                                          int blue)
Create a Color from the given Alpha/Red/Green/Blue intensities in [0..255].


makeAwtColor

public static java.awt.Color makeAwtColor(int alpha,
                                          int red,
                                          int green,
                                          int blue)
Create a Color from the given Alpha/Red/Green/Blue intensities in [0..255].


colorToARGB

public static int colorToARGB(java.lang.String c)
Convert the given Color String into ARGB integer format.


colorToARGB

public static int colorToARGB(double red,
                              double green,
                              double blue)
Convert the given Color intensities into ARGB integer format. RGB intensities must be between 0 and 1.0, inclusive.


colorToARGB

public static int colorToARGB(double alpha,
                              double red,
                              double green,
                              double blue)
Convert the given Alpha and Color intensities into ARGB integer format. ARGB intensities must be between 0 and 1.0, inclusive.


colorToARGB

public static int colorToARGB(int red,
                              int green,
                              int blue)
Convert the given Color intensities into ARGB integer format. RGB intensities must be between 0 and 255, inclusive.


colorToARGB

public static int colorToARGB(int alpha,
                              int red,
                              int green,
                              int blue)
Convert the given Alpha and Color intensities into ARGB integer format. ARGB intensities must be between 0 and 255, inclusive.


makeColor

public static java.lang.String makeColor(int color)
Create a color String from the given integer that encodes Alpha/Red/Green/Blue intensities. Each of the low-order bytes encodes an intensity in [0..255] where the Red/Green/Blue/Alpha are in order from high to low order bytes.


makeAwtColor

public static java.awt.Color makeAwtColor(int color)
Create a Color from the given integer that encodes Alpha/Red/Green/Blue intensities. Each of the low-order bytes encodes an intensity in [0..255] where the Alpha/Red/Green/Blue/Alpha are in order from high to low order bytes.