public final class ColorHelper extends java.lang.Object
| Modifier | Constructor and Description |
|---|---|
private |
ColorHelper() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
color2html(java.awt.Color col)
Returns the HTML color code (6 or 8 digit).
|
static java.lang.String |
color2html(java.awt.Color col,
boolean withAlpha)
Returns the HTML color code (6 or 8 digit).
|
static java.awt.Color |
getForegroundColor(java.awt.Color bg)
Determines the correct foreground color (black or white) to use for the given background,
so the text will be readable.
|
static java.awt.Color |
html2color(java.lang.String html)
Returns the
Color for the given HTML code. |
private static java.lang.String |
int2hex(int i) |
private ColorHelper()
public static java.awt.Color html2color(java.lang.String html)
Color for the given HTML code.html - the color codeprivate static java.lang.String int2hex(int i)
public static java.lang.String color2html(java.awt.Color col)
col - The color to convertpublic static java.lang.String color2html(java.awt.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 java.awt.Color getForegroundColor(java.awt.Color bg)
bg - background colorColor#BLACK or Color#WHITE