Interface IsColor
-
- All Known Implementing Classes:
Color
,GoogleChartColor
,GwtMaterialColor
,HtmlColor
public interface IsColor
Defines the methods that all colors must have and many of them have got already an implementation that usually does not need to be changed.- Author:
- Andrea "Stock" Stocchero
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default IsColor
alpha(double alpha)
Clones the color applying the alpha value.default IsColor
brighter()
Creates a new color that is a brighter version of this color.default IsColor
brighter(double alpha)
Creates a new color that is a brighter version of this color.static String
checkAndGetValue(IsColor value)
Checks a color value if consistent, returning the RGBA representation, otherwisenull
.static void
checkIfValid(IsColor color)
Checks if the passed color is consistent, that means with a right red, green, blue and alpha values.
If not consistent, anIllegalArgumentException
will be thrown.default IsColor
darker()
Creates a newColor
that is a darker version of thisColor
.
This method applies an arbitrary scale factor to each of the three RGB components of thisColor
to create a darker version of thisColor
.
Althoughbrighter
anddarker
are inverse operations, the results of a series of invocations of these two methods might be inconsistent because of rounding errors.default IsColor
darker(double alpha)
Creates a newColor
that is a darker version of thisColor
.
This method applies an arbitrary scale factor to each of the three RGB components of thisColor
to create a darker version of thisColor
.
Althoughbrighter
anddarker
are inverse operations, the results of a series of invocations of these two methods might be inconsistent because of rounding errors.double
getAlpha()
Returns the alpha rate.int
getBlue()
Returns the blue value.int
getGreen()
Returns the green value.int
getRed()
Returns the red value.default IsColor
interpolate(IsColor endColor, double percentage)
Returns a color from a specific offset starting from the current one.static boolean
isConsistent(IsColor color)
Returnstrue
if the passed color instance is consistent, that means with a right red, green, blue and alpha values and if the RGBA string representation is consistent as well.static boolean
isValid(IsColor color)
Returnstrue
if the passed color instance is consistent, that means with a right red, green, blue and alpha values.static boolean
isVisible(IsColor color)
Returnstrue
if the passed color instance is not transparent, with alpha greater than 0.default String
toHex()
Returns HEX string value which represents the color.default String
toHSL()
Returns HSL string value which represents the color.default String
toHSLA()
Returns HSLA string value which represents the color.default String
toRGB()
Returns RGB string value which represents the color.default String
toRGBA()
Returns RGBA string value which represents the color.default int
toRGBs()
As IEC 61966-2-1:1999, applies to the encoding and communication of RGB colors used in computer systems and similar applications, by defining encoding transformations for use in defined reference conditions.
-
-
-
Method Detail
-
isConsistent
static boolean isConsistent(IsColor color)
Returnstrue
if the passed color instance is consistent, that means with a right red, green, blue and alpha values and if the RGBA string representation is consistent as well.- Parameters:
color
- color instance to check- Returns:
true
if the passed color instance is consistent
-
isValid
static boolean isValid(IsColor color)
Returnstrue
if the passed color instance is consistent, that means with a right red, green, blue and alpha values.- Parameters:
color
- color instance to check- Returns:
true
if the passed color instance is consistent
-
isVisible
static boolean isVisible(IsColor color)
Returnstrue
if the passed color instance is not transparent, with alpha greater than 0.- Parameters:
color
- color instance to check- Returns:
true
if the passed color instance is not transparent
-
checkIfValid
static void checkIfValid(IsColor color)
Checks if the passed color is consistent, that means with a right red, green, blue and alpha values.
If not consistent, anIllegalArgumentException
will be thrown.- Parameters:
color
- color instance to check
-
checkAndGetValue
static String checkAndGetValue(IsColor value)
Checks a color value if consistent, returning the RGBA representation, otherwisenull
.- Parameters:
value
- value to be set- Returns:
- the string RGBA color representation or
null
if color is null
-
getRed
int getRed()
Returns the red value.- Returns:
- the red
-
getGreen
int getGreen()
Returns the green value.- Returns:
- the green
-
getBlue
int getBlue()
Returns the blue value.- Returns:
- the blue
-
getAlpha
double getAlpha()
Returns the alpha rate.- Returns:
- the alpha
-
alpha
default IsColor alpha(double alpha)
Clones the color applying the alpha value.- Parameters:
alpha
- the alpha to set- Returns:
- new color with the alpha value
-
toRGBA
default String toRGBA()
Returns RGBA string value which represents the color.- Returns:
- RGBA string value which represents the color
-
toRGB
default String toRGB()
Returns RGB string value which represents the color.- Returns:
- RGB string value which represents the color
-
toHex
default String toHex()
Returns HEX string value which represents the color.- Returns:
- HEX string value which represents the color.
-
toHSLA
default String toHSLA()
Returns HSLA string value which represents the color.- Returns:
- HSLA string value which represents the color
-
toHSL
default String toHSL()
Returns HSL string value which represents the color.- Returns:
- HSL string value which represents the color
-
toRGBs
default int toRGBs()
As IEC 61966-2-1:1999, applies to the encoding and communication of RGB colors used in computer systems and similar applications, by defining encoding transformations for use in defined reference conditions.
byte byte byte byte | | | | | +--------+--------+--------+--------+ alpha red green blue
- Returns:
- a integer value which represents the RGB color
-
interpolate
default IsColor interpolate(IsColor endColor, double percentage)
Returns a color from a specific offset starting from the current one.- Parameters:
endColor
- The end color to interpolatepercentage
- percentage, value between 0 1 and 1, to apply to the color interpolation- Returns:
- a color from a specific offset starting from the current one
-
brighter
default IsColor brighter()
Creates a new color that is a brighter version of this color.
This method applies an arbitrary scale factor to each of the three RGB components of this color to create a brighter version of this color.
Althoughbrighter
anddarker
are inverse operations, the results of a series of invocations of these two methods might be inconsistent because of rounding errors.- Returns:
- a new color object that is a brighter version of this color with the same alpha value.
-
brighter
default IsColor brighter(double alpha)
Creates a new color that is a brighter version of this color.
This method applies an arbitrary scale factor to each of the three RGB components of this color to create a brighter version of this color.
Althoughbrighter
anddarker
are inverse operations, the results of a series of invocations of these two methods might be inconsistent because of rounding errors.- Parameters:
alpha
- the alpha to set- Returns:
- a new color object that is a brighter version of this color with the passed alpha value.
-
darker
default IsColor darker()
Creates a newColor
that is a darker version of thisColor
.
This method applies an arbitrary scale factor to each of the three RGB components of thisColor
to create a darker version of thisColor
.
Althoughbrighter
anddarker
are inverse operations, the results of a series of invocations of these two methods might be inconsistent because of rounding errors.- Returns:
- a new color object that is a darker version of this color with the same alpha value.
-
darker
default IsColor darker(double alpha)
Creates a newColor
that is a darker version of thisColor
.
This method applies an arbitrary scale factor to each of the three RGB components of thisColor
to create a darker version of thisColor
.
Althoughbrighter
anddarker
are inverse operations, the results of a series of invocations of these two methods might be inconsistent because of rounding errors.- Parameters:
alpha
- the alpha to set- Returns:
- a new color object that is a darker version of this color with the passed alpha value.
-
-