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