Class CIELabColorSpace

  • All Implemented Interfaces:
    java.io.Serializable

    public class CIELabColorSpace
    extends java.awt.color.ColorSpace
    This class defines the CIE L*a*b* (CIE 1976) color space. Valid values for L* are between 0 and 100, for a* and b* between -127 and +127.
    See Also:
    http://en.wikipedia.org/wiki/Lab_color_space, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String CIE_LAB_ONLY_HAS_3_COMPONENTS  
      private static double D  
      private static double REF_A  
      private static double REF_B  
      private static float REF_X_D50  
      private static float REF_X_D65  
      private static float REF_Y_D50  
      private static float REF_Y_D65  
      private static float REF_Z_D50  
      private static float REF_Z_D65  
      private static long serialVersionUID  
      private static double T0  
      private float wpX  
      private float wpY  
      private float wpZ  
      • 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
      CIELabColorSpace()
      Default constructor using the D65 white point.
      CIELabColorSpace​(float[] whitePoint)
      CIE Lab space constructor which allows to give an arbitrary white point.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void checkNumComponents​(float[] colorvalue)  
      private void checkNumComponents​(float[] colorvalue, int expected)  
      private float denormalize​(float value, int component)  
      float[] fromCIEXYZ​(float[] colorvalue)
      float[] fromRGB​(float[] rgbvalue)
      static float[] getD50WhitePoint()
      Returns the D50 white point.
      static float[] getD65WhitePoint()
      Returns the D65 white point.
      float getMaxValue​(int component)
      float getMinValue​(int component)
      java.lang.String getName​(int component)
      private float getNativeValueRange​(int component)  
      float[] getWhitePoint()
      Returns the configured white point.
      private float normalize​(float value, int component)  
      float[] toCIEXYZ​(float[] colorvalue)
      float[] toCIEXYZNative​(float l, float a, float b)
      Transforms a color value assumed to be in this ColorSpace into the CS_CIEXYZ conversion color space.
      java.awt.Color toColor​(float[] colorvalue, float alpha)
      Creates a Color instance from color values usually used by the L*a*b* color space by scaling them to the 0.0..1.0 range expected by Color's constructor.
      java.awt.Color toColor​(float l, float a, float b, float alpha)
      Creates a Color instance from color values usually used by the L*a*b* color space by scaling them to the 0.0..1.0 range expected by Color's constructor.
      float[] toNativeComponents​(float[] comps)
      Converts normalized (0..1) color components to CIE L*a*b*'s native value range.
      float[] toRGB​(float[] colorvalue)
      • Methods inherited from class java.awt.color.ColorSpace

        getInstance, getNumComponents, getType, isCS_sRGB
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CIELabColorSpace

        public CIELabColorSpace()
        Default constructor using the D65 white point.
      • CIELabColorSpace

        public CIELabColorSpace​(float[] whitePoint)
        CIE Lab space constructor which allows to give an arbitrary white point.
        Parameters:
        whitePoint - the white point in XYZ coordinates (valid values: 0.0f to 1.0f, although values slightly larger than 1.0f are common)
    • Method Detail

      • getD65WhitePoint

        public static float[] getD65WhitePoint()
        Returns the D65 white point.
        Returns:
        the D65 white point.
      • getD50WhitePoint

        public static float[] getD50WhitePoint()
        Returns the D50 white point.
        Returns:
        the D50 white point.
      • checkNumComponents

        private void checkNumComponents​(float[] colorvalue)
      • checkNumComponents

        private void checkNumComponents​(float[] colorvalue,
                                        int expected)
      • getWhitePoint

        public float[] getWhitePoint()
        Returns the configured white point.
        Returns:
        the white point in CIE XYZ coordinates
      • getMinValue

        public float getMinValue​(int component)
        Overrides:
        getMinValue in class java.awt.color.ColorSpace
      • getMaxValue

        public float getMaxValue​(int component)
        Overrides:
        getMaxValue in class java.awt.color.ColorSpace
      • getName

        public java.lang.String getName​(int component)
        Overrides:
        getName in class java.awt.color.ColorSpace
      • fromCIEXYZ

        public float[] fromCIEXYZ​(float[] colorvalue)
        Specified by:
        fromCIEXYZ in class java.awt.color.ColorSpace
      • fromRGB

        public float[] fromRGB​(float[] rgbvalue)
        Specified by:
        fromRGB in class java.awt.color.ColorSpace
      • toCIEXYZ

        public float[] toCIEXYZ​(float[] colorvalue)
        Specified by:
        toCIEXYZ in class java.awt.color.ColorSpace
      • toCIEXYZNative

        public float[] toCIEXYZNative​(float l,
                                      float a,
                                      float b)
        Transforms a color value assumed to be in this ColorSpace into the CS_CIEXYZ conversion color space. This method uses component values in CIE Lab's native color ranges rather than the normalized values between 0 and 1.
        Parameters:
        l - the L* component (values between 0 and 100)
        a - the a* component (usually between -128 and +128)
        b - the b* component (usually between -128 and +128)
        Returns:
        the XYZ color values
        See Also:
        toCIEXYZ(float[])
      • toRGB

        public float[] toRGB​(float[] colorvalue)
        Specified by:
        toRGB in class java.awt.color.ColorSpace
      • getNativeValueRange

        private float getNativeValueRange​(int component)
      • normalize

        private float normalize​(float value,
                                int component)
      • denormalize

        private float denormalize​(float value,
                                  int component)
      • toNativeComponents

        public float[] toNativeComponents​(float[] comps)
        Converts normalized (0..1) color components to CIE L*a*b*'s native value range.
        Parameters:
        comps - the normalized components.
        Returns:
        the denormalized components
      • toColor

        public java.awt.Color toColor​(float[] colorvalue,
                                      float alpha)
        Creates a Color instance from color values usually used by the L*a*b* color space by scaling them to the 0.0..1.0 range expected by Color's constructor.
        Parameters:
        colorvalue - the original color values (native value range, i.e. not normalized to 0.0..1.0)
        alpha - the alpha component
        Returns:
        the requested color instance
      • toColor

        public java.awt.Color toColor​(float l,
                                      float a,
                                      float b,
                                      float alpha)
        Creates a Color instance from color values usually used by the L*a*b* color space by scaling them to the 0.0..1.0 range expected by Color's constructor.
        Parameters:
        l - the L* component (values between 0 and 100)
        a - the a* component (usually between -128 and +127)
        b - the b* component (usually between -128 and +127)
        alpha - the alpha component (values between 0 and 1)
        Returns:
        the requested color instance