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
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault floatalpha()Returns the opacity channel value in the0..1range.default floatblue()Returns the blue channel value in the0..1range.default floatgreen()Returns the green channel value in the0..1range.default booleanisValid()Returnstrueif this color is a valid color.static Color.BuilderCreates a newColorbuilder with the given required parameters.default floatred()Returns the red channel value in the0..1range.static Colorrgb(float red, float green, float blue) Creates a newColorinstance from the passedRGBvalues with opacity (alpha) channel set to 1 (non-transparent).static Colorrgba(float red, float green, float blue, float alpha) Creates a newColorinstance from the passedRGBAvalues.default StringtoHexRGB()Returns a string representation for this color in the#RGBhex format.default StringReturns a string representation for this color in the#RGBAhex format.
-
Method Details
-
newBuilder
Creates a newColorbuilder with the given required parameters.- Returns:
- a new
Color.Builderinstance
-
rgba
Creates a newColorinstance from the passedRGBAvalues.- Parameters:
red- the red channel value in the0..1rangegreen- the green channel value in the0..1rangeblue- the blue channel value in the0..1rangealpha- the opacity channel value in the0..1range- Returns:
- a new
Colorinstance - Throws:
IllegalArgumentException- if any of the passed values is out of the0..1range
-
rgb
Creates a newColorinstance from the passedRGBvalues with opacity (alpha) channel set to 1 (non-transparent).- Parameters:
red- the red channel value in the0..1rangegreen- the green channel value in the0..1rangeblue- the blue channel value in the0..1range- Returns:
- a new
Colorinstance - Throws:
IllegalArgumentException- if any of the passed values is out of the0..1range
-
isValid
default boolean isValid()Returnstrueif this color is a valid color. The color is valid only if its channel values are in the0..1range. -
toHexRGBA
Returns a string representation for this color in the#RGBAhex format.- Throws:
IllegalArgumentException- when this color is invalid
-
toHexRGB
Returns a string representation for this color in the#RGBhex format.- Throws:
IllegalArgumentException- when this color is invalid
-
alpha
default float alpha()Returns the opacity channel value in the0..1range. 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..1range. -
green
default float green()Returns the green channel value in the0..1range. -
red
default float red()Returns the red channel value in the0..1range.
-