Class ColorHelper
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.components.ColorHelper
-
public final class ColorHelper extends Object
A helper class for dealing with colors.
This class defines helper methods for converting color values specified in form builder Jelly scripts. In this model colors can be defined in the following different ways:
- Using a symbolic name. For this purpose this class defines constants
that roughly correspond to the colors defined by the
java.awt.Color
class. - As a hexadecimal numeric value. In this case the color definition must
start with a "#" sign, e.g.
#80FF80
. This is analogous to color definitions in HTML. - As triple of decimal rgb values. Definitions of this type look like
(r, g, b)
, with r, g, b in the range from 0 to 255. - Logic color definitions. These are arbitrary strings which are not
further interpreted, e.g. style sheet names. To be recognized, such a string
must start with a "~" character, e.g.
~MyStyle
.
- Version:
- $Id: ColorHelper.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
- Using a symbolic name. For this purpose this class defines constants
that roughly correspond to the colors defined by the
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ColorHelper.NamedColor
An enumeration with predefined color constants.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Color
getPredefinedColor(String name)
Returns the predefined color with the given name.static Iterator<String>
getPredefinedNames()
Returns an iterator with the names (Strings) of all predefined colors.static Color
resolveColor(String c)
The main method for resolving a color definition.
-
-
-
Method Detail
-
getPredefinedColor
public static Color getPredefinedColor(String name) throws FormBuilderException
Returns the predefined color with the given name. The passed in name must be one of the names returned by thegetPredefinedNames()
method (case does not matter).- Parameters:
name
- the name of the desired color- Returns:
- the color
- Throws:
FormBuilderException
- if this color does not exist
-
getPredefinedNames
public static Iterator<String> getPredefinedNames()
Returns an iterator with the names (Strings) of all predefined colors. These names can be passed to thegetPredefinedColor()
method.- Returns:
- the names of the predefined colors
-
resolveColor
public static Color resolveColor(String c) throws FormBuilderException
The main method for resolving a color definition. This method can be given a color definition in one of the supported flavors. It will try to resolve this definition and return the correspondingColor
object. If this fails, an exception will be thrown.- Parameters:
c
- the color definition- Returns:
- the corresponding color object or null if the passed in color definition was null
- Throws:
FormBuilderException
- if the color definition cannot be resolved
-
-