com.guiseframework.style
Class RGBColor

java.lang.Object
  extended by com.guiseframework.style.AbstractModeledColor<RGBColor.Component>
      extended by com.guiseframework.style.RGBColor
All Implemented Interfaces:
Color, ModeledColor<RGBColor.Component>

public class RGBColor
extends AbstractModeledColor<RGBColor.Component>

Encapsulates a color value of the sRGB color space.

Author:
Garret Wilson
See Also:
A Standard Default Color Space for the Internet - sRGB, CSS 3 Color Module, X11 color names, Colors By Name, HTML Color Names, CSS 3 Color Module: SVG color keywords, SVG 1.1: Recognized color keyword names, Re: color names in SVG-1.0 conflict with /usr/lib/X11/rgb.txt

Nested Class Summary
static class RGBColor.Component
          A color component of sRGB.
 
Field Summary
static RGBColor ALICE_BLUE
           
static RGBColor ANTIQUE_WHITE
           
static RGBColor AQUA
           
static RGBColor AQUA_MARINE
           
static RGBColor AZURE
           
static RGBColor BEIGE
           
static RGBColor BISQUE
           
static RGBColor BLACK
           
static RGBColor BLANCHE_DALMOND
           
static RGBColor BLUE
           
static RGBColor BLUE_VIOLET
           
static RGBColor BROWN
           
static RGBColor BURLY_WOOD
           
static RGBColor CADET_BLUE
           
static RGBColor CHARTREUSE
           
static RGBColor CHOCOLATE
           
static RGBColor CORAL
           
static RGBColor CORNFLOWER_BLUE
           
static RGBColor CORNSILK
           
static RGBColor CRIMSON
           
static RGBColor CYAN
           
static RGBColor DARK_BLUE
           
static RGBColor DARK_CYAN
           
static RGBColor DARK_GOLDEN_ROD
           
static RGBColor DARK_GRAY
           
static RGBColor DARK_GREEN
           
static RGBColor DARK_KHAKI
           
static RGBColor DARK_MAGENTA
           
static RGBColor DARK_OLIVE_GREEN
           
static RGBColor DARK_ORANGE
           
static RGBColor DARK_ORCHID
           
static RGBColor DARK_RED
           
static RGBColor DARK_SALMON
           
static RGBColor DARK_SEA_GREEN
           
static RGBColor DARK_SLATE_BLUE
           
static RGBColor DARK_SLATE_GRAY
           
static RGBColor DARK_TURQUOISE
           
static RGBColor DARK_VIOLET
           
static RGBColor DEEP_PINK
           
static RGBColor DEEP_SKY_BLUE
           
static RGBColor DIM_GRAY
           
static RGBColor DODGER_BLUE
           
static RGBColor FELDSPAR
           
static RGBColor FIRE_BRICK
           
static RGBColor FLORAL_WHITE
           
static RGBColor FOREST_GREEN
           
static RGBColor FUCHSIA
           
static RGBColor GAINSBORO
           
static RGBColor GHOST_WHITE
           
static RGBColor GOLD
           
static RGBColor GOLDEN_ROD
           
static RGBColor GRAY
           
static RGBColor GREEN
           
static RGBColor GREEN_YELLOW
           
static RGBColor HONEY_DEW
           
static RGBColor HOT_PINK
           
static RGBColor INDIAN_RED
           
static RGBColor INDIGO
           
static RGBColor IVORY
           
static RGBColor KHAKI
           
static RGBColor LAVENDER
           
static RGBColor LAVENDER_BLUSH
           
static RGBColor LAWN_GREEN
           
static RGBColor LEMON_CHIFFON
           
static RGBColor LIGHT_BLUE
           
static RGBColor LIGHT_CORAL
           
static RGBColor LIGHT_CYAN
           
static RGBColor LIGHT_GOLDEN_ROD_YELLOW
           
static RGBColor LIGHT_GREEN
           
static RGBColor LIGHT_GREY
           
static RGBColor LIGHT_PINK
           
static RGBColor LIGHT_SALMON
           
static RGBColor LIGHT_SEA_GREEN
           
static RGBColor LIGHT_SKY_BLUE
           
static RGBColor LIGHT_SLATE_BLUE
           
static RGBColor LIGHT_SLATE_GRAY
           
static RGBColor LIGHT_STEEL_BLUE
           
static RGBColor LIGHT_YELLOW
           
static RGBColor LIME
           
static RGBColor LIME_GREEN
           
static RGBColor LINEN
           
static RGBColor MAGENTA
           
static RGBColor MAROON
           
static RGBColor MEDIU_MBLUE
           
static RGBColor MEDIUM_AQUA_MARINE
           
static RGBColor MEDIUM_ORCHID
           
static RGBColor MEDIUM_PURPLE
           
static RGBColor MEDIUM_SEA_GREEN
           
static RGBColor MEDIUM_SLATE_BLUE
           
static RGBColor MEDIUM_SPRING_GREEN
           
static RGBColor MEDIUM_TURQUOISE
           
static RGBColor MEDIUM_VIOLET_RED
           
static RGBColor MIDNIGHT_BLUE
           
static RGBColor MINT_CREAM
           
static RGBColor MISTY_ROSE
           
static RGBColor MOCCASIN
           
static RGBColor NAVAJO_WHITE
           
static RGBColor NAVY
           
static RGBColor OLD_LACE
           
static RGBColor OLIVE
           
static RGBColor OLIVE_DRAB
           
static RGBColor ORANGE
           
static RGBColor ORANGE_RED
           
static RGBColor ORCHID
           
static RGBColor PALE_GOLDEN_ROD
           
static RGBColor PALE_GREEN
           
static RGBColor PALE_TURQUOISE
           
static RGBColor PALE_VIOLET_RED
           
static RGBColor PAPAYA_WHIP
           
static RGBColor PEACH_PUFF
           
static RGBColor PERU
           
static RGBColor PINK
           
static RGBColor PLUM
           
static RGBColor POWDER_BLUE
           
static RGBColor PURPLE
           
static RGBColor RED
           
static RGBColor ROSY_BROWN
           
static RGBColor ROYAL_BLUE
           
static RGBColor SADDLE_BROWN
           
static RGBColor SALMON
           
static RGBColor SANDY_BROWN
           
static RGBColor SEA_GREEN
           
static RGBColor SEA_SHELL
           
static RGBColor SIENNA
           
static RGBColor SILVER
           
static RGBColor SKY_BLUE
           
static RGBColor SLATE_BLUE
           
static RGBColor SLATE_GRAY
           
static RGBColor SNOW
           
static RGBColor SPRING_GREEN
           
static RGBColor STEEL_BLUE
           
static RGBColor TAN
           
static RGBColor TEAL
           
static RGBColor THISTLE
           
static RGBColor TOMATO
           
static RGBColor TRANSPARENT
           
static RGBColor TURQUOISE
           
static RGBColor VIOLET
           
static RGBColor VIOLET_RED
           
static RGBColor WHEAT
           
static RGBColor WHITE
           
static RGBColor WHITE_SMOKE
           
static RGBColor YELLOW
           
static RGBColor YELLOW_GREEN
           
 
Constructor Summary
RGBColor(java.lang.CharSequence charSequence)
          Creates an RGB color from the specified string representation.
RGBColor(double red, double green, double blue)
          Creates an opaque sRGB color with the specified red, green, and blue component values.
RGBColor(double red, double green, double blue, double alpha)
          Creates an sRGB color with the specified red, green, blue, and alpha component values.
RGBColor(int rgb)
          Creates an opaque sRGB color from the specified sRGB color value.
RGBColor(int argb, boolean hasAlpha)
          Creates an sRGB color from the specified sRGB color value and alpha indication.
RGBColor(int red, int green, int blue)
          Creates an opaque sRGB color with the specified absolute red, green, and blue component values.
RGBColor(int red, int green, int blue, int alpha)
          Creates an sRGB color with the specified absolute red, green, blue, and alpha component values.
 
Method Summary
 HSLColor asHSL()
          Converts this RGB color to an HSL color.
 RGBColor asRGB()
           
 int getAbsoluteAlpha8()
           
 int getAbsoluteBlue8()
           
 int getAbsoluteGreen8()
           
 int getAbsoluteRed8()
           
 double getAlpha()
           
 double getBlue()
           
 double getGreen()
           
 double getRed()
           
static RGBColor valueOf(java.lang.CharSequence charSequence)
          Creates an RGB color from a string representation.
 
Methods inherited from class com.guiseframework.style.AbstractModeledColor
checkComponentValue, equals, getAbsoluteComponent, getComponent, getValues, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSPARENT

public static final RGBColor TRANSPARENT

ALICE_BLUE

public static final RGBColor ALICE_BLUE

ANTIQUE_WHITE

public static final RGBColor ANTIQUE_WHITE

AQUA

public static final RGBColor AQUA

AQUA_MARINE

public static final RGBColor AQUA_MARINE

AZURE

public static final RGBColor AZURE

BEIGE

public static final RGBColor BEIGE

BISQUE

public static final RGBColor BISQUE

BLACK

public static final RGBColor BLACK

BLANCHE_DALMOND

public static final RGBColor BLANCHE_DALMOND

BLUE

public static final RGBColor BLUE

BLUE_VIOLET

public static final RGBColor BLUE_VIOLET

BROWN

public static final RGBColor BROWN

BURLY_WOOD

public static final RGBColor BURLY_WOOD

CADET_BLUE

public static final RGBColor CADET_BLUE

CHARTREUSE

public static final RGBColor CHARTREUSE

CHOCOLATE

public static final RGBColor CHOCOLATE

CORAL

public static final RGBColor CORAL

CORNFLOWER_BLUE

public static final RGBColor CORNFLOWER_BLUE

CORNSILK

public static final RGBColor CORNSILK

CRIMSON

public static final RGBColor CRIMSON

CYAN

public static final RGBColor CYAN

DARK_BLUE

public static final RGBColor DARK_BLUE

DARK_CYAN

public static final RGBColor DARK_CYAN

DARK_GOLDEN_ROD

public static final RGBColor DARK_GOLDEN_ROD

DARK_GRAY

public static final RGBColor DARK_GRAY

DARK_GREEN

public static final RGBColor DARK_GREEN

DARK_KHAKI

public static final RGBColor DARK_KHAKI

DARK_MAGENTA

public static final RGBColor DARK_MAGENTA

DARK_OLIVE_GREEN

public static final RGBColor DARK_OLIVE_GREEN

DARK_ORANGE

public static final RGBColor DARK_ORANGE

DARK_ORCHID

public static final RGBColor DARK_ORCHID

DARK_RED

public static final RGBColor DARK_RED

DARK_SALMON

public static final RGBColor DARK_SALMON

DARK_SEA_GREEN

public static final RGBColor DARK_SEA_GREEN

DARK_SLATE_BLUE

public static final RGBColor DARK_SLATE_BLUE

DARK_SLATE_GRAY

public static final RGBColor DARK_SLATE_GRAY

DARK_TURQUOISE

public static final RGBColor DARK_TURQUOISE

DARK_VIOLET

public static final RGBColor DARK_VIOLET

DEEP_PINK

public static final RGBColor DEEP_PINK

DEEP_SKY_BLUE

public static final RGBColor DEEP_SKY_BLUE

DIM_GRAY

public static final RGBColor DIM_GRAY

DODGER_BLUE

public static final RGBColor DODGER_BLUE

FELDSPAR

public static final RGBColor FELDSPAR

FIRE_BRICK

public static final RGBColor FIRE_BRICK

FLORAL_WHITE

public static final RGBColor FLORAL_WHITE

FOREST_GREEN

public static final RGBColor FOREST_GREEN

FUCHSIA

public static final RGBColor FUCHSIA

GAINSBORO

public static final RGBColor GAINSBORO

GHOST_WHITE

public static final RGBColor GHOST_WHITE

GOLD

public static final RGBColor GOLD

GOLDEN_ROD

public static final RGBColor GOLDEN_ROD

GRAY

public static final RGBColor GRAY

GREEN

public static final RGBColor GREEN

GREEN_YELLOW

public static final RGBColor GREEN_YELLOW

HONEY_DEW

public static final RGBColor HONEY_DEW

HOT_PINK

public static final RGBColor HOT_PINK

INDIAN_RED

public static final RGBColor INDIAN_RED

INDIGO

public static final RGBColor INDIGO

IVORY

public static final RGBColor IVORY

KHAKI

public static final RGBColor KHAKI

LAVENDER

public static final RGBColor LAVENDER

LAVENDER_BLUSH

public static final RGBColor LAVENDER_BLUSH

LAWN_GREEN

public static final RGBColor LAWN_GREEN

LEMON_CHIFFON

public static final RGBColor LEMON_CHIFFON

LIGHT_BLUE

public static final RGBColor LIGHT_BLUE

LIGHT_CORAL

public static final RGBColor LIGHT_CORAL

LIGHT_CYAN

public static final RGBColor LIGHT_CYAN

LIGHT_GOLDEN_ROD_YELLOW

public static final RGBColor LIGHT_GOLDEN_ROD_YELLOW

LIGHT_GREY

public static final RGBColor LIGHT_GREY

LIGHT_GREEN

public static final RGBColor LIGHT_GREEN

LIGHT_PINK

public static final RGBColor LIGHT_PINK

LIGHT_SALMON

public static final RGBColor LIGHT_SALMON

LIGHT_SEA_GREEN

public static final RGBColor LIGHT_SEA_GREEN

LIGHT_SKY_BLUE

public static final RGBColor LIGHT_SKY_BLUE

LIGHT_SLATE_BLUE

public static final RGBColor LIGHT_SLATE_BLUE

LIGHT_SLATE_GRAY

public static final RGBColor LIGHT_SLATE_GRAY

LIGHT_STEEL_BLUE

public static final RGBColor LIGHT_STEEL_BLUE

LIGHT_YELLOW

public static final RGBColor LIGHT_YELLOW

LIME

public static final RGBColor LIME

LIME_GREEN

public static final RGBColor LIME_GREEN

LINEN

public static final RGBColor LINEN

MAGENTA

public static final RGBColor MAGENTA

MAROON

public static final RGBColor MAROON

MEDIUM_AQUA_MARINE

public static final RGBColor MEDIUM_AQUA_MARINE

MEDIU_MBLUE

public static final RGBColor MEDIU_MBLUE

MEDIUM_ORCHID

public static final RGBColor MEDIUM_ORCHID

MEDIUM_PURPLE

public static final RGBColor MEDIUM_PURPLE

MEDIUM_SEA_GREEN

public static final RGBColor MEDIUM_SEA_GREEN

MEDIUM_SLATE_BLUE

public static final RGBColor MEDIUM_SLATE_BLUE

MEDIUM_SPRING_GREEN

public static final RGBColor MEDIUM_SPRING_GREEN

MEDIUM_TURQUOISE

public static final RGBColor MEDIUM_TURQUOISE

MEDIUM_VIOLET_RED

public static final RGBColor MEDIUM_VIOLET_RED

MIDNIGHT_BLUE

public static final RGBColor MIDNIGHT_BLUE

MINT_CREAM

public static final RGBColor MINT_CREAM

MISTY_ROSE

public static final RGBColor MISTY_ROSE

MOCCASIN

public static final RGBColor MOCCASIN

NAVAJO_WHITE

public static final RGBColor NAVAJO_WHITE

NAVY

public static final RGBColor NAVY

OLD_LACE

public static final RGBColor OLD_LACE

OLIVE

public static final RGBColor OLIVE

OLIVE_DRAB

public static final RGBColor OLIVE_DRAB

ORANGE

public static final RGBColor ORANGE

ORANGE_RED

public static final RGBColor ORANGE_RED

ORCHID

public static final RGBColor ORCHID

PALE_GOLDEN_ROD

public static final RGBColor PALE_GOLDEN_ROD

PALE_GREEN

public static final RGBColor PALE_GREEN

PALE_TURQUOISE

public static final RGBColor PALE_TURQUOISE

PALE_VIOLET_RED

public static final RGBColor PALE_VIOLET_RED

PAPAYA_WHIP

public static final RGBColor PAPAYA_WHIP

PEACH_PUFF

public static final RGBColor PEACH_PUFF

PERU

public static final RGBColor PERU

PINK

public static final RGBColor PINK

PLUM

public static final RGBColor PLUM

POWDER_BLUE

public static final RGBColor POWDER_BLUE

PURPLE

public static final RGBColor PURPLE

RED

public static final RGBColor RED

ROSY_BROWN

public static final RGBColor ROSY_BROWN

ROYAL_BLUE

public static final RGBColor ROYAL_BLUE

SADDLE_BROWN

public static final RGBColor SADDLE_BROWN

SALMON

public static final RGBColor SALMON

SANDY_BROWN

public static final RGBColor SANDY_BROWN

SEA_GREEN

public static final RGBColor SEA_GREEN

SEA_SHELL

public static final RGBColor SEA_SHELL

SIENNA

public static final RGBColor SIENNA

SILVER

public static final RGBColor SILVER

SKY_BLUE

public static final RGBColor SKY_BLUE

SLATE_BLUE

public static final RGBColor SLATE_BLUE

SLATE_GRAY

public static final RGBColor SLATE_GRAY

SNOW

public static final RGBColor SNOW

SPRING_GREEN

public static final RGBColor SPRING_GREEN

STEEL_BLUE

public static final RGBColor STEEL_BLUE

TAN

public static final RGBColor TAN

TEAL

public static final RGBColor TEAL

THISTLE

public static final RGBColor THISTLE

TOMATO

public static final RGBColor TOMATO

TURQUOISE

public static final RGBColor TURQUOISE

VIOLET

public static final RGBColor VIOLET

VIOLET_RED

public static final RGBColor VIOLET_RED

WHEAT

public static final RGBColor WHEAT

WHITE

public static final RGBColor WHITE

WHITE_SMOKE

public static final RGBColor WHITE_SMOKE

YELLOW

public static final RGBColor YELLOW

YELLOW_GREEN

public static final RGBColor YELLOW_GREEN
Constructor Detail

RGBColor

public RGBColor(java.lang.CharSequence charSequence)
Creates an RGB color from the specified string representation. This representation can be in one of the following forms: This method also recognizes the transparent color name as equivalent to rgba(0, 0, 0, 0), or black with zero alpha. In most instances, the valueOf(CharSequence) static method is preferred for string-based construction, as it allows singleton instances of named RGB colors to be used.

Parameters:
charSequence - The character sequence representation of a color, either a lowercase name of a standard HTML color, or a three or six-digit hex code beginning with '#'.
Throws:
java.lang.NullPointerException - if the given string is null.
java.lang.IllegalArgumentException - if a color cannot be determined from the given string.

RGBColor

public RGBColor(int rgb)
Creates an opaque sRGB color from the specified sRGB color value. Any alpha present is ignored and replaced with alpha of 0xFF.

Parameters:
rgb - The color value composed of 8 bits each of red, green, and blue.

RGBColor

public RGBColor(int argb,
                boolean hasAlpha)
Creates an sRGB color from the specified sRGB color value and alpha indication.

Parameters:
argb - The color value composed of 8 bits each of alpha, red, green, and blue (0xAARRGGBB).
hasAlpha - true if the given value contains alpha information, else false if default opaque alpha should be added.

RGBColor

public RGBColor(int red,
                int green,
                int blue)
Creates an opaque sRGB color with the specified absolute red, green, and blue component values. The alpha component will be set to its maximum (0xFF).

Parameters:
red - The red component on an absolute scale in the range (0x00-0xFF).
green - The green component on an absolute scale in the range (0x00-0xFF).
blue - The blue component on an absolute scale in the range (0x00-0xFF).
Throws:
java.lang.IllegalArgumentException - if one of the values is outside the range (0x00-0xFF).

RGBColor

public RGBColor(int red,
                int green,
                int blue,
                int alpha)
Creates an sRGB color with the specified absolute red, green, blue, and alpha component values.

Parameters:
red - The red component on an absolute scale in the range (0x00-0xFF).
green - The green component on an absolute scale in the range (0x00-0xFF).
blue - The blue component on an absolute scale in the range (0x00-0xFF).
alpha - The alpha component on an absolute scale in the range (0x00-0xFF).
Throws:
java.lang.IllegalArgumentException - if one of the values is outside the range (0x00-0xFF).

RGBColor

public RGBColor(double red,
                double green,
                double blue)
Creates an opaque sRGB color with the specified red, green, and blue component values. The alpha component will be set to its maximum (1.0).

Parameters:
red - The red component.
green - The green component.
blue - The blue component.
Throws:
java.lang.IllegalArgumentException - if one of the values is outside the range (0.0-1.0).

RGBColor

public RGBColor(double red,
                double green,
                double blue,
                double alpha)
Creates an sRGB color with the specified red, green, blue, and alpha component values.

Parameters:
red - The red component.
green - The green component.
blue - The blue component.
alpha - The alpha component.
Throws:
java.lang.IllegalArgumentException - if one of the values is outside the range (0.0-1.0).
Method Detail

getRed

public double getRed()
Returns:
The red component value.

getAbsoluteRed8

public int getAbsoluteRed8()
Returns:
The absolute red value at a depth of 8 bits.

getGreen

public double getGreen()
Returns:
The green component value.

getAbsoluteGreen8

public int getAbsoluteGreen8()
Returns:
The absolute green value at a depth of 8 bits.

getBlue

public double getBlue()
Returns:
The blue component value.

getAbsoluteBlue8

public int getAbsoluteBlue8()
Returns:
The absolute blue value at a depth of 8 bits.

getAlpha

public double getAlpha()
Returns:
The alpha component value.

getAbsoluteAlpha8

public int getAbsoluteAlpha8()
Returns:
The absolute alpha value at a depth of 8 bits.

asHSL

public HSLColor asHSL()
Converts this RGB color to an HSL color.

Returns:
The color in the HSL color space.
See Also:
HSL color space: Converting to RGB, EasyRGB RGB->HSL

asRGB

public RGBColor asRGB()
Returns:
The color in the RGB color space.

valueOf

public static RGBColor valueOf(java.lang.CharSequence charSequence)
Creates an RGB color from a string representation. This representation can be in one of the following forms: This method also recognizes the transparent color name as equivalent to rgba(0, 0, 0, 0), or black with zero alpha.

Parameters:
charSequence - The character sequence representation of an RGB color.
Returns:
An RGB color object representing the color represented by the given string.
Throws:
java.lang.NullPointerException - if the given string is null.
java.lang.IllegalArgumentException - if a color cannot be determined from the given string.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.