ColorUtil
Date: 2016-04-28

org.apache.xmlgraphics.java2d.color

## Class ColorUtil

- java.lang.Object
- - org.apache.xmlgraphics.java2d.color.ColorUtil

-     public final class ColorUtil
      extends java.lang.Object

  Generic Color helper class.

  This class supports parsing string values into color values and creating color values for strings. It provides a list of standard color names.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `isGray(java.awt.Color col)` Indicates whether the color is a gray value.
    `static boolean` | `isSameColor(java.awt.Color col1, java.awt.Color col2)` Checks if two colors are the same color.
    `static java.awt.Color` | `lightenColor(java.awt.Color col, float factor)` Lightens up a color for groove, ridge, inset and outset border effects.
    `static java.awt.Color` | `toCMYKGrayColor(float black)` Creates an uncalibrated CMYK color with the given gray value.
    `static java.awt.Color` | `toSRGBColor(java.awt.Color col)` Converts an arbitrary `Color` to a plain sRGB color doing the conversion at the best possible conversion quality.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### lightenColor

          public static java.awt.Color lightenColor(java.awt.Color col,
                                    float factor)

      Lightens up a color for groove, ridge, inset and outset border effects.
      Parameters:
        `col` - the color to lighten up
        `factor` - factor by which to lighten up (negative values darken the color)
      Returns:
        the modified color

    - #### isGray

          public static boolean isGray(java.awt.Color col)

      Indicates whether the color is a gray value.
      Parameters:
        `col` - the color
      Returns:
        true if it is a gray value

    - #### toCMYKGrayColor

          public static java.awt.Color toCMYKGrayColor(float black)

      Creates an uncalibrated CMYK color with the given gray value.
      Parameters:
        `black` - the gray component (0 - 1)
      Returns:
        the CMYK color

    - #### toSRGBColor

          public static java.awt.Color toSRGBColor(java.awt.Color col)

      Converts an arbitrary `Color` to a plain sRGB color doing the conversion at the best possible conversion quality.
      Parameters:
        `col` - the original color
      Returns:
        the sRGB equivalent

    - #### isSameColor

          public static boolean isSameColor(java.awt.Color col1,
                            java.awt.Color col2)

      Checks if two colors are the same color. This check is much more restrictive than `Color.equals(Object)` in that it doesn't only check if both colors result in the same sRGB value. For example, if two colors not of the same exact class are compared, they are treated as not the same.

      Note: At the moment, this method only supports `Color` and `ColorWithAlternatives` only. Other subclasses of `Color` are checked only using the `Color.equals(Object)` method.

      Parameters:
        `col1` - the first color
        `col2` - the second color
      Returns:
        true if both colors are the same color