kiwi.text
Class ColorFormatter

java.lang.Object
  |
  +--kiwi.text.ColorFormatter

public class ColorFormatter
extends Object

This class provides methods for converting colors to and from string representations. Known colors (those defined as constants in the Color class) are converted directly to or from symbolic names such as "green" or "magenta". Other colors are converted to or from RGB specifications in the format #RRGGBB - a '#' followed by 6 hexadecimal digits.

Version:
1.0 (11/98)
Author:
Mark Lindner, PING Software Group
See Also:
Color

Method Summary
static Color colorForName(String name)
          Get a color for a name.
static String format(Color color)
          Format a color as a string.
static String nameForColor(Color c)
          Get a name for a color.
static Color parse(String name)
          Parse a color representation, returning an appropriate Color object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

nameForColor

public static String nameForColor(Color c)
Get a name for a color. Returns a name for the color, if the color is one of the colors predefined in the Color class: black, blue, cyan, gray, green, magenta, orange, pink, red, white, or yellow.
Parameters:
c - The color.
Returns:
The name of the color, or null if c is not one of the colors listed above.
See Also:
nameForColor(java.awt.Color)

colorForName

public static Color colorForName(String name)
Get a color for a name. Returns a color for a color name, if the name identifies one of the colors predefined in the Color class.
Parameters:
name - The name of the color.
Returns:
The Color object for the given name, or null if name does not identify one of the colors listed above.
See Also:
colorForName(java.lang.String)

format

public static String format(Color color)
Format a color as a string. Returns a string representation of the given color as either a symbolic name (if the color is one of the colors predefined in the Color class), or a hex representation of the color in the format #RRGGBB.
Parameters:
color - The Color to parse.
Returns:
A string representation of the color.
See Also:
parse(java.lang.String)

parse

public static Color parse(String name)
                   throws ParsingException
Parse a color representation, returning an appropriate Color object.
Parameters:
name - The name of the color; one of the strings black, blue, cyan, gray, green, magenta, orange, pink, red, white, yellow, or an RGB color specification of the form #RRGGBB.
Returns:
An appropriate Color object.
Throws:
ParsingException - If name is an invalid color representation.
See Also:
format(java.awt.Color)