Package io.guise.framework.style
Class HSLColor
- java.lang.Object
-
- io.guise.framework.style.AbstractModeledColor<HSLColor.Component>
-
- io.guise.framework.style.HSLColor
-
- All Implemented Interfaces:
Color
,ModeledColor<HSLColor.Component>
public class HSLColor extends AbstractModeledColor<HSLColor.Component>
Encapsulates a color value of the HSL color space.- Author:
- Garret Wilson
- See Also:
- HSL color space, HSLColor Class, EasyRGB
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HSLColor.Component
A color component of HSL.
-
Constructor Summary
Constructors Constructor Description 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).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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HSLColor
asHSL()
RGBColor
asRGB()
double
getHue()
double
getHueDegrees()
Determines the value of the hue in degrees in the range (0.0-360.0].double
getLightness()
double
getSaturation()
static HSLColor
valueOf(java.lang.CharSequence charSequence)
Creates an HSL color from a string representation.-
Methods inherited from class io.guise.framework.style.AbstractModeledColor
checkComponentValue, equals, getAbsoluteComponent, getComponent, getValues, hashCode
-
-
-
-
Constructor Detail
-
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:
java.lang.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:
java.lang.IllegalArgumentException
- if one of the values is outside the range (0.0-1.0).
-
-
Method Detail
-
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
public HSLColor asHSL()
- Returns:
- The color in the HSL color space.
-
asRGB
public RGBColor asRGB()
- Returns:
- The color in the RGB color space.
-
valueOf
public static HSLColor valueOf(java.lang.CharSequence charSequence)
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:
java.lang.NullPointerException
- if the given string isnull
.java.lang.IllegalArgumentException
- if a color cannot be determined from the given string.
-
-