Package io.guise.framework.style
Class AbstractModeledColor<C extends Enum<C> & ModeledColor.Component>
java.lang.Object
io.guise.framework.style.AbstractModeledColor<C>
- Type Parameters:
C
- The type of color component for this color space.
- All Implemented Interfaces:
Color
,ModeledColor<C>
public abstract class AbstractModeledColor<C extends Enum<C> & ModeledColor.Component>
extends Object
implements ModeledColor<C>
Abstract representation of a color value in a color space.
- Author:
- Garret Wilson
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.guise.framework.style.ModeledColor
ModeledColor.Component
-
Constructor Summary
ConstructorDescriptionAbstractModeledColor
(double... values) Constructs a color with the given components. -
Method Summary
Modifier and TypeMethodDescriptionprotected static double
checkComponentValue
(double value) Checks the range of a given color component.boolean
long
getAbsoluteComponent
(C component, int bitDepth) Determines the absolute value of the given color component with the given bit depth.double
getComponent
(C component) Determines the value of the given color component.double[]
int
hashCode()
static Color
valueOf
(CharSequence charSequence) Creates a color from a string representation.
-
Constructor Details
-
AbstractModeledColor
public AbstractModeledColor(double... values) Constructs a color with the given components.- Parameters:
values
- The values of components of the color in the correct color space, each within the range (0.0-1.0), in the order of the component ordinals.- Throws:
NullPointerException
- if the components isnull
. TODO fix @throws IllegalArgumentException if the number of component values do not equal the number of components.
-
-
Method Details
-
getValues
public double[] getValues()- Returns:
- The color component values, each within the range (0.0-1.0).
-
checkComponentValue
protected static double checkComponentValue(double value) Checks the range of a given color component.- Parameters:
value
- The value to check.- Returns:
- The checked value.
- Throws:
IllegalArgumentException
- if the given component is outside the range (0.0-1.0).
-
getComponent
Description copied from interface:ModeledColor
Determines the value of the given color component.- Specified by:
getComponent
in interfaceModeledColor<C extends Enum<C> & ModeledColor.Component>
- Parameters:
component
- The color component for which a value should be retrieved.- Returns:
- The value of the requested color component.
-
getAbsoluteComponent
Description copied from interface:ModeledColor
Determines the absolute value of the given color component with the given bit depth. For example, retrieving a component with value 0.5 and a bit depth of 16 would produce 128 or 0x80.- Specified by:
getAbsoluteComponent
in interfaceModeledColor<C extends Enum<C> & ModeledColor.Component>
- Parameters:
component
- The color component for which a value should be retrieved.bitDepth
- The number of bits to use for the given color component.- Returns:
- The absolute value of the requested color component at the given bit depth.
- See Also:
-
hashCode
public int hashCode() -
equals
This implementation returns whether the objects are of the same class with identical color component values.
-
valueOf
Creates a color from a string representation. This representation can be in one of the following forms:colorname
, one of the HTML color names, which must be in all lowercase without delimiters, such as "aliceblue".#rgb
, with hexadecimal representation of RGB color components without regard to case.#rrggbb
, with hexadecimal representation of RGB color components without regard to case.rgb(red,green,blue)
, with decimal representation with a depth of eight bits (0-255).rgb(red%,green%,blue%)
, with decimal component values multiplied by 100 (0.0-100.0%).rgba(red,green,blue,alpha)
, with decimal representation with a depth of eight bits (0-255).rgba(red%,green%,blue%,alpha%)
, with decimal component values multiplied by 100 (0.0%-100.0%).hsl(hue,saturation,lightness)
, with decimal representation with a depth of eight bits (0-255).hsl(hue%,saturation%,lightness%)
, with decimal component values multiplied by 100 (0.0-100.0%).
transparent
color name as equivalent torgba(0, 0, 0, 0)
, or black with zero alpha.- Parameters:
charSequence
- The character sequence representation of a color.- Returns:
- A color object representing the color represented by the given string.
- Throws:
NullPointerException
- if the given string isnull
.IllegalArgumentException
- if a color cannot be determined from the given string.- See Also:
-