Package com.teamdev.jxbrowser.ui
Interface Color
public interface Color
A numeric model of an RGB color. The components of the color instance are presented in the
arithmetic notation. This means that each component accepts any fractional value from 0 to 1.
If all the components except alpha
are at zero and the alpha
is at 1, the
result is black. If all are at 1, the result is the brightest representable white.
Important: the component values out of the 0..1
range are not allowed and
should not be used.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault float
alpha()
Returns the opacity channel value in the0..1
range.default float
blue()
Returns the blue channel value in the0..1
range.default float
green()
Returns the green channel value in the0..1
range.default boolean
isValid()
Returnstrue
if this color is a valid color.static Color.Builder
Creates a newColor
builder with the given required parameters.default float
red()
Returns the red channel value in the0..1
range.static Color
rgb
(float red, float green, float blue) Creates a newColor
instance from the passedRGB
values with opacity (alpha) channel set to 1 (non-transparent).static Color
rgba
(float red, float green, float blue, float alpha) Creates a newColor
instance from the passedRGBA
values.default String
toHexRGB()
Returns a string representation for this color in the#RGB
hex format.default String
Returns a string representation for this color in the#RGBA
hex format.
-
Method Details
-
newBuilder
Creates a newColor
builder with the given required parameters.- Returns:
- a new
Color.Builder
instance
-
rgba
Creates a newColor
instance from the passedRGBA
values.- Parameters:
red
- the red channel value in the0..1
rangegreen
- the green channel value in the0..1
rangeblue
- the blue channel value in the0..1
rangealpha
- the opacity channel value in the0..1
range- Returns:
- a new
Color
instance - Throws:
IllegalArgumentException
- if any of the passed values is out of the0..1
range
-
rgb
Creates a newColor
instance from the passedRGB
values with opacity (alpha) channel set to 1 (non-transparent).- Parameters:
red
- the red channel value in the0..1
rangegreen
- the green channel value in the0..1
rangeblue
- the blue channel value in the0..1
range- Returns:
- a new
Color
instance - Throws:
IllegalArgumentException
- if any of the passed values is out of the0..1
range
-
isValid
default boolean isValid()Returnstrue
if this color is a valid color. The color is valid only if its channel values are in the0..1
range. -
toHexRGBA
Returns a string representation for this color in the#RGBA
hex format.- Throws:
IllegalArgumentException
- when this color is invalid
-
toHexRGB
Returns a string representation for this color in the#RGB
hex format.- Throws:
IllegalArgumentException
- when this color is invalid
-
alpha
default float alpha()Returns the opacity channel value in the0..1
range. When the value is 1, the color is 100% opaque. When 0, the color is 100% transparent. -
blue
default float blue()Returns the blue channel value in the0..1
range. -
green
default float green()Returns the green channel value in the0..1
range. -
red
default float red()Returns the red channel value in the0..1
range.
-