att.grappa
Class GrappaColor

java.lang.Object
  extended by att.grappa.GrappaColor

public abstract class GrappaColor
extends java.lang.Object

This abstract class sets up and provides name-to-color and color-to-name mappings and some associated class methods.

Version:
1.2, 21 Aug 2005; Copyright 1996 - 2005 by AT&T Corp.
Author:
John Mocenigo, Research @ AT&T Labs

Field Summary
private static java.util.Hashtable colorLookUp
           
private static java.util.Hashtable colorTable
           
static java.awt.Color defaultBackground
          The default background color (white).
static java.awt.Color defaultColor
          The default color of last resort in all cases (black).
static java.awt.Color defaultFontcolor
          The default font color (black).
static java.awt.Color defaultForeground
          The default foreground color (black).
static java.awt.Color defaultXOR
          The default XOR color (light gray).
 
Constructor Summary
GrappaColor()
           
 
Method Summary
static void addColor(java.lang.String name, java.awt.Color color)
          Adds a color to the application color table.
private static java.lang.String canonColor(java.lang.String name, float[] hsb)
           
private static void doAddColor(java.lang.String name, java.awt.Color color)
           
private static void doAddColor(java.lang.String name, java.awt.Color color, boolean override)
           
static java.awt.Color getColor(java.lang.String name, java.awt.Color color)
          Return the color in the color table with the given name.
static java.lang.String getColorName(java.awt.Color color)
          Return the name of the supplied color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colorTable

private static java.util.Hashtable colorTable

colorLookUp

private static java.util.Hashtable colorLookUp

defaultForeground

public static final java.awt.Color defaultForeground
The default foreground color (black).


defaultBackground

public static final java.awt.Color defaultBackground
The default background color (white).


defaultXOR

public static final java.awt.Color defaultXOR
The default XOR color (light gray).


defaultFontcolor

public static final java.awt.Color defaultFontcolor
The default font color (black).


defaultColor

public static final java.awt.Color defaultColor
The default color of last resort in all cases (black).

Constructor Detail

GrappaColor

public GrappaColor()
Method Detail

addColor

public static void addColor(java.lang.String name,
                            java.awt.Color color)
                     throws java.lang.IllegalArgumentException
Adds a color to the application color table. For search purposes, names are canonicalized by converting to lower case and stripping non-alphanumerics. A name must contains at least one alphabetic. Once in the table, colors can be set by name, and names can be retrieved by color (although a single color referred to by multiple names only causes the retrieval of the last name mapped to that color).

Parameters:
name - the name to be used to reference the color.
color - the Color value.
Throws:
java.lang.IllegalArgumentException

doAddColor

private static void doAddColor(java.lang.String name,
                               java.awt.Color color,
                               boolean override)

doAddColor

private static void doAddColor(java.lang.String name,
                               java.awt.Color color)

canonColor

private static java.lang.String canonColor(java.lang.String name,
                                           float[] hsb)

getColor

public static java.awt.Color getColor(java.lang.String name,
                                      java.awt.Color color)
Return the color in the color table with the given name. If the color is not found, the supplied default is returned. If the supplied default is null, the class default is returned. If the name consists of three comma or space separated floating point numbers in the range 0 to 1 inclusive, then it is assumed to represent an HSB color specification and generated directly. The name search is case insensitive and looks at alphanumerics only.

Parameters:
name - the name of the color to be retrieved.
color - the color value to return if requested color is not found.
Returns:
the color matching the name or the default.

getColorName

public static java.lang.String getColorName(java.awt.Color color)
Return the name of the supplied color.

Parameters:
color - the color whose name is to be retrieved.
Returns:
the color's (most recently entered) name, if it is in the color table, or its HSB value string otherwise.