Package io.guise.framework.style
Class HSLColor
- All Implemented Interfaces:
Color
,ModeledColor<HSLColor.Component>
Encapsulates a color value of the HSL color space.
- Author:
- Garret Wilson
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionHSLColor
(double hue, double saturation, double lightness) Creates an HSL color with the specified hue, saturation, and lightness component values in the range (0.0-1.0).HSLColor
(int hue, double saturation, double lightness) Creates an HSL color with the specified hue in the range (0-359), and saturation, and lightness component values in the range (0.0-1.0). -
Method Summary
Methods inherited from class io.guise.framework.style.AbstractModeledColor
checkComponentValue, equals, getAbsoluteComponent, getComponent, getValues, hashCode
-
Constructor Details
-
HSLColor
public HSLColor(int hue, double saturation, double lightness) Creates an HSL color with the specified hue in the range (0-359), and saturation, and lightness component values in the range (0.0-1.0).- Parameters:
hue
- The hue component as an integer value in the range (0-359).saturation
- The saturation component in the range (0.0-1.0).lightness
- The lightness component in the range (0.0-1.0).- Throws:
IllegalArgumentException
- if the hue is outside the range (0-359), and/or if one of the other values is outside the range (0.0-1.0).
-
HSLColor
public HSLColor(double hue, double saturation, double lightness) Creates an HSL color with the specified hue, saturation, and lightness component values in the range (0.0-1.0).- Parameters:
hue
- The hue component.saturation
- The saturation component.lightness
- The lightness component.- Throws:
IllegalArgumentException
- if one of the values is outside the range (0.0-1.0).
-
-
Method Details
-
getHue
public double getHue()- Returns:
- The hue component value.
-
getHueDegrees
public double getHueDegrees()Determines the value of the hue in degrees in the range (0.0-360.0]. For example, retrieving a hue with value 0.5 would produce 180.- Returns:
- The absolute value of the hue in degrees.
-
getSaturation
public double getSaturation()- Returns:
- The saturation component value.
-
getLightness
public double getLightness()- Returns:
- The lightness component value.
-
asHSL
- Returns:
- The color in the HSL color space.
-
asRGB
- Returns:
- The color in the RGB color space.
-
valueOf
Creates an HSL color from a string representation. This representation can be in one of the following forms: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%).
- Parameters:
charSequence
- The character sequence representation of an HSL color.- Returns:
- An RGB 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.
-