|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tbee.swing.ColorUtil
public class ColorUtil
Some Color Utils methods a.o. convert a HTML Color string to Color and vice versa.
| Constructor Summary | |
|---|---|
ColorUtil()
|
|
| Method Summary | |
|---|---|
static Color |
alterAlpha(Color color,
float alpha)
Make a new version of the color but change the alpha component |
static Color |
alterAlpha(Color color,
int alpha)
Make a new version of the color but change the alpha component |
static Color |
alterTransparency(Color color,
int alpha)
Return the same color but with an altered transparency |
static Color |
blend(Color color1,
Color color2)
Make an even blend between two colors. |
static Color |
blend(Color color1,
Color color2,
double ratio)
Blend two colors. |
static Color |
brighter(Color color,
double percentage)
Creates a new Color that is a brighter version of this
Color. |
static Color |
brighterOrDarker(Color color,
double percentage)
Make a darker color brighter and vice versa |
static Color |
change(Color color,
double factor)
Creates a new Color that is a scalar version of this Color. |
static double |
colorDistance(Color color1,
Color color2)
Return the "distance" between two colors. |
static double |
colorDistance(double[] color1,
double[] color2)
Return the "distance" between two colors. |
static double |
colorDistance(double r1,
double g1,
double b1,
double r2,
double g2,
double b2)
Return the "distance" between two colors. |
static Color |
darker(Color color,
double percentage)
Creates a new Color that is a darker version of this
Color. |
static Color |
getAlternatingColor(Color color)
Determine an alternating color for e.g. |
static String |
getHexName(Color color)
Return the hex name of a specified color. |
static Color |
getOppositeColor(Color color)
Determine the opposite color but with the same alpha. |
static boolean |
isDark(Color color)
Check if a color is more dark than light. |
static boolean |
isDark(double r,
double g,
double b)
Check if a color is more dark than light. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ColorUtil()
| Method Detail |
|---|
public static Color change(Color color,
double factor)
Color that is a scalar version of this Color.
public static Color brighter(Color color,
double percentage)
Color that is a brighter version of this
Color.
This method applies an arbitrary scale factor to each of the three RGB
components of this Color to create a brighter version
of this Color. Although brighter and
darker are inverse operations, the results of a
series of invocations of these two methods might be inconsistent
because of rounding errors.
Color object that is a brighter version of this Color.Color.brighter()
public static Color darker(Color color,
double percentage)
Color that is a darker version of this
Color.
This method applies an arbitrary scale factor to each of the three RGB
components of this Color to create a darker version of
this Color. Although brighter and
darker are inverse operations, the results of a series of
invocations of these two methods might be inconsistent because of
rounding errors.
Color object that is a darker version of
this Color.Color.darker()
public static Color brighterOrDarker(Color color,
double percentage)
color - percentage -
public static Color blend(Color color1,
Color color2,
double ratio)
color1 - First color to blend.color2 - Second color to blend.ratio - Blend ratio. 0.5 will give even blend, 1.0 will return
color1, 0.0 will return color2 and so on.
public static Color blend(Color color1,
Color color2)
c1 - First color to blend.c2 - Second color to blend.
public static String getHexName(Color color)
color - Color to get hex name of.
public static double colorDistance(double r1,
double g1,
double b1,
double r2,
double g2,
double b2)
r1, - g1, b1 First color.r2, - g2, b2 Second color.
public static double colorDistance(double[] color1,
double[] color2)
color1 - First color [r,g,b].color2 - Second color [r,g,b].
public static double colorDistance(Color color1,
Color color2)
color1 - First color.color2 - Second color.
public static boolean isDark(double r,
double g,
double b)
r,g,b - Color to check.
public static boolean isDark(Color color)
color - Color to check.
public static Color getAlternatingColor(Color color)
color -
public static Color alterAlpha(Color color,
int alpha)
color - alpha -
public static Color alterAlpha(Color color,
float alpha)
color - alpha -
public static Color getOppositeColor(Color color)
color -
public static Color alterTransparency(Color color,
int alpha)
color -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||