Interface IsColor
-
- All Known Implementing Classes:
Color,GoogleChartColor,GwtMaterialColor,HtmlColor
public interface IsColorDefines 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 IsColoralpha(double alpha)Clones the color applying the alpha value.default IsColorbrighter()Creates a new color that is a brighter version of this color.default IsColorbrighter(double alpha)Creates a new color that is a brighter version of this color.static StringcheckAndGetValue(IsColor value)Checks a color value if consistent, returning the RGBA representation, otherwisenull.static voidcheckIfValid(IsColor color)Checks if the passed color is consistent, that means with a right red, green, blue and alpha values.
If not consistent, anIllegalArgumentExceptionwill be thrown.default IsColordarker()Creates a newColorthat is a darker version of thisColor.
This method applies an arbitrary scale factor to each of the three RGB components of thisColorto create a darker version of thisColor.
Althoughbrighteranddarkerare inverse operations, the results of a series of invocations of these two methods might be inconsistent because of rounding errors.default IsColordarker(double alpha)Creates a newColorthat is a darker version of thisColor.
This method applies an arbitrary scale factor to each of the three RGB components of thisColorto create a darker version of thisColor.
Althoughbrighteranddarkerare inverse operations, the results of a series of invocations of these two methods might be inconsistent because of rounding errors.doublegetAlpha()Returns the alpha rate.intgetBlue()Returns the blue value.intgetGreen()Returns the green value.intgetRed()Returns the red value.default IsColorinterpolate(IsColor endColor, double percentage)Returns a color from a specific offset starting from the current one.static booleanisConsistent(IsColor color)Returnstrueif 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 booleanisValid(IsColor color)Returnstrueif the passed color instance is consistent, that means with a right red, green, blue and alpha values.static booleanisVisible(IsColor color)Returnstrueif the passed color instance is not transparent, with alpha greater than 0.default StringtoHex()Returns HEX string value which represents the color.default StringtoHSL()Returns HSL string value which represents the color.default StringtoHSLA()Returns HSLA string value which represents the color.default StringtoRGB()Returns RGB string value which represents the color.default StringtoRGBA()Returns RGBA string value which represents the color.default inttoRGBs()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)
Returnstrueif 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:
trueif the passed color instance is consistent
-
isValid
static boolean isValid(IsColor color)
Returnstrueif the passed color instance is consistent, that means with a right red, green, blue and alpha values.- Parameters:
color- color instance to check- Returns:
trueif the passed color instance is consistent
-
isVisible
static boolean isVisible(IsColor color)
Returnstrueif the passed color instance is not transparent, with alpha greater than 0.- Parameters:
color- color instance to check- Returns:
trueif 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, anIllegalArgumentExceptionwill 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
nullif 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.
Althoughbrighteranddarkerare 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.
Althoughbrighteranddarkerare 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 newColorthat is a darker version of thisColor.
This method applies an arbitrary scale factor to each of the three RGB components of thisColorto create a darker version of thisColor.
Althoughbrighteranddarkerare 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 newColorthat is a darker version of thisColor.
This method applies an arbitrary scale factor to each of the three RGB components of thisColorto create a darker version of thisColor.
Althoughbrighteranddarkerare 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.
-
-