com.simpleservlets.htmlobjects
Class HTMLColor
java.lang.Object
com.simpleservlets.htmlobjects.HTMLColor
public final class HTMLColor
- extends Object
Used to represent a color for HTML. All colors are rendered in HTML pages
in the #RRGGBB format (including the #). There are many
constant values defined which can be handily accessed in Java code by
their names, but end up being in #RRGGBB format in HTML so that
they are universally understood by browsers. Instances of this class are
immutable and may be safely shared.
Names and shades of the colors can be viewed at
w3schools.com
(the source used for these definitions).
- Author:
- Paul Hyde
|
Constructor Summary |
HTMLColor(Color awtColor)
|
HTMLColor(double red,
double green,
double blue)
Specify the amount of red, green, and blue as double. |
HTMLColor(int red,
int green,
int blue)
Specify the amount of red, green, and blue as int. |
HTMLColor(String color)
Create a new color. |
HTMLColor(String color,
String javaName,
String htmlName,
String displayName)
Create a new color. |
|
Method Summary |
static String |
awtColorToHex(Color awtColor)
Takes the AWT color and produces a #RRGGBB string representation. |
static HTMLColor |
getColorForName(String name)
Normalizes the passed name and returns the HTMLColor stored
under that name (if any). |
String |
getDisplayName()
Returns the name of this color in a very human normal form
(with mixed case and spaces between words). |
String |
getHexValue()
Returns the color as a #RRGGBB string. |
String |
getHtmlName()
Returns the name of this color as defined by HTML
(with mixed case and no spaces between words). |
String |
getJavaName()
Returns the name of this color as defined by a Java constant
(with all capital letters and underscores between words). |
static String |
normalizeName(String name)
Returns the name with non-alpha characters stripped and all
others turned to capitals. |
String |
toString()
Returns the color as a #RRGGBB string. |
ALICE_BLUE
public static final HTMLColor ALICE_BLUE
- The color 'Alice Blue'.
ANTIQUE_WHITE
public static final HTMLColor ANTIQUE_WHITE
- The color 'Antique White'.
AQUA
public static final HTMLColor AQUA
- The color 'Aqua'.
AQUAMARINE
public static final HTMLColor AQUAMARINE
- The color 'Aquamarine'.
AZURE
public static final HTMLColor AZURE
- The color 'Azure'.
BEIGE
public static final HTMLColor BEIGE
- The color 'Beige'.
BISQUE
public static final HTMLColor BISQUE
- The color 'Bisque'.
BLACK
public static final HTMLColor BLACK
- The color 'Black'.
BLANCHED_ALMOND
public static final HTMLColor BLANCHED_ALMOND
- The color 'Blanched Almond'.
BLUE
public static final HTMLColor BLUE
- The color 'Blue'.
BLUE_VIOLET
public static final HTMLColor BLUE_VIOLET
- The color 'Blue Violet'.
BROWN
public static final HTMLColor BROWN
- The color 'Brown'.
BURLY_WOOD
public static final HTMLColor BURLY_WOOD
- The color 'Burly Wood'.
CADET_BLUE
public static final HTMLColor CADET_BLUE
- The color 'Cadet Blue'.
CHARTREUSE
public static final HTMLColor CHARTREUSE
- The color 'Chartreuse'.
CHOCOLATE
public static final HTMLColor CHOCOLATE
- The color 'Chocolate'.
CORAL
public static final HTMLColor CORAL
- The color 'Coral'.
CORNFLOWER_BLUE
public static final HTMLColor CORNFLOWER_BLUE
- The color 'Cornflower Blue'.
CORNSILK
public static final HTMLColor CORNSILK
- The color 'Cornsilk'.
CRIMSON
public static final HTMLColor CRIMSON
- The color 'Crimson'.
CYAN
public static final HTMLColor CYAN
- The color 'Cyan'.
DARK_BLUE
public static final HTMLColor DARK_BLUE
- The color 'Dark Blue'.
DARK_CYAN
public static final HTMLColor DARK_CYAN
- The color 'Dark Cyan'.
DARK_GOLDEN_ROD
public static final HTMLColor DARK_GOLDEN_ROD
- The color 'Dark Golden Rod'.
DARK_GRAY
public static final HTMLColor DARK_GRAY
- The color 'Dark Gray'.
DARK_GREEN
public static final HTMLColor DARK_GREEN
- The color 'Dark Green'.
DARK_KHAKI
public static final HTMLColor DARK_KHAKI
- The color 'Dark Khaki'.
DARK_MAGENTA
public static final HTMLColor DARK_MAGENTA
- The color 'Dark Magenta'.
DARK_OLIVE_GREEN
public static final HTMLColor DARK_OLIVE_GREEN
- The color 'Dark Olive Green'.
DARKORANGE
public static final HTMLColor DARKORANGE
- The color 'Darkorange'.
DARK_ORCHID
public static final HTMLColor DARK_ORCHID
- The color 'Dark Orchid'.
DARK_RED
public static final HTMLColor DARK_RED
- The color 'Dark Red'.
DARK_SALMON
public static final HTMLColor DARK_SALMON
- The color 'Dark Salmon'.
DARK_SEA_GREEN
public static final HTMLColor DARK_SEA_GREEN
- The color 'Dark Sea Green'.
DARK_SLATE_BLUE
public static final HTMLColor DARK_SLATE_BLUE
- The color 'Dark Slate Blue'.
DARK_SLATE_GRAY
public static final HTMLColor DARK_SLATE_GRAY
- The color 'Dark Slate Gray'.
DARK_TURQUOISE
public static final HTMLColor DARK_TURQUOISE
- The color 'Dark Turquoise'.
DARK_VIOLET
public static final HTMLColor DARK_VIOLET
- The color 'Dark Violet'.
DEEP_PINK
public static final HTMLColor DEEP_PINK
- The color 'Deep Pink'.
DEEP_SKY_BLUE
public static final HTMLColor DEEP_SKY_BLUE
- The color 'Deep Sky Blue'.
DIM_GRAY
public static final HTMLColor DIM_GRAY
- The color 'Dim Gray'.
DODGER_BLUE
public static final HTMLColor DODGER_BLUE
- The color 'Dodger Blue'.
FELDSPAR
public static final HTMLColor FELDSPAR
- The color 'Feldspar'.
FIRE_BRICK
public static final HTMLColor FIRE_BRICK
- The color 'Fire Brick'.
FLORAL_WHITE
public static final HTMLColor FLORAL_WHITE
- The color 'Floral White'.
FOREST_GREEN
public static final HTMLColor FOREST_GREEN
- The color 'Forest Green'.
FUCHSIA
public static final HTMLColor FUCHSIA
- The color 'Fuchsia'.
GAINSBORO
public static final HTMLColor GAINSBORO
- The color 'Gainsboro'.
GHOST_WHITE
public static final HTMLColor GHOST_WHITE
- The color 'Ghost White'.
GOLD
public static final HTMLColor GOLD
- The color 'Gold'.
GOLDEN_ROD
public static final HTMLColor GOLDEN_ROD
- The color 'Golden Rod'.
GRAY
public static final HTMLColor GRAY
- The color 'Gray'.
GREEN
public static final HTMLColor GREEN
- The color 'Green'.
GREEN_YELLOW
public static final HTMLColor GREEN_YELLOW
- The color 'Green Yellow'.
HONEY_DEW
public static final HTMLColor HONEY_DEW
- The color 'Honey Dew'.
HOT_PINK
public static final HTMLColor HOT_PINK
- The color 'Hot Pink'.
INDIAN_RED
public static final HTMLColor INDIAN_RED
- The color 'Indian Red'.
INDIGO
public static final HTMLColor INDIGO
- The color 'Indigo'.
IVORY
public static final HTMLColor IVORY
- The color 'Ivory'.
KHAKI
public static final HTMLColor KHAKI
- The color 'Khaki'.
LAVENDER
public static final HTMLColor LAVENDER
- The color 'Lavender'.
LAVENDER_BLUSH
public static final HTMLColor LAVENDER_BLUSH
- The color 'Lavender Blush'.
LAWN_GREEN
public static final HTMLColor LAWN_GREEN
- The color 'Lawn Green'.
LEMON_CHIFFON
public static final HTMLColor LEMON_CHIFFON
- The color 'Lemon Chiffon'.
LIGHT_BLUE
public static final HTMLColor LIGHT_BLUE
- The color 'Light Blue'.
LIGHT_CORAL
public static final HTMLColor LIGHT_CORAL
- The color 'Light Coral'.
LIGHT_CYAN
public static final HTMLColor LIGHT_CYAN
- The color 'Light Cyan'.
LIGHT_GOLDEN_ROD_YELLOW
public static final HTMLColor LIGHT_GOLDEN_ROD_YELLOW
- The color 'Light Golden Rod Yellow'.
LIGHT_GREY
public static final HTMLColor LIGHT_GREY
- The color 'Light Grey'.
LIGHT_GREEN
public static final HTMLColor LIGHT_GREEN
- The color 'Light Green'.
LIGHT_PINK
public static final HTMLColor LIGHT_PINK
- The color 'Light Pink'.
LIGHT_SALMON
public static final HTMLColor LIGHT_SALMON
- The color 'Light Salmon'.
LIGHT_SEA_GREEN
public static final HTMLColor LIGHT_SEA_GREEN
- The color 'Light Sea Green'.
LIGHT_SKY_BLUE
public static final HTMLColor LIGHT_SKY_BLUE
- The color 'Light Sky Blue'.
LIGHT_SLATE_BLUE
public static final HTMLColor LIGHT_SLATE_BLUE
- The color 'Light Slate Blue'.
LIGHT_SLATE_GRAY
public static final HTMLColor LIGHT_SLATE_GRAY
- The color 'Light Slate Gray'.
LIGHT_STEEL_BLUE
public static final HTMLColor LIGHT_STEEL_BLUE
- The color 'Light Steel Blue'.
LIGHT_YELLOW
public static final HTMLColor LIGHT_YELLOW
- The color 'Light Yellow'.
LIME
public static final HTMLColor LIME
- The color 'Lime'.
LIME_GREEN
public static final HTMLColor LIME_GREEN
- The color 'Lime Green'.
LINEN
public static final HTMLColor LINEN
- The color 'Linen'.
MAGENTA
public static final HTMLColor MAGENTA
- The color 'Magenta'.
MAROON
public static final HTMLColor MAROON
- The color 'Maroon'.
MEDIUM_AQUA_MARINE
public static final HTMLColor MEDIUM_AQUA_MARINE
- The color 'Medium Aqua Marine'.
MEDIUM_BLUE
public static final HTMLColor MEDIUM_BLUE
- The color 'Medium Blue'.
MEDIUM_ORCHID
public static final HTMLColor MEDIUM_ORCHID
- The color 'Medium Orchid'.
MEDIUM_PURPLE
public static final HTMLColor MEDIUM_PURPLE
- The color 'Medium Purple'.
MEDIUM_SEA_GREEN
public static final HTMLColor MEDIUM_SEA_GREEN
- The color 'Medium Sea Green'.
MEDIUM_SLATE_BLUE
public static final HTMLColor MEDIUM_SLATE_BLUE
- The color 'Medium Slate Blue'.
MEDIUM_SPRING_GREEN
public static final HTMLColor MEDIUM_SPRING_GREEN
- The color 'Medium Spring Green'.
MEDIUM_TURQUOISE
public static final HTMLColor MEDIUM_TURQUOISE
- The color 'Medium Turquoise'.
MEDIUM_VIOLET_RED
public static final HTMLColor MEDIUM_VIOLET_RED
- The color 'Medium Violet Red'.
MIDNIGHT_BLUE
public static final HTMLColor MIDNIGHT_BLUE
- The color 'Midnight Blue'.
MINT_CREAM
public static final HTMLColor MINT_CREAM
- The color 'Mint Cream'.
MISTY_ROSE
public static final HTMLColor MISTY_ROSE
- The color 'Misty Rose'.
MOCCASIN
public static final HTMLColor MOCCASIN
- The color 'Moccasin'.
NAVAJO_WHITE
public static final HTMLColor NAVAJO_WHITE
- The color 'Navajo White'.
NAVY
public static final HTMLColor NAVY
- The color 'Navy'.
OLD_LACE
public static final HTMLColor OLD_LACE
- The color 'Old Lace'.
OLIVE
public static final HTMLColor OLIVE
- The color 'Olive'.
OLIVE_DRAB
public static final HTMLColor OLIVE_DRAB
- The color 'Olive Drab'.
ORANGE
public static final HTMLColor ORANGE
- The color 'Orange'.
ORANGE_RED
public static final HTMLColor ORANGE_RED
- The color 'Orange Red'.
ORCHID
public static final HTMLColor ORCHID
- The color 'Orchid'.
PALE_GOLDEN_ROD
public static final HTMLColor PALE_GOLDEN_ROD
- The color 'Pale Golden Rod'.
PALE_GREEN
public static final HTMLColor PALE_GREEN
- The color 'Pale Green'.
PALE_TURQUOISE
public static final HTMLColor PALE_TURQUOISE
- The color 'Pale Turquoise'.
PALE_VIOLET_RED
public static final HTMLColor PALE_VIOLET_RED
- The color 'Pale Violet Red'.
PAPAYA_WHIP
public static final HTMLColor PAPAYA_WHIP
- The color 'Papaya Whip'.
PEACH_PUFF
public static final HTMLColor PEACH_PUFF
- The color 'Peach Puff'.
PERU
public static final HTMLColor PERU
- The color 'Peru'.
PINK
public static final HTMLColor PINK
- The color 'Pink'.
PLUM
public static final HTMLColor PLUM
- The color 'Plum'.
POWDER_BLUE
public static final HTMLColor POWDER_BLUE
- The color 'Powder Blue'.
PURPLE
public static final HTMLColor PURPLE
- The color 'Purple'.
RED
public static final HTMLColor RED
- The color 'Red'.
ROSY_BROWN
public static final HTMLColor ROSY_BROWN
- The color 'Rosy Brown'.
ROYAL_BLUE
public static final HTMLColor ROYAL_BLUE
- The color 'Royal Blue'.
SADDLE_BROWN
public static final HTMLColor SADDLE_BROWN
- The color 'Saddle Brown'.
SALMON
public static final HTMLColor SALMON
- The color 'Salmon'.
SANDY_BROWN
public static final HTMLColor SANDY_BROWN
- The color 'Sandy Brown'.
SEA_GREEN
public static final HTMLColor SEA_GREEN
- The color 'Sea Green'.
SEA_SHELL
public static final HTMLColor SEA_SHELL
- The color 'Sea Shell'.
SIENNA
public static final HTMLColor SIENNA
- The color 'Sienna'.
SILVER
public static final HTMLColor SILVER
- The color 'Silver'.
SKY_BLUE
public static final HTMLColor SKY_BLUE
- The color 'Sky Blue'.
SLATE_BLUE
public static final HTMLColor SLATE_BLUE
- The color 'Slate Blue'.
SLATE_GRAY
public static final HTMLColor SLATE_GRAY
- The color 'Slate Gray'.
SNOW
public static final HTMLColor SNOW
- The color 'Snow'.
SPRING_GREEN
public static final HTMLColor SPRING_GREEN
- The color 'Spring Green'.
STEEL_BLUE
public static final HTMLColor STEEL_BLUE
- The color 'Steel Blue'.
TAN
public static final HTMLColor TAN
- The color 'Tan'.
TEAL
public static final HTMLColor TEAL
- The color 'Teal'.
THISTLE
public static final HTMLColor THISTLE
- The color 'Thistle'.
TOMATO
public static final HTMLColor TOMATO
- The color 'Tomato'.
TURQUOISE
public static final HTMLColor TURQUOISE
- The color 'Turquoise'.
VIOLET
public static final HTMLColor VIOLET
- The color 'Violet'.
VIOLET_RED
public static final HTMLColor VIOLET_RED
- The color 'Violet Red'.
WHEAT
public static final HTMLColor WHEAT
- The color 'Wheat'.
WHITE
public static final HTMLColor WHITE
- The color 'White'.
WHITE_SMOKE
public static final HTMLColor WHITE_SMOKE
- The color 'White Smoke'.
YELLOW
public static final HTMLColor YELLOW
- The color 'Yellow'.
YELLOW_GREEN
public static final HTMLColor YELLOW_GREEN
- The color 'Yellow Green'.
HTMLColor
public HTMLColor(String color,
String javaName,
String htmlName,
String displayName)
- Create a new color.
- Parameters:
color - must be in the format: #RRGGBB
(including the #).
HTMLColor
public HTMLColor(String color)
- Create a new color.
- Parameters:
color - must be in the format: #RRGGBB
(including the #).
HTMLColor
public HTMLColor(Color awtColor)
HTMLColor
public HTMLColor(int red,
int green,
int blue)
- Specify the amount of red, green, and blue as int.
Values are in the range: 0..255.
HTMLColor
public HTMLColor(double red,
double green,
double blue)
- Specify the amount of red, green, and blue as double.
Values are in the range: 0.0 .. 1.0.
getColorForName
public static HTMLColor getColorForName(String name)
- Normalizes the passed name and returns the HTMLColor stored
under that name (if any). If there is no match, then null
is returned. See
normalizeName(String) to see how
the different names are normalized for a search.
normalizeName
public static String normalizeName(String name)
- Returns the name with non-alpha characters stripped and all
others turned to capitals.
For example: SEA_GREEN, Sea Green, and SeaGreen all become
SEAGREEN.
This normalized name is used for lookups by name.
awtColorToHex
public static String awtColorToHex(Color awtColor)
- Takes the AWT color and produces a #RRGGBB string representation.
getJavaName
public String getJavaName()
- Returns the name of this color as defined by a Java constant
(with all capital letters and underscores between words).
For example, LIGHT_BLUE, YELLOW, SEA_GREEN.
getHtmlName
public String getHtmlName()
- Returns the name of this color as defined by HTML
(with mixed case and no spaces between words).
For example, LightBlue, Yellow, SeaGreen.
getDisplayName
public String getDisplayName()
- Returns the name of this color in a very human normal form
(with mixed case and spaces between words).
For example, Light Blue, Yellow, Sea Green.
getHexValue
public String getHexValue()
- Returns the color as a #RRGGBB string.
For example, #ADD8E6, #FFFF00, #2E8B57.
toString
public String toString()
- Returns the color as a #RRGGBB string.
- Overrides:
toString in class Object
Copyright © 2001-2007
Programix Incorporated.
All rights reserved.
SimpleServlets is free
and is
OSI Certified
Open Source Software under the BSD
license.