org.embl.ebi.escience.scuflui.shared
Class GraphColours

java.lang.Object
  extended by org.embl.ebi.escience.scuflui.shared.GraphColours

public abstract class GraphColours
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, 12 Jun 2001; Copyright 1996 - 2001 by AT&T Corp.
Author:
John Mocenigo , Research @ AT&T Labs

Field Summary
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
GraphColours()
           
 
Method Summary
static void addColor(java.lang.String name, java.awt.Color color)
          Adds a color to the application color table.
static java.lang.String getColorName(java.awt.Color color)
          Return the name of the supplied color.
static java.awt.Color getColour(java.lang.String name, java.awt.Color def)
          Return the color in the color table with the given name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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

GraphColours

public GraphColours()
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

getColour

public static java.awt.Color getColour(java.lang.String name,
                                       java.awt.Color def)
Return the color in the color table with the given name. If the name is parseable as a numeric color, use that Otherwise, If the color is not found, the supplied default is returned. If the supplied default is null, the class default is returned. The name search is case insensitive and looks at alphanumerics only.

Parameters:
name - the name of the color to be retrieved.
def - 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.