public class ColorToolkit
extends java.lang.Object
AWT colors
.Modifier and Type | Field and Description |
---|---|
private static float |
normalHashValue |
Modifier | Constructor and Description |
---|---|
private |
ColorToolkit() |
Modifier and Type | Method and Description |
---|---|
static java.awt.Color |
blend(java.awt.Color fg,
java.awt.Color bg) |
static java.awt.Color |
decode(java.lang.String hexColor)
Decode a string created by
encode(Color) and create a corresponding color instance. |
static java.lang.String |
encode(java.awt.Color color)
Encode a color as a hexadecimal string starting with '#'.
|
static java.awt.Color |
getDistinguishableColor(java.lang.Object o)
Generate a color based on an object.
|
private static java.awt.Color |
getGradientBottomColor(java.awt.Color topColor) |
private static int |
getGradientComponent(int c) |
static java.awt.GradientPaint |
getGradientPaint(java.awt.Color topColor,
int top)
Get a gradient paint based on a top color.
|
static java.awt.Color |
withAlpha(java.awt.Color color,
int alpha)
Create a color with a specified alpha value.
|
public static java.lang.String encode(java.awt.Color color)
decode(String)
.color
- color to encodepublic static java.awt.Color decode(java.lang.String hexColor) throws java.lang.NumberFormatException
encode(Color)
and create a corresponding color instance.hexColor
- hexadecimal string to decodejava.lang.NumberFormatException
- if the string can't be decodedpublic static java.awt.Color getDistinguishableColor(java.lang.Object o)
The algorithm for generating colors is arbitrary and may be changed.
o
- object to get a color forpublic static java.awt.GradientPaint getGradientPaint(java.awt.Color topColor, int top)
topColor
- color for the top of the gradienttop
- X coordinate for the top colortop
private static java.awt.Color getGradientBottomColor(java.awt.Color topColor)
private static int getGradientComponent(int c)
public static java.awt.Color withAlpha(java.awt.Color color, int alpha)
color
- base coloralpha
- alpha valuepublic static java.awt.Color blend(java.awt.Color fg, java.awt.Color bg)