public final class ColorUtil
extends java.lang.Object
This class supports parsing string values into color values and creating color values for strings. It provides a list of standard color names.
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. |
public static java.awt.Color lightenColor(java.awt.Color col, float factor)
col
- the color to lighten upfactor
- factor by which to lighten up (negative values darken the color)public static boolean isGray(java.awt.Color col)
col
- the colorpublic static java.awt.Color toCMYKGrayColor(float black)
black
- the gray component (0 - 1)public static java.awt.Color toSRGBColor(java.awt.Color col)
Color
to a plain sRGB color doing the conversion at the
best possible conversion quality.col
- the original colorpublic static boolean isSameColor(java.awt.Color col1, java.awt.Color col2)
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.
col1
- the first colorcol2
- the second colorCopyright 1999-2012 The Apache Software Foundation. All Rights Reserved.