Package com.dua3.utility.data
Interface Color
public interface Color
A common interface for different color implementations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Color
The color ALICEBLUE.static final Color
The color ANTIQUEWHITE.static final Color
The color AQUA.static final Color
The color AQUAMARINE.static final Color
The color AZURE.static final Color
The color BEIGE.static final Color
The color BISQUE.static final RGBColor
The color BLACK.static final Color
The color BLANCHEDALMOND.static final Color
The color BLUE.static final Color
The color BLUEVIOLET.static final Color
The color BROWN.static final Color
The color BURLYWOOD.static final Color
The color CADETBLUE.static final Color
The color CHARTREUSE.static final Color
The color CHOCOLATE.static final Color
The color CORAL.static final Color
The color CORNFLOWERBLUE.static final Color
The color CORNSILK.static final Color
The color CRIMSON.static final Color
The color DARKBLUE.static final Color
The color DARKCYAN.static final Color
The color DARKGOLDENROD.static final Color
The color DARKGRAY.static final Color
The color DARKGREEN.static final Color
The color DARKGREY.static final Color
The color DARKKHAKI.static final Color
The color DARKMAGENTA.static final Color
The color DARKOLIVEGREEN.static final Color
The color DARKORANGE.static final Color
The color DARKORCHID.static final Color
The color DARKRED.static final Color
The color DARKSALMON.static final Color
The color DARKSEAGREEN.static final Color
The color DARKSLATEBLUE.static final Color
The color DARKSLATEGRAY.static final Color
The color DARKSLATEGREY.static final Color
The color DARKTURQUOISE.static final Color
The color DARKVIOLET.static final Color
The color DEEPPINK.static final Color
The color DEEPSKYBLUE.static final Color
The color DIMGRAY.static final Color
The color DIMGREY.static final Color
The color DODGERBLUE.static final float
Factor to apply when generating a brighter or darker version of a color.static final Color
The color FIREBRICK.static final Color
The color FLORALWHITE.static final Color
The color FORESTGREEN.static final Color
The color FUCHSIA.static final Color
The color GAINSBORO.static final Color
The color GHOSTWHITE.static final Color
The color GOLD.static final Color
The color GOLDENROD.static final Color
The color GRAY.static final Color
The color GREEN.static final Color
The color GREENYELLOW.static final Color
The color GREY.static final HexFormat
A static instance of HexFormat used for formatting and parsing hexadecimal representations of color values.static final Color
The color HONEYDEW.static final Color
The color HOTPINK.static final Color
The color INDIANRED.static final Color
The color INDIGO.static final Color
The color IVORY.static final Color
The color KHAKI.static final Color
The color LAVENDER.static final Color
The color LAVENDERBLUSH.static final Color
The color LAWNGREEN.static final Color
The color LEMONCHIFFON.static final Color
The color LIGHTBLUE.static final Color
The color LIGHTCORAL.static final Color
The color LIGHTCYAN.static final Color
The color LIGHTGOLDENRODYELLOW.static final Color
The color LIGHTGRAY.static final Color
The color LIGHTGREEN.static final Color
The color LIGHTGREY.static final Color
The color LIGHTPINK.static final Color
The color LIGHTSALMON.static final Color
The color LIGHTSEAGREEN.static final Color
The color LIGHTSKYBLUE.static final Color
The color LIGHTSLATEGRAY.static final Color
The color LIGHTSLATEGREY.static final Color
The color LIGHTSTEELBLUE.static final Color
The color LIGHTYELLOW.static final Color
The color LIME.static final Color
The color LIMEGREEN.static final Color
The color LINEN.static final Color
The color MAROON.static final Color
The color MEDIUMAQUAMARINE.static final Color
The color MEDIUMBLUE.static final Color
The color MEDIUMORCHID.static final Color
The color MEDIUMPURPLE.static final Color
The color MEDIUMSEAGREEN.static final Color
The color MEDIUMSLATEBLUE.static final Color
The color MEDIUMSPRINGGREEN.static final Color
The color MEDIUMTURQUOISE.static final Color
The color MEDIUMVIOLETRED.static final Color
The color MIDNIGHTBLUE.static final Color
The color MINTCREAM.static final Color
The color MISTYROSE.static final Color
The color MOCCASIN.static final Color
The color NAVAJOWHITE.static final Color
The color NAVY.static final Color
The color OLDLACE.static final Color
The color OLIVE.static final Color
The color OLIVEDRAB.static final Color
The color ORANGE.static final Color
The color ORANGERED.static final Color
The color ORCHID.static final Color
The color PALEGOLDENROD.static final Color
The color PALEGREEN.static final Color
The color PALETURQUOISE.static final Color
The color PALEVIOLETRED.static final Color
The color PAPAYAWHIP.static final Color
The color PEACHPUFF.static final Color
The color PERU.static final Color
The color PINK.static final Color
The color PLUM.static final Color
The color POWDERBLUE.static final Color
The color PURPLE.static final Color
The color REBECCAPURPLE.static final Color
The color RED.static final Color
The color ROSYBROWN.static final Color
The color ROYALBLUE.static final Color
The color SADDLEBROWN.static final Color
The color SALMON.static final Color
The color SANDYBROWN.static final Color
The color SEAGREEN.static final Color
The color SEASHELL.static final Color
The color SIENNA.static final Color
The color SILVER.static final Color
The color SKYBLUE.static final Color
The color SLATEBLUE.static final Color
The color SLATEGRAY.static final Color
The color SLATEGREY.static final Color
The color SNOW.static final Color
The color SPRINGGREEN.static final Color
The color STEELBLUE.static final Color
The color TAN.static final Color
The color TEAL.static final Color
The color THISTLE.static final Color
The color TOMATO.static final Color
The color TRANSPARENT.static final Color
The color TRANSPARENT.static final Color
The color TURQUOISE.static final Color
The color VIOLET.static final Color
The color WHEAT.static final Color
The color WHITE.static final Color
The color WHITESMOKE.static final Color
The color YELLOW.static final Color
The color YELLOWGREEN. -
Method Summary
Modifier and TypeMethodDescriptionint
a()
Get the alpha component of this color as an integer.float
alpha()
Get the alpha component of this color.int
argb()
Get the color value as an integer in ARGB order.static RGBColor
argb
(int argb) Create color from ARGB packed integer value.brighter()
Get a brighter color.darker()
Get a darker color.static HSVColor
hsv
(float h, float s, float v) Create color from HSV values.static HSVColor
hsva
(float h, float s, float v, float alpha) Create color from HSV values.boolean
isOpaque()
Test if this color is opaque.boolean
Test if this color is transparent.palette()
Get a mapping from color name to Color instance.static RGBColor
rgb
(int r, int g, int b) Create color from RGB values.default int
rgba()
Get the color value as an integer in RGBA order.static RGBColor
rgba
(int r, int g, int b, int a) Create color from RGBA values.static RGBColor
rgbaF
(float r, float g, float b, float alpha) Create color from RGB values.static RGBColor
rgbF
(float r, float g, float b) Create color from RGB values.default String
toArgb()
Get hex-string in ARGB form for this color.default byte[]
Get the color components.default byte[]
Get the color components.default String
toCss()
Get CSS compatible string representation of this color.default HSVColor
Convert this color toHSVColor
.default String
toRgba()
Get hex-string in RGBA form for this color.default RGBColor
Convert this color toRGBColor
.static Color
Convert String to Color.values()
Get Iterable over all declared color values.
-
Field Details
-
F_BRIGHTEN
static final float F_BRIGHTENFactor to apply when generating a brighter or darker version of a color.- See Also:
-
ALICEBLUE
The color ALICEBLUE. -
ANTIQUEWHITE
The color ANTIQUEWHITE. -
AQUA
The color AQUA. -
AQUAMARINE
The color AQUAMARINE. -
AZURE
The color AZURE. -
BEIGE
The color BEIGE. -
BISQUE
The color BISQUE. -
BLACK
The color BLACK. -
BLANCHEDALMOND
The color BLANCHEDALMOND. -
BLUE
The color BLUE. -
BLUEVIOLET
The color BLUEVIOLET. -
BROWN
The color BROWN. -
BURLYWOOD
The color BURLYWOOD. -
CADETBLUE
The color CADETBLUE. -
CHARTREUSE
The color CHARTREUSE. -
CHOCOLATE
The color CHOCOLATE. -
CORAL
The color CORAL. -
CORNFLOWERBLUE
The color CORNFLOWERBLUE. -
CORNSILK
The color CORNSILK. -
CRIMSON
The color CRIMSON. -
DARKBLUE
The color DARKBLUE. -
DARKCYAN
The color DARKCYAN. -
DARKGOLDENROD
The color DARKGOLDENROD. -
DARKGRAY
The color DARKGRAY. -
DARKGREEN
The color DARKGREEN. -
DARKGREY
The color DARKGREY. -
DARKKHAKI
The color DARKKHAKI. -
DARKMAGENTA
The color DARKMAGENTA. -
DARKOLIVEGREEN
The color DARKOLIVEGREEN. -
DARKORANGE
The color DARKORANGE. -
DARKORCHID
The color DARKORCHID. -
DARKRED
The color DARKRED. -
DARKSALMON
The color DARKSALMON. -
DARKSEAGREEN
The color DARKSEAGREEN. -
DARKSLATEBLUE
The color DARKSLATEBLUE. -
DARKSLATEGRAY
The color DARKSLATEGRAY. -
DARKSLATEGREY
The color DARKSLATEGREY. -
DARKTURQUOISE
The color DARKTURQUOISE. -
DARKVIOLET
The color DARKVIOLET. -
DEEPPINK
The color DEEPPINK. -
DEEPSKYBLUE
The color DEEPSKYBLUE. -
DIMGRAY
The color DIMGRAY. -
DIMGREY
The color DIMGREY. -
DODGERBLUE
The color DODGERBLUE. -
FIREBRICK
The color FIREBRICK. -
FLORALWHITE
The color FLORALWHITE. -
FORESTGREEN
The color FORESTGREEN. -
FUCHSIA
The color FUCHSIA. -
GAINSBORO
The color GAINSBORO. -
GHOSTWHITE
The color GHOSTWHITE. -
GOLD
The color GOLD. -
GOLDENROD
The color GOLDENROD. -
GRAY
The color GRAY. -
GREEN
The color GREEN. -
GREENYELLOW
The color GREENYELLOW. -
GREY
The color GREY. -
HONEYDEW
The color HONEYDEW. -
HOTPINK
The color HOTPINK. -
INDIANRED
The color INDIANRED. -
INDIGO
The color INDIGO. -
IVORY
The color IVORY. -
KHAKI
The color KHAKI. -
LAVENDER
The color LAVENDER. -
LAVENDERBLUSH
The color LAVENDERBLUSH. -
LAWNGREEN
The color LAWNGREEN. -
LEMONCHIFFON
The color LEMONCHIFFON. -
LIGHTBLUE
The color LIGHTBLUE. -
LIGHTCORAL
The color LIGHTCORAL. -
LIGHTCYAN
The color LIGHTCYAN. -
LIGHTGOLDENRODYELLOW
The color LIGHTGOLDENRODYELLOW. -
LIGHTGRAY
The color LIGHTGRAY. -
LIGHTGREEN
The color LIGHTGREEN. -
LIGHTGREY
The color LIGHTGREY. -
LIGHTPINK
The color LIGHTPINK. -
LIGHTSALMON
The color LIGHTSALMON. -
LIGHTSEAGREEN
The color LIGHTSEAGREEN. -
LIGHTSKYBLUE
The color LIGHTSKYBLUE. -
LIGHTSLATEGRAY
The color LIGHTSLATEGRAY. -
LIGHTSLATEGREY
The color LIGHTSLATEGREY. -
LIGHTSTEELBLUE
The color LIGHTSTEELBLUE. -
LIGHTYELLOW
The color LIGHTYELLOW. -
LIME
The color LIME. -
LIMEGREEN
The color LIMEGREEN. -
LINEN
The color LINEN. -
MAROON
The color MAROON. -
MEDIUMAQUAMARINE
The color MEDIUMAQUAMARINE. -
MEDIUMBLUE
The color MEDIUMBLUE. -
MEDIUMORCHID
The color MEDIUMORCHID. -
MEDIUMPURPLE
The color MEDIUMPURPLE. -
MEDIUMSEAGREEN
The color MEDIUMSEAGREEN. -
MEDIUMSLATEBLUE
The color MEDIUMSLATEBLUE. -
MEDIUMSPRINGGREEN
The color MEDIUMSPRINGGREEN. -
MEDIUMTURQUOISE
The color MEDIUMTURQUOISE. -
MEDIUMVIOLETRED
The color MEDIUMVIOLETRED. -
MIDNIGHTBLUE
The color MIDNIGHTBLUE. -
MINTCREAM
The color MINTCREAM. -
MISTYROSE
The color MISTYROSE. -
MOCCASIN
The color MOCCASIN. -
NAVAJOWHITE
The color NAVAJOWHITE. -
NAVY
The color NAVY. -
OLDLACE
The color OLDLACE. -
OLIVE
The color OLIVE. -
OLIVEDRAB
The color OLIVEDRAB. -
ORANGE
The color ORANGE. -
ORANGERED
The color ORANGERED. -
ORCHID
The color ORCHID. -
PALEGOLDENROD
The color PALEGOLDENROD. -
PALEGREEN
The color PALEGREEN. -
PALETURQUOISE
The color PALETURQUOISE. -
PALEVIOLETRED
The color PALEVIOLETRED. -
PAPAYAWHIP
The color PAPAYAWHIP. -
PEACHPUFF
The color PEACHPUFF. -
PERU
The color PERU. -
PINK
The color PINK. -
PLUM
The color PLUM. -
POWDERBLUE
The color POWDERBLUE. -
PURPLE
The color PURPLE. -
REBECCAPURPLE
The color REBECCAPURPLE. -
RED
The color RED. -
ROSYBROWN
The color ROSYBROWN. -
ROYALBLUE
The color ROYALBLUE. -
SADDLEBROWN
The color SADDLEBROWN. -
SALMON
The color SALMON. -
SANDYBROWN
The color SANDYBROWN. -
SEAGREEN
The color SEAGREEN. -
SEASHELL
The color SEASHELL. -
SIENNA
The color SIENNA. -
SILVER
The color SILVER. -
SKYBLUE
The color SKYBLUE. -
SLATEBLUE
The color SLATEBLUE. -
SLATEGRAY
The color SLATEGRAY. -
SLATEGREY
The color SLATEGREY. -
SNOW
The color SNOW. -
SPRINGGREEN
The color SPRINGGREEN. -
STEELBLUE
The color STEELBLUE. -
TAN
The color TAN. -
TEAL
The color TEAL. -
THISTLE
The color THISTLE. -
TOMATO
The color TOMATO. -
TURQUOISE
The color TURQUOISE. -
VIOLET
The color VIOLET. -
WHEAT
The color WHEAT. -
WHITE
The color WHITE. -
WHITESMOKE
The color WHITESMOKE. -
YELLOW
The color YELLOW. -
YELLOWGREEN
The color YELLOWGREEN. -
TRANSPARENT_WHITE
The color TRANSPARENT. -
TRANSPARENT_BLACK
The color TRANSPARENT. -
HEX_FORMAT
A static instance of HexFormat used for formatting and parsing hexadecimal representations of color values.
-
-
Method Details
-
palette
Get a mapping from color name to Color instance.- Returns:
- map containing the predefined colors
-
valueOf
Convert String to Color. Lookup is tried i these steps:- directly look up the String in the map of predefined colors.
- if first character is '#', interpret s as hex representation of the RGB value
- if s starts with rgb, s should be something like "rgb(123,210,120)"
- otherwise an exception is thrown
- Parameters:
s
- the text- Returns:
- result of conversion
-
argb
Create color from ARGB packed integer value.- Parameters:
argb
- the ARGB packed integer value- Returns:
- the color
-
rgb
Create color from RGB values.- Parameters:
r
- the red component [0 .. 255]g
- the green component [0 .. 255]b
- the blue component [0 .. 255]- Returns:
- the color
-
rgba
Create color from RGBA values.- Parameters:
r
- the red component [0 .. 255]g
- the green component [0 .. 255]b
- the blue component [0 .. 255]a
- the alpha value [0 .. 255]- Returns:
- the color
-
rgbF
Create color from RGB values.- Parameters:
r
- the red component [0 .. 1]g
- the green component [0 .. 1]b
- the blue component [0 .. 1]- Returns:
- the color
-
rgbaF
Create color from RGB values.- Parameters:
r
- the red component [0 .. 1]g
- the green component [0 .. 1]b
- the blue component [0 .. 1]alpha
- the alpha value [0 .. 1]- Returns:
- the color
-
hsv
Create color from HSV values.- Parameters:
h
- the hue [0 .. 360]s
- the saturation [0 .. 1]v
- the brightness [0 .. 1]- Returns:
- the color
-
hsva
Create color from HSV values.- Parameters:
h
- the hue [0 .. 360]s
- the saturation [0 .. 1]v
- the brightness [0 .. 1]alpha
- the alpha value [0 .. 1]- Returns:
- the color
-
values
Get Iterable over all declared color values.- Returns:
- Iterable
-
alpha
float alpha()Get the alpha component of this color.- Returns:
- alpha component
-
a
int a()Get the alpha component of this color as an integer.- Returns:
- alpha component
-
isOpaque
boolean isOpaque()Test if this color is opaque.- Returns:
- true, if the color uses the maximum alpha value
-
isTransparent
boolean isTransparent()Test if this color is transparent.- Returns:
- true, if the color uses an alpha value of 0
-
toArgb
Get hex-string in ARGB form for this color.- Returns:
- hex-string
-
toRgba
Get hex-string in RGBA form for this color.- Returns:
- hex-string
-
toRGBColor
Convert this color toRGBColor
.- Returns:
- this color as RGBColor instance
-
toHSVColor
Convert this color toHSVColor
.- Returns:
- this color as RGBColor instance
-
toCss
Get CSS compatible string representation of this color.Opaque colors are represented as three component hex strings, i. e. "#ff0000" for red. Colors using transparency are represented as four component hex strings in rrggbbaa format.
- Returns:
- this color as hex value (in rgb or rgba representation)
-
argb
int argb()Get the color value as an integer in ARGB order.- Returns:
- this color encoded as an integer value in ARGB order
-
rgba
default int rgba()Get the color value as an integer in RGBA order.- Returns:
- this color encoded as an integer value
-
toByteArray
default byte[] toByteArray()Get the color components.- Returns:
- byte array of size 4 containing this color's components in argb order
-
toByteArrayRGB
default byte[] toByteArrayRGB()Get the color components.- Returns:
- byte array of size 3 containing this color's components in rgb order
-
brighter
Color brighter()Get a brighter color.- Returns:
- a brighter version of this color
-
darker
Color darker()Get a darker color.- Returns:
- a darker version of this color
-