|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectilog.views.util.IlvColorUtil
public class IlvColorUtil
The IlvColorUtil class consists of static methods
that are of general use when working with colors.
This class defines a color map that consists of keyword/color pairs.
These colors correspond to the predefined color names that are recognized by
the SVG specification; see
http://www.w3.org/TR/SVG/types.html#ColorKeywords.
The color names defined in SVG take over the ones in Java. For
instance, gray, green, and orange
are not the same in the two color spaces. It is possible to control this
behavior through the (@link javaNamesFirst #setJavaNamesFirst} method.
| Constructor Summary | |
|---|---|
protected |
IlvColorUtil()
Singleton class. |
| Method Summary | |
|---|---|
static void |
addColor(String name,
Color color)
Adds a new named color to the color map. |
static Color |
brighter(Color c)
Returns a brighter version of the specified color. |
static Color |
darker(Color c)
Returns a darker version of the specified color. |
static float |
getBrightness(Color c)
Returns the brightness of the specified color. |
static Color |
getColor(String colorName)
Returns a named color from the color map. |
static Map |
getColorMap()
Returns the color map. |
static float |
getHue(Color c)
Returns the hue of the specified color. |
static float |
getLuminance(Color color)
Returns the luminance of the specified color. |
static Color |
getRandomColor()
Creates a random color. |
static float |
getSaturation(Color c)
Returns the saturation of the specified color. |
static boolean |
isJavaNamesFirst()
Returns whether Java color names take over SVG color names. |
static Color |
setAlpha(Color c,
float alpha)
Returns a color with a modified alpha value. |
static Color |
setBrightness(Color c,
float brightness)
Returns a color with a modified brightness. |
static Color |
setHue(Color c,
float hue)
Returns a color with a modified hue. |
static void |
setJavaNamesFirst(boolean val)
Specifies whether Java colors take over the SVG color definition. |
static Color |
setSaturation(Color c,
float saturation)
Returns a color with a modified saturation. |
static Color |
slightlyBrighter(Color c)
Returns a slightly brighter version of the specified color. |
static Color |
slightlyDarker(Color c)
Returns a slightly darker version of the specified color. |
static Color |
toColor(String text)
Returns the color corresponding to the specified string. |
static String |
toHumanReadableString(Color c)
Returns a string representation of the specified color. |
static String |
toString(Color c)
Returns a string representation of the specified color. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected IlvColorUtil()
| Method Detail |
|---|
public static void addColor(String name,
Color color)
name - The name of the color.color - The color.public static Map getColorMap()
addColor(java.lang.String, java.awt.Color)public static void setJavaNamesFirst(boolean val)
val - The boolean specification.public static boolean isJavaNamesFirst()
setJavaNamesFirst(boolean)public static final Color getColor(String colorName)
colorName - The name of the color.
null if the name is not registered in the color map.public static Color getRandomColor()
public static Color setAlpha(Color c,
float alpha)
c - The original color.alpha - The new alpha value, in the range [0 .. 1].
public static float getBrightness(Color c)
Note: This function returns the maximum of the three components
(red, green, blue), as a floating-point value between 0 and 1. It
does not reflect the brightness at it appears to the human eye; for
this, see getLuminance(java.awt.Color).
c - The color.
public static Color setBrightness(Color c,
float brightness)
c - The original color.brightness - The new brightness value, in the range
[0 .. 1].
public static float getSaturation(Color c)
c - The color.
public static Color setSaturation(Color c,
float saturation)
c - The original color.saturation - The new saturation value, in the range
[0 .. 1].
public static float getHue(Color c)
c - The color.
public static Color setHue(Color c,
float hue)
c - The original color.hue - The new hue value, in the range [0 .. 1].
public static Color brighter(Color c)
c - The original color.
public static Color slightlyBrighter(Color c)
c - The original color.
public static Color darker(Color c)
c - The original color.
public static Color slightlyDarker(Color c)
c - The original color.
public static float getLuminance(Color color)
This function is suitable for color to grayscale conversion.
getBrightness(java.awt.Color)
public static Color toColor(String text)
throws IllegalArgumentException
The specified string can have the following forms:
getColorMap()).#aarrggbb or
#rrggbb.[0,255]):
r,g,b.
text - The string to parse.
IllegalArgumentException - The specified string cannot
be parsed.toString(java.awt.Color)public static String toHumanReadableString(Color c)
c - The considered color.
toColor(java.lang.String)public static String toString(Color c)
c - The considered color.
toColor(java.lang.String)
|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||