com.guiseframework.style
Class HSLColor

java.lang.Object
  extended by com.guiseframework.style.AbstractModeledColor<HSLColor.Component>
      extended by com.guiseframework.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
static class HSLColor.Component
          A color component of HSL.
 
Constructor Summary
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
 HSLColor asHSL()
           
 RGBColor asRGB()
          Converts this HSL color to an RGB color.
 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 com.guiseframework.style.AbstractModeledColor
checkComponentValue, equals, getAbsoluteComponent, getComponent, getValues, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

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()
Converts this HSL color to an RGB color.

Returns:
The color in the RGB color space.
See Also:
HSL color space: Converting to RGB, EasyRGB HSL->RGB

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:

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 is null.
java.lang.IllegalArgumentException - if a color cannot be determined from the given string.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.