Package com.dua3.utility.data
Interface Color
public interface Color
A common interface for different color implementations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ColorThe color ALICEBLUE.static final ColorThe color ANTIQUEWHITE.static final ColorThe color AQUA.static final ColorThe color AQUAMARINE.static final ColorThe color AZURE.static final ColorThe color BEIGE.static final ColorThe color BISQUE.static final RGBColorThe color BLACK.static final ColorThe color BLANCHEDALMOND.static final ColorThe color BLUE.static final ColorThe color BLUEVIOLET.static final ColorThe color BROWN.static final ColorThe color BURLYWOOD.static final ColorThe color CADETBLUE.static final ColorThe color CHARTREUSE.static final ColorThe color CHOCOLATE.static final ColorThe color CORAL.static final ColorThe color CORNFLOWERBLUE.static final ColorThe color CORNSILK.static final ColorThe color CRIMSON.static final ColorThe color DARKBLUE.static final ColorThe color DARKCYAN.static final ColorThe color DARKGOLDENROD.static final ColorThe color DARKGRAY.static final ColorThe color DARKGREEN.static final ColorThe color DARKGREY.static final ColorThe color DARKKHAKI.static final ColorThe color DARKMAGENTA.static final ColorThe color DARKOLIVEGREEN.static final ColorThe color DARKORANGE.static final ColorThe color DARKORCHID.static final ColorThe color DARKRED.static final ColorThe color DARKSALMON.static final ColorThe color DARKSEAGREEN.static final ColorThe color DARKSLATEBLUE.static final ColorThe color DARKSLATEGRAY.static final ColorThe color DARKSLATEGREY.static final ColorThe color DARKTURQUOISE.static final ColorThe color DARKVIOLET.static final ColorThe color DEEPPINK.static final ColorThe color DEEPSKYBLUE.static final ColorThe color DIMGRAY.static final ColorThe color DIMGREY.static final ColorThe color DODGERBLUE.static final floatFactor to apply when generating a brighter or darker version of a color.static final ColorThe color FIREBRICK.static final ColorThe color FLORALWHITE.static final ColorThe color FORESTGREEN.static final ColorThe color FUCHSIA.static final ColorThe color GAINSBORO.static final ColorThe color GHOSTWHITE.static final ColorThe color GOLD.static final ColorThe color GOLDENROD.static final ColorThe color GRAY.static final ColorThe color GREEN.static final ColorThe color GREENYELLOW.static final ColorThe color GREY.static final HexFormatA static instance of HexFormat used for formatting and parsing hexadecimal representations of color values.static final ColorThe color HONEYDEW.static final ColorThe color HOTPINK.static final ColorThe color INDIANRED.static final ColorThe color INDIGO.static final ColorThe color IVORY.static final ColorThe color KHAKI.static final ColorThe color LAVENDER.static final ColorThe color LAVENDERBLUSH.static final ColorThe color LAWNGREEN.static final ColorThe color LEMONCHIFFON.static final ColorThe color LIGHTBLUE.static final ColorThe color LIGHTCORAL.static final ColorThe color LIGHTCYAN.static final ColorThe color LIGHTGOLDENRODYELLOW.static final ColorThe color LIGHTGRAY.static final ColorThe color LIGHTGREEN.static final ColorThe color LIGHTGREY.static final ColorThe color LIGHTPINK.static final ColorThe color LIGHTSALMON.static final ColorThe color LIGHTSEAGREEN.static final ColorThe color LIGHTSKYBLUE.static final ColorThe color LIGHTSLATEGRAY.static final ColorThe color LIGHTSLATEGREY.static final ColorThe color LIGHTSTEELBLUE.static final ColorThe color LIGHTYELLOW.static final ColorThe color LIME.static final ColorThe color LIMEGREEN.static final ColorThe color LINEN.static final ColorThe color MAROON.static final ColorThe color MEDIUMAQUAMARINE.static final ColorThe color MEDIUMBLUE.static final ColorThe color MEDIUMORCHID.static final ColorThe color MEDIUMPURPLE.static final ColorThe color MEDIUMSEAGREEN.static final ColorThe color MEDIUMSLATEBLUE.static final ColorThe color MEDIUMSPRINGGREEN.static final ColorThe color MEDIUMTURQUOISE.static final ColorThe color MEDIUMVIOLETRED.static final ColorThe color MIDNIGHTBLUE.static final ColorThe color MINTCREAM.static final ColorThe color MISTYROSE.static final ColorThe color MOCCASIN.static final ColorThe color NAVAJOWHITE.static final ColorThe color NAVY.static final ColorThe color OLDLACE.static final ColorThe color OLIVE.static final ColorThe color OLIVEDRAB.static final ColorThe color ORANGE.static final ColorThe color ORANGERED.static final ColorThe color ORCHID.static final ColorThe color PALEGOLDENROD.static final ColorThe color PALEGREEN.static final ColorThe color PALETURQUOISE.static final ColorThe color PALEVIOLETRED.static final ColorThe color PAPAYAWHIP.static final ColorThe color PEACHPUFF.static final ColorThe color PERU.static final ColorThe color PINK.static final ColorThe color PLUM.static final ColorThe color POWDERBLUE.static final ColorThe color PURPLE.static final ColorThe color REBECCAPURPLE.static final ColorThe color RED.static final ColorThe color ROSYBROWN.static final ColorThe color ROYALBLUE.static final ColorThe color SADDLEBROWN.static final ColorThe color SALMON.static final ColorThe color SANDYBROWN.static final ColorThe color SEAGREEN.static final ColorThe color SEASHELL.static final ColorThe color SIENNA.static final ColorThe color SILVER.static final ColorThe color SKYBLUE.static final ColorThe color SLATEBLUE.static final ColorThe color SLATEGRAY.static final ColorThe color SLATEGREY.static final ColorThe color SNOW.static final ColorThe color SPRINGGREEN.static final ColorThe color STEELBLUE.static final ColorThe color TAN.static final ColorThe color TEAL.static final ColorThe color THISTLE.static final ColorThe color TOMATO.static final ColorThe color TRANSPARENT.static final ColorThe color TRANSPARENT.static final ColorThe color TURQUOISE.static final ColorThe color VIOLET.static final ColorThe color WHEAT.static final ColorThe color WHITE.static final ColorThe color WHITESMOKE.static final ColorThe color YELLOW.static final ColorThe color YELLOWGREEN. -
Method Summary
Modifier and TypeMethodDescriptioninta()Get the alpha component of this color as an integer.floatalpha()Get the alpha component of this color.intargb()Get the color value as an integer in ARGB order.static RGBColorargb(int argb) Create color from ARGB packed integer value.brighter()Get a brighter color.darker()Get a darker color.static HSVColorhsv(float h, float s, float v) Create color from HSV values.static HSVColorhsva(float h, float s, float v, float alpha) Create color from HSV values.booleanisOpaque()Test if this color is opaque.booleanTest if this color is transparent.palette()Get a mapping from color name to Color instance.static RGBColorrgb(int r, int g, int b) Create color from RGB values.default intrgba()Get the color value as an integer in RGBA order.static RGBColorrgba(int r, int g, int b, int a) Create color from RGBA values.static RGBColorrgbaF(float r, float g, float b, float alpha) Create color from RGB values.static RGBColorrgbF(float r, float g, float b) Create color from RGB values.default StringtoArgb()Get hex-string in ARGB form for this color.default byte[]Get the color components.default byte[]Get the color components.default StringtoCss()Get CSS compatible string representation of this color.default HSVColorConvert this color toHSVColor.default StringtoRgba()Get hex-string in RGBA form for this color.default RGBColorConvert this color toRGBColor.static ColorConvert 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
-