Class LabColorSpace

  • All Implemented Interfaces:
    java.io.Serializable

    public class LabColorSpace
    extends java.awt.color.ColorSpace

    Represents the CIE 1976 (L*, a*, b*) or "CIELAB" device-independent ColorSpace. Colors from this ColorSpace can be used like any other color from the RGB or CMYK ColorSpaces, although they are most useful when specifying alternates for Spot colors.

    Technically you also need to specify the CIE illuminant to completely define the color, but usually the intention is to define an exact color for print output, so the D50 illuminant is assumed. If you require a D65 illuminant the getColorD65(float, float, float) method can be called.

    For example, here are three ways to specify the Color "PANTONE® Reflex Blue C" - the first using L*a*b values in CIELAB space with a D50 illuminant, the second in the same space with a D65 illuminant, and the third using a CMYK process colorspace. Note that the third approach is an approximation only as this particular shade can not normally be reproduced using a four-color process, which is why using Lab colors as alternatives for Spot colors is the best option if possible.

     Color blue = SpotColorSpace.getInstance("Pantone Reflex Blue C", LabColorSpace.getColor(19, 26, -68));
     Color blue = SpotColorSpace.getInstance("Pantone Reflex Blue C", LabColorSpace.getColorD65(26.18, 18.64, -59.93));
     Color blue = SpotColorSpace.getInstance("Pantone Reflex Blue C", CMYKColorSpace.getColor(1, 0.73f, 0, 0.02f));
     
    Since:
    2.14.1
    See Also:
    Serialized Form
    • Field Summary

      • 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
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<java.util.Map.Entry<java.lang.Float,​java.awt.Color>> convertGradient​(java.util.List<java.util.Map.Entry<java.lang.Float,​java.awt.Color>> in, java.awt.color.ColorSpace target, java.awt.color.ColorSpace interpolation, java.lang.String options)
      Given a list of [Fraction,Color] pairs in one (or more) ColorSpaces representing a Gradient, return a List representing the same gradient in the specified target ColorSpace, ensuring that each Color is within the specified tolerance.
      boolean equals​(java.lang.Object o)  
      float[] fromCIEXYZ​(float[] xyz)  
      float[] fromRGB​(float[] rgb)  
      static java.awt.Color getColor​(float L, float a, float b)
      Get a Color in the standard CIELAB D50 ColorSpace, based on the D50 illuminant.
      static java.awt.Color getColor​(float L, float a, float b, float alpha)
      Get a Color in the standard CIELAB D50 ColorSpace, based on the D50 illuminant.
      static java.awt.Color getColorD65​(float L, float a, float b)
      Get a Color in the CIELAB ColorSpace, based on the D65 illuminant.
      static LabColorSpace getInstance()
      Return a standard instance of the Lab Colorspace, with a D50 whitepoint
      float getMaxValue​(int c)  
      float getMinValue​(int c)  
      java.lang.String getName​(int i)  
      int hashCode()  
      float[] toCIEXYZ​(float[] lab)
      Note this method will typically be called when converting a bitmap, and we have to map from
      float[] toRGB​(float[] lab)  
      java.lang.String toString()  
      • Methods inherited from class java.awt.color.ColorSpace

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

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getInstance

        public static final LabColorSpace getInstance()
        Return a standard instance of the Lab Colorspace, with a D50 whitepoint
        Since:
        2.26
      • getName

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toRGB

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

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

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

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

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

        public float[] toCIEXYZ​(float[] lab)
        Note this method will typically be called when converting a bitmap, and we have to map from
        Specified by:
        toCIEXYZ in class java.awt.color.ColorSpace
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getColor

        public static java.awt.Color getColor​(float L,
                                              float a,
                                              float b)
        Get a Color in the standard CIELAB D50 ColorSpace, based on the D50 illuminant. This is usually the correct method to get a Lab color for use as an alternate for a SpotColorSpace Spot color, for instance.
        Parameters:
        L - the "L" value, which will be clipped to the range 0..100
        a - the "a" value, which will be clipped to the range -100..100
        b - the "b" value, which will be clipped to the range -100..100
      • getColor

        public static java.awt.Color getColor​(float L,
                                              float a,
                                              float b,
                                              float alpha)
        Get a Color in the standard CIELAB D50 ColorSpace, based on the D50 illuminant. This is usually the correct method to get a Lab color for use as an alternate for a SpotColorSpace Spot color, for instance.
        Parameters:
        L - the "L" value, which will be clipped to the range 0..100
        a - the "a" value, which will be clipped to the range -100..100
        b - the "b" value, which will be clipped to the range -100..100
        alpha - the alpha value from 0..1
      • getColorD65

        public static java.awt.Color getColorD65​(float L,
                                                 float a,
                                                 float b)
        Get a Color in the CIELAB ColorSpace, based on the D65 illuminant.
        Parameters:
        L - the "L" value, which will be clipped to the range 0..100
        a - the "a" value, which will be clipped to the range -100..100
        b - the "b" value, which will be clipped to the range -100..100
      • convertGradient

        public static java.util.List<java.util.Map.Entry<java.lang.Float,​java.awt.Color>> convertGradient​(java.util.List<java.util.Map.Entry<java.lang.Float,​java.awt.Color>> in,
                                                                                                                java.awt.color.ColorSpace target,
                                                                                                                java.awt.color.ColorSpace interpolation,
                                                                                                                java.lang.String options)
        Given a list of [Fraction,Color] pairs in one (or more) ColorSpaces representing a Gradient, return a List representing the same gradient in the specified target ColorSpace, ensuring that each Color is within the specified tolerance. The colors will be interpolated in the specified interpolation ColorSpace, which may be null - if it is, the interpolation ColorSpace is the ColorSpace of the supplied colors, or CIELab if they're in multiple ColorSpaces. The tolerance is the maximum CIE94 delta-E allowable. This method is definitely not for general use.
        Parameters:
        in - the list of [t, color] pairs, where t is a value from 0..1 indicating the location in the gradient, and color is the color at that point. The "t" values must be strictly ascending.
        target - the target ColorSpace which all the colors will be converted to, or null to choose an appropriate space supported in PDF
        interpolation - the ColorSpace which the interpolation will take place in, or null to derive as described above.
        options - options to control the process.
        Since:
        2.24.1