Class HSLColorSpace
- All Implemented Interfaces:
java.io.Serializable
public class HSLColorSpace
extends java.awt.color.ColorSpace
- Author:
- Kevin Menningen
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static int
HUE_INDEX
The index in a return array of values for the entry containing the hue value.static int
LUMINANCE_INDEX
The index in a return array of values for the entry containing the luminance value.static int
SATURATION_INDEX
The index in a return array of values for the entry containing the saturation value.Fields inherited from class java.awt.color.ColorSpace
CS_CIEXYZ, CS_GRAY, CS_LINEAR_RGB, CS_PYCC, CS_sRGB, TYPE_2CLR, TYPE_3CLR, TYPE_4CLR, TYPE_5CLR, TYPE_6CLR, TYPE_7CLR, TYPE_8CLR, TYPE_9CLR, TYPE_ACLR, TYPE_BCLR, TYPE_CCLR, TYPE_CMY, TYPE_CMYK, TYPE_DCLR, TYPE_ECLR, TYPE_FCLR, TYPE_GRAY, TYPE_HLS, TYPE_HSV, TYPE_Lab, TYPE_Luv, TYPE_RGB, TYPE_XYZ, TYPE_YCbCr, TYPE_Yxy
-
Constructor Summary
Constructors Constructor Description HSLColorSpace()
Default constructor. -
Method Summary
Modifier and Type Method Description float[]
fromCIEXYZ(float[] colorvalue)
Transforms a color value assumed to be in the CS_CIEXYZ conversion color space into this ColorSpace.float[]
fromRGB(float[] rgbvalue)
Transforms a color value assumed to be in the default CS_sRGB color space into this ColorSpace.float
getMaxValue(int component)
Returns the maximum normalized color component value for the specified component.float
getMinValue(int component)
Returns the minimum normalized color component value for the specified component.float[]
toCIEXYZ(float[] colorvalue)
Transforms a color value assumed to be in this ColorSpace into the CS_CIEXYZ conversion color space.float[]
toRGB(float[] colorvalue)
Transforms a color value assumed to be in this ColorSpace into a value in the default CS_sRGB color space.
-
Field Details
-
HUE_INDEX
public static final int HUE_INDEXThe index in a return array of values for the entry containing the hue value.- See Also:
- Constant Field Values
-
SATURATION_INDEX
public static final int SATURATION_INDEXThe index in a return array of values for the entry containing the saturation value.- See Also:
- Constant Field Values
-
LUMINANCE_INDEX
public static final int LUMINANCE_INDEXThe index in a return array of values for the entry containing the luminance value.- See Also:
- Constant Field Values
-
-
Constructor Details
-
HSLColorSpace
public HSLColorSpace()Default constructor.
-
-
Method Details
-
toRGB
public float[] toRGB(float[] colorvalue)Transforms a color value assumed to be in this ColorSpace into a value in the default CS_sRGB color space.This method transforms color values using algorithms designed to produce the best perceptual match between input and output colors. In order to do colorimetric conversion of color values, you should use the
toCIEXYZ
method of this color space to first convert from the input color space to the CS_CIEXYZ color space, and then use thefromCIEXYZ
method of the CS_sRGB color space to convert from CS_CIEXYZ to the output color space. SeetoCIEXYZ
andfromCIEXYZ
for further information.- Specified by:
toRGB
in classjava.awt.color.ColorSpace
- Parameters:
colorvalue
- a float array with length of at least the number of components in this ColorSpace- Returns:
- a float array of length 3
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if array length is not at least the number of components in this ColorSpace
-
fromRGB
public float[] fromRGB(float[] rgbvalue)Transforms a color value assumed to be in the default CS_sRGB color space into this ColorSpace.This method transforms color values using algorithms designed to produce the best perceptual match between input and output colors. In order to do colorimetric conversion of color values, you should use the
toCIEXYZ
method of the CS_sRGB color space to first convert from the input color space to the CS_CIEXYZ color space, and then use thefromCIEXYZ
method of this color space to convert from CS_CIEXYZ to the output color space. SeetoCIEXYZ
andfromCIEXYZ
for further information.- Specified by:
fromRGB
in classjava.awt.color.ColorSpace
- Parameters:
rgbvalue
- a float array with length of at least 3- Returns:
- a float array with length equal to the number of components in this ColorSpace
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if array length is not at least 3
-
toCIEXYZ
public float[] toCIEXYZ(float[] colorvalue)Transforms a color value assumed to be in this ColorSpace into the CS_CIEXYZ conversion color space.This method transforms color values using relative colorimetry, as defined by the International Color Consortium standard. This means that the XYZ values returned by this method are represented relative to the D50 white point of the CS_CIEXYZ color space. This representation is useful in a two-step color conversion process in which colors are transformed from an input color space to CS_CIEXYZ and then to an output color space. This representation is not the same as the XYZ values that would be measured from the given color value by a colorimeter. A further transformation is necessary to compute the XYZ values that would be measured using current CIE recommended practices. See the
toCIEXYZ
method ofICC_ColorSpace
for further information.- Specified by:
toCIEXYZ
in classjava.awt.color.ColorSpace
- Parameters:
colorvalue
- a float array with length of at least the number of components in this ColorSpace- Returns:
- a float array of length 3
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if array length is not at least the number of components in this ColorSpace.
-
fromCIEXYZ
public float[] fromCIEXYZ(float[] colorvalue)Transforms a color value assumed to be in the CS_CIEXYZ conversion color space into this ColorSpace.This method transforms color values using relative colorimetry, as defined by the International Color Consortium standard. This means that the XYZ argument values taken by this method are represented relative to the D50 white point of the CS_CIEXYZ color space. This representation is useful in a two-step color conversion process in which colors are transformed from an input color space to CS_CIEXYZ and then to an output color space. The color values returned by this method are not those that would produce the XYZ value passed to the method when measured by a colorimeter. If you have XYZ values corresponding to measurements made using current CIE recommended practices, they must be converted to D50 relative values before being passed to this method. See the
fromCIEXYZ
method ofICC_ColorSpace
for further information.- Specified by:
fromCIEXYZ
in classjava.awt.color.ColorSpace
- Parameters:
colorvalue
- a float array with length of at least 3- Returns:
- a float array with length equal to the number of components in this ColorSpace
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if array length is not at least 3
-
getMinValue
public float getMinValue(int component)Returns the minimum normalized color component value for the specified component. The default implementation in this abstract class returns 0.0 for all components. Subclasses should override this method if necessary.- Overrides:
getMinValue
in classjava.awt.color.ColorSpace
- Parameters:
component
- the component index- Returns:
- the minimum normalized component value
- Throws:
java.lang.IllegalArgumentException
- if component is less than 0 or greater than numComponents - 1- Since:
- 1.4
-
getMaxValue
public float getMaxValue(int component)Returns the maximum normalized color component value for the specified component. The default implementation in this abstract class returns 1.0 for all components. Subclasses should override this method if necessary.- Overrides:
getMaxValue
in classjava.awt.color.ColorSpace
- Parameters:
component
- the component index- Returns:
- the maximum normalized component value
- Throws:
java.lang.IllegalArgumentException
- if component is less than 0 or greater than numComponents - 1- Since:
- 1.4
-