Package io.guise.framework.style
Class RGBColor
- java.lang.Object
-
- io.guise.framework.style.AbstractModeledColor<RGBColor.Component>
-
- io.guise.framework.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
Nested Classes Modifier and Type Class Description static class
RGBColor.Component
A color component of sRGB.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description 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.RGBColor(java.lang.CharSequence charSequence)
Creates an RGB color from the specified string representation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HSLColor
asHSL()
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 io.guise.framework.style.AbstractModeledColor
checkComponentValue, equals, getAbsoluteComponent, getComponent, getValues, hashCode
-
-
-
-
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:colorname
, one of the HTML color names, which must be in all lowercase without delimiters, such as "aliceblue".#rgb
, with hexadecimal representation of color components without regard to case.#rrggbb
, with hexadecimal representation of color components without regard to case.
transparent
color name as equivalent to rgba(0, 0, 0, 0), or black with zero alpha. In most instances, thevalueOf(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 isnull
.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, elsefalse
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()
- Returns:
- The color in the HSL color space.
-
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:colorname
, one of the HTML color names, which must be in all lowercase without delimiters, such as "aliceblue".#rgb
, with hexadecimal representation of color components without regard to case.#rrggbb
, with hexadecimal representation of color components without regard to case.rgb(red,green,blue)
, with decimal representation with a depth of eight bits (0-255).rgb(red%,green%,blue%)
, with decimal component values multiplied by 100 (0.0-100.0%).rgba(red,green,blue,alpha)
, with decimal representation with a depth of eight bits (0-255).rgba(red%,green%,blue%,alpha%)
, with decimal component values multiplied by 100 (0.0%-100.0%).
transparent
color name as equivalent torgba(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 isnull
.java.lang.IllegalArgumentException
- if a color cannot be determined from the given string.
-
-