public class ColorMgr extends Object
getColorBg()
and getColor(int)
methods.
When the class is first loaded, the background color is set to white
and all the stroke colors to black
.
Then, they are set using the "colorBackground", "color" and "colorX"
parameters (X from 1 to 5) from the ConfigMgr
class from
andyLib. In this way a color is always available and the default one
can be set using the configuration.
In all the methods, color codes can be specified both as a RRGGBB
or a #RRGGBB
string.
Modifier and Type | Field and Description |
---|---|
private static Color |
_colorBg
Color of the background.
|
private static Color[] |
_colorStrokes
Color of the strokes.
|
Modifier | Constructor and Description |
---|---|
private |
ColorMgr() |
Modifier and Type | Method and Description |
---|---|
static Color |
getColor(int strokeWidth)
Returns the color for a stroke.
|
static Color |
getColorBg()
Returns the color for the background.
|
private static String |
normalizeColorCode(String s)
Normalize the color code.
|
static void |
setBgColor(Color color)
Sets the colors for the background.
|
static void |
setBgColor(String colorCode)
Safely sets the colors for the background.
|
static void |
setColor(Color color)
Sets all the colors.
|
static void |
setColor(int strokeWidth,
Color color)
Sets the color for a stroke.
|
static void |
setColor(int strokeWidth,
String colorCode)
Safely sets the color for a stroke.
|
static void |
setColor(String colorCode)
Safely sets all the colors.
|
private static Color _colorBg
private static final Color[] _colorStrokes
public static void setBgColor(String colorCode)
colorCode
- numeric code of the colorpublic static void setBgColor(Color color)
color==null
, this method does nothing.color
- the colorpublic static void setColor(String colorCode)
colorCode
does not correspond to a valid color code, this
method does nothing.colorCode
- numeric code of the colorpublic static void setColor(Color color)
color==null
, this method does nothing.color
- numeric code of the colorpublic static void setColor(int strokeWidth, String colorCode)
colorCode
does not correspond to a valid color code, this
method does nothing.strokeWidth
- width of the stroke to setcolorCode
- numeric code of the colorpublic static void setColor(int strokeWidth, Color color)
color==null
, this method does nothing.strokeWidth
- width of the stroke to setcolor
- numeric code of the colorpublic static Color getColorBg()
public static Color getColor(int strokeWidth)
strokeWidth
- width of the stroke to retriveprivate static String normalizeColorCode(String s)
s
if it
does not begin with '#'.s
- a string color codeColor.decode(String)
© 2013 andynaz - http://andynaz.altervista.org