org.tigris.gef.util
Class ColorUtility

java.lang.Object
  extended by org.tigris.gef.util.ColorUtility

public class ColorUtility
extends java.lang.Object

A flyweight factory class used to get color instances. This only creates new instances of a Color if required. Previous instances are cached.

Since:
0.11.1 10-May-2005
Author:
Bob Tarling

Method Summary
static java.awt.Color getColor(java.lang.String colorDescr)
          A flyweight factory method for reusing the same Color value multiple times.
static java.awt.Color getColor(java.lang.String colorDescr, java.awt.Color defaultColor)
          A flyweight factory method for reusing the same Color value multiple times.
static java.lang.String getColorName(java.awt.Color color)
          Get a color name for a color or null if this is some custom color.
static java.lang.String getPgmlColor(java.awt.Color color)
          Get the PGML description of a color.
static java.lang.String getSvgColor(java.awt.Color color)
          Get the SVG description of a color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getColor

public static java.awt.Color getColor(java.lang.String colorDescr,
                                      java.awt.Color defaultColor)
A flyweight factory method for reusing the same Color value multiple times.

Parameters:
colorDescr - A string of RGB values seperated by space or a color name recognised by PGML (later to include SVG)
defaultColor - a color to return if the color description can't be interpretted.
Returns:
the equivilent Color

getColor

public static java.awt.Color getColor(java.lang.String colorDescr)
A flyweight factory method for reusing the same Color value multiple times.

Parameters:
colorDescr - A string of RGB values seperated by space or a color name recognised by PGML (later to include SVG)
Returns:
the equivilent Color

getColorName

public static java.lang.String getColorName(java.awt.Color color)
Get a color name for a color or null if this is some custom color.

Parameters:
color -
Returns:
the color name or null.

getPgmlColor

public static java.lang.String getPgmlColor(java.awt.Color color)
Get the PGML description of a color. If possible this is a text description otherwise it is in red green blue integer format seperated by spaces.

Parameters:
color - The color to convert to PGML style
Returns:
a string representing the color in pgml format

getSvgColor

public static java.lang.String getSvgColor(java.awt.Color color)
Get the SVG description of a color. If possible this is a text description otherwise it is in hexadecimal red green blue format of either #rrggbb or #rgb.

Parameters:
color - The color to convert to SVG style
Returns:
a string representing the color in SVG format