Package rma.text

Class ColorFormatter

java.lang.Object
rma.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.
See Also:
  • Field Details

    • colorNames

      public static final String[] colorNames
    • colors

      public static final Color[] colors
  • Method Details

    • 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:
    • 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:
    • 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

      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:
      kiwi.text.ParsingException - If name is an invalid color representation.
      ParsingException
      See Also: