|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.freehep.swing.ColorConverter
public class ColorConverter
A utility class for converting strings to color's.
Nested Class Summary | |
---|---|
static class |
ColorConverter.ColorConversionException
An exception thrown if a given string cannot be converted to a Color |
Constructor Summary | |
---|---|
ColorConverter()
Creates an instance of ColorConverter with the default color conversions |
Method Summary | |
---|---|
void |
addEntry(Color c,
String name)
Add an entry to the color converter map |
void |
clear()
Clear all the mappings from the color converter |
String[] |
colorNames()
Returns array of all Color names that are added, each name is unique |
String |
colorToString(Color color)
Convert the given color to a string. |
protected Color |
createColor(float red,
float green,
float blue,
float alpha)
Return a color for the given values. |
protected Color |
createColor(int red,
int green,
int blue,
int alpha)
Return a color for the given values. |
static String |
get(Color color)
Convert a color to a string, using the default ColorConverter |
static Color |
get(String name)
Converts a string to a color, using the default ColorConverter |
static JColorChooser |
getColorChooser()
Creates new JColorChooser with extra panel that allows to choose Color by name |
static String[] |
getNames()
Returns array of all Color names that are added, each name is unique |
Color |
stringToColor(String name)
this method returns a Color. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ColorConverter()
Method Detail |
---|
public static JColorChooser getColorChooser()
public static String get(Color color)
color
- The color to convert
public static Color get(String name) throws ColorConverter.ColorConversionException
name
- The string to convert
ColorConverter.ColorConversionException
- Thrown if the given string cannot be converted to a colorpublic static String[] getNames()
public String[] colorNames()
public void addEntry(Color c, String name)
c
- The color to addname
- The name corresponding to the colorpublic void clear()
public String colorToString(Color color)
color
- The color to be converted
public Color stringToColor(String name) throws ColorConverter.ColorConversionException
by name: "yellow" , where alpha is always 1.0 by int r,g,b,a: "128, 255, 64, 255" , where alpha (a) is optional by float r,g,b,a: "0.5, 1.0, 0.25, 1.0" , where alpha (a) is optional by single number: "64637" or "0x0FFF08" , where alpha is always 1.0
name
- name/number of the color
ColorConverter.ColorConversionException
- Thrown if the given string cannot be converted to a colorprotected Color createColor(int red, int green, int blue, int alpha)
protected Color createColor(float red, float green, float blue, float alpha)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |