Class ColorUtil
java.lang.Object
org.apache.xmlgraphics.java2d.color.ColorUtil
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.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor since this is an utility class. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanIndicates whether the color is a gray value.static booleanisSameColor(Color col1, Color col2) Checks if two colors are the same color.static ColorlightenColor(Color col, float factor) Lightens up a color for groove, ridge, inset and outset border effects.static ColortoCMYKGrayColor(float black) Creates an uncalibrated CMYK color with the given gray value.static ColortoSRGBColor(Color col) Converts an arbitraryColorto a plain sRGB color doing the conversion at the best possible conversion quality.
-
Constructor Details
-
ColorUtil
private ColorUtil()Private constructor since this is an utility class.
-
-
Method Details
-
lightenColor
-
isGray
Indicates whether the color is a gray value.- Parameters:
col- the color- Returns:
- true if it is a gray value
-
toCMYKGrayColor
Creates an uncalibrated CMYK color with the given gray value.- Parameters:
black- the gray component (0 - 1)- Returns:
- the CMYK color
-
toSRGBColor
-
isSameColor
Checks if two colors are the same color. This check is much more restrictive thanColor.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
ColorandColorWithAlternativesonly. Other subclasses ofColorare checked only using theColor.equals(Object)method.- Parameters:
col1- the first colorcol2- the second color- Returns:
- true if both colors are the same color
-