org.moyoman.client.reference.util
Class GUISupport

java.lang.Object
  |
  +--org.moyoman.client.reference.util.GUISupport
All Implemented Interfaces:
IGUIConstants

public final class GUISupport
extends Object
implements IGUIConstants

Provides support for color, font, integer, and icon properties. The values of various properties are stored in "config/display.properties", and retrieved by supplying the appropriate key string.

Colors are specified as RGB triples (e.g. COLOR_BOARD=200, 150, 50).
Fonts are specified as family, style, size triples (e.g. FONT_BOARD=Helvetica,plain,12). Valid values for style are plain, bold, italic, and bold_italic.
Icons are specified as the filepath (e.g. ICON_ABOUT=/org/moyoman/client/reference/icons/About24.gif).

Since:
v0.02
Version:
v0.15
Author:
Jeffrey M. Thompson

Field Summary
private static Properties _displayProperties
          Properties.
private static int BOLD_ITALIC_INT
           
private static String BOLD_ITALIC_STRING
           
private static String BOLD_STRING
           
private static String GUI_PROPERTIES_FILEPATH
          Display properties filepath.
private static String ITALIC_STRING
           
private static String PLAIN_STRING
           
 
Fields inherited from interface org.moyoman.client.reference.util.IGUIConstants
DEBUG, DIRTY_PROPERTY, GAP, MARGIN, TRANSPARENT_COLOR
 
Constructor Summary
private GUISupport()
          Private constructor to disallow direct instantiation.
 
Method Summary
private static Color colorFromString(String colorDesc)
          Return a Color object described by the given String.
private static int convertStyleFromString(String styleDesc)
          Return a string representing the given style integer.
private static Font fontFromString(String fontDesc)
          Return a Font object described by the given String.
static Color getColor(String key)
          Return the color specified by the given key.
static Font getFont(String key)
          Return the font specified by the given key.
static Icon getIcon(String key)
          Return the icon specified by the given key.
static int getInt(String key)
          Return the integer specified by the given key.
private static int getIntFromString(String string)
          Return an integer from the given string.
static String getString(String key)
          Return the string specified by the given key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLAIN_STRING

private static final String PLAIN_STRING
See Also:
Constant Field Values

BOLD_STRING

private static final String BOLD_STRING
See Also:
Constant Field Values

ITALIC_STRING

private static final String ITALIC_STRING
See Also:
Constant Field Values

BOLD_ITALIC_STRING

private static final String BOLD_ITALIC_STRING
See Also:
Constant Field Values

BOLD_ITALIC_INT

private static final int BOLD_ITALIC_INT
See Also:
Constant Field Values

GUI_PROPERTIES_FILEPATH

private static final String GUI_PROPERTIES_FILEPATH
Display properties filepath.

See Also:
Constant Field Values

_displayProperties

private static Properties _displayProperties
Properties.

Constructor Detail

GUISupport

private GUISupport()
Private constructor to disallow direct instantiation.

Since:
v0.02
Method Detail

getColor

public static Color getColor(String key)
Return the color specified by the given key.

Parameters:
key - Key which identifies the desired resource.
Since:
v0.02

getFont

public static Font getFont(String key)
Return the font specified by the given key.

Parameters:
key - Key which identifies the desired resource.
Since:
v0.02

getIcon

public static Icon getIcon(String key)
Return the icon specified by the given key.

Since:
v0.02

getInt

public static int getInt(String key)
Return the integer specified by the given key.

Parameters:
key - Key which identifies the desired resource.
Returns:
the integer, or Integer.MIN_VALUE if not found.
Since:
v0.13

getString

public static String getString(String key)
Return the string specified by the given key.

Parameters:
key - Key which identifies the desired resource.
Returns:
the string, or null if not found.
Since:
v0.15

getIntFromString

private static int getIntFromString(String string)
Return an integer from the given string.

Parameters:
string - The String to parse.
Throws:
IllegalArgumentException - if string is null.
NumberFormatException - if the string does not contain a parsable integer.
Since:
v0.02

colorFromString

private static Color colorFromString(String colorDesc)
Return a Color object described by the given String. The method calls convertFromString( convertToString( color ) ) return the original color.

Parameters:
colorDesc - A String description of a color.
Throws:
IllegalArgumentException - if colorDesc is null.
NumberFormatException - if the description is improperly formatted.
Since:
v0.02

convertStyleFromString

private static int convertStyleFromString(String styleDesc)
Return a string representing the given style integer.

Parameters:
styleDesc - The style descriptor of interest.
Throws:
IllegalArgumentException - if styleDesc is null.
Since:
v0.02

fontFromString

private static Font fontFromString(String fontDesc)
Return a Font object described by the given String. The method calls convertFromString( convertToString( font ) ) return the original font.

Parameters:
fontDesc - A String description of a font.
Throws:
IllegalArgumentException - if fontDesc is null.
NumberFormatException - if the description is improperly formatted.
Since:
v0.02