public final class ColorHelper extends Object
Modifier | Constructor and Description |
---|---|
private |
ColorHelper() |
Modifier and Type | Method and Description |
---|---|
static String |
color2html(Color col)
Returns the HTML color code (6 or 8 digit).
|
static String |
color2html(Color col,
boolean withAlpha)
Returns the HTML color code (6 or 8 digit).
|
static Color |
getForegroundColor(Color bg)
Determines the correct foreground color (black or white) to use for the given background,
so the text will be readable.
|
static Color |
html2color(String html)
Returns the
Color for the given HTML code. |
private static String |
int2hex(int i) |
private ColorHelper()
public static Color html2color(String html)
Color
for the given HTML code.html
- the color codepublic static String color2html(Color col)
col
- The color to convertpublic static String color2html(Color col, boolean withAlpha)
col
- The color to convertwithAlpha
- if true
and alpha value < 255, return 8-digit color code, else always 6-digitpublic static Color getForegroundColor(Color bg)
bg
- background colorColor#BLACK
or Color#WHITE