org.vishia.gral.ifc

## Class GralColor

- java.lang.Object
- - org.vishia.gral.ifc.GralColor

-     public class GralColor
      extends java.lang.Object

  This class defines a data structure to hold color values in a usual but system-independent form and defines some standard colors by name.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `private static class` | `GralColor.GralColorContainer`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `blue` Values 0..255 for the base colors.
    `java.lang.Object` | `colorGuimpl` The color-instance for the implementation can be set from the implementation with the necessary type to minimize the effort in dynamic instances.
    `private static GralColor.GralColorContainer` | `container`
    `int` | `green` Values 0..255 for the base colors.
    `java.lang.String` | `name` The unique short name for this color.
    `int` | `red` Values 0..255 for the base colors.
    `protected int` | `rgb` The rgb value, same value as red, green, blue.
    `protected java.lang.String` | `usualNames` String with one or more usual names for this color, especially HTML names, X11 names.
    `static java.lang.String` | `version` Version, history and license.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GralColor(int color)` Deprecated. only private using, because more as one instances for the same color is prevented then and the color have a correct name if the value matches to a existent color.
    `GralColor(int red, int green, int blue)` Deprecated. use `getColor(int, int, int)` because more as one instances for the same color is prevented then and the color have a correct name if the value matches to a existent color.
    `GralColor(java.lang.String name, int color)` Deprecated. only private using, because more as one instances for the same color is prevented then and the color have a correct name if the value matches to a existent color.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static GralColor` | `getColor(int value)`
    `static GralColor` | `getColor(int red, int green, int blue)`
    `static GralColor` | `getColor(java.lang.String name)` Gets a color by its name.
    `java.lang.String` | `getColorName()`
    `int` | `getColorValue()`
    `static GralColor` | `getStdColor(int color, int brightness)`
    `boolean` | `notUsed()` The color is not used till yet or it is changed.
    `int` | `rgb()`
    `java.lang.String` | `toString()`
    `java.lang.String` | `usualNames()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### version

          public static final java.lang.String version

      Version, history and license.
      - 2012-10-11 Hartmut new concepts from new ColorChooser with usualNames, starting.
      - 2012-09-07 Hartmut bugfix: toString: color with hexa value with leading 00 for example "0x00ff00".
      - 2012-06-09 Hartmut new: `getColor(String)` now accepts a "0xhexa-Value" for a color name. If the color name does not match, a magenta color is returned. The method returns a color in any case.
      - 2011-10-01 Hartmut new: color lbk light black darker than dark gray. Change values for gray.
      - 2011-09-08 Hartmut new: some enhancements, new colors.
      - 2011-09-04 Hartmut chg: Rename from ColorGui to GralColor
      - 2011-09-04 Hartmut chg: Move the `getColor(String)` and `getColor(int)` with the colorContainer from gridPanel/PropertiesGUI to this.
      - 2011-05-14 Hartmut new: Reference to the `colorGuimpl` to get the graphic base system color instance if need.
      - 2010-00-00 Hartmut created. It had contain only the 3 int red, green, blue
      Copyright/Copyleft:
      For this source the LGPL Lesser General Public License, published by the Free Software Foundation is valid. It means:
      1. You can use this source without any restriction for any desired purpose.
      2. You can redistribute copies of this source to everybody.
      3. Every user of this source, also the user of redistribute copies with or without payment, must accept this license for further using.
      4. But the LPGL is not appropriate for a whole software product, if this source is only a part of them. It means, the user must publish this part of source, but doesn't need to publish the whole source of the own product.
      5. You can study and modify (improve) this source for own using or for redistribution, but you have to license the modified sources likewise under this LGPL Lesser General Public License. You mustn't delete this Copyright/Copyleft inscription in this source file.
      If you intent to use this source without publishing its usage, you can get a second license subscribing a special contract with the author.
      See Also:
        Constant Field Values

    - #### red

          public int red

      Values 0..255 for the base colors. Note: don't change by any application, read only! Changes are overridden on any usage.

    - #### green

          public int green

      Values 0..255 for the base colors. Note: don't change by any application, read only! Changes are overridden on any usage.

    - #### blue

          public int blue

      Values 0..255 for the base colors. Note: don't change by any application, read only! Changes are overridden on any usage.

    - #### rgb

          protected int rgb

      The rgb value, same value as red, green, blue.

    - #### name

          public final java.lang.String name

      The unique short name for this color.

    - #### usualNames

          protected java.lang.String usualNames

      String with one or more usual names for this color, especially HTML names, X11 names. If more as one name is given, it is separated by comma.

    - #### colorGuimpl

          public java.lang.Object colorGuimpl

      The color-instance for the implementation can be set from the implementation with the necessary type to minimize the effort in dynamic instances.

    - #### container

          private static GralColor.GralColorContainer container

  - ### Constructor Detail

    - #### GralColor

          public GralColor(int red,
                           int green,
                           int blue)

      Deprecated. use `getColor(int, int, int)` because more as one instances for the same color is prevented then and the color have a correct name if the value matches to a existent color.
      Deprecated
      Parameters:
        `red` -
        `green` -
        `blue` -

    - #### GralColor

          public GralColor(int color)

      Deprecated. only private using, because more as one instances for the same color is prevented then and the color have a correct name if the value matches to a existent color.
      Parameters:
        `color` -

    - #### GralColor

          public GralColor(java.lang.String name,
                           int color)

      Deprecated. only private using, because more as one instances for the same color is prevented then and the color have a correct name if the value matches to a existent color.
      Deprecated, only private usage. Use
      Parameters:
        `color` -

  - ### Method Detail

    - #### getColorValue

          public int getColorValue()

    - #### rgb

          public int rgb()

    - #### usualNames

          public java.lang.String usualNames()

    - #### getColorName

          public java.lang.String getColorName()

    - #### notUsed

          public boolean notUsed()

      The color is not used till yet or it is changed.
      Returns:

    - #### getColor

          public static GralColor getColor(java.lang.String name)

      Gets a color by its name. The following named colors are available:
      Full name simple colors:
      - "white", 0xffffff);
      - "gray", 0x808080);
      - "black", 0x000000);
      - "red", 0xff0000);
      - "green", 0x00ff00);
      - "blue", 0x0000ff);
      - "yellow", 0xffff00);
      - "magenta",0xff00ff);
      - "cyan", 0x00ffff);
      - "brown", 0x600020);
      - "amber", 0xffe000);
      - "orange", 0xffa000);
      - "pink", 0xff0080);
      - "violet", 0x6000ff);
      - "purple", 0xff00ff);
      saturated colors: The same as full name colors. All colors are designated with 2 letters.
      - "wh", white, 0xffffff);
      - "gr", gray, 0xa0a0a0);
      - "bk", black, 0x000000);
      - "rd", red, 0xff0000);
      - "gn", green, 0x00e000);
      - "bl", blue, 0x0000ff);
      - "ye", yellow, 0xffff00);
      - "ma", magenta, 0xff00ff);
      - "cy", cyan, 0x00ffff);
      - "bn", brown, 0x600020);
      - "am", amber, 0xffe000);
      - "or", orange, 0xffa000);
      - "pk", orange, 0xff0080);
      - "vi", violet 0x6000ff);
      - "pu", purple, de: purpurfarben 0xff0060);
      light colors: The more light version is designated with a "l" before the 2-letter color name.
      - "lgr", 0xd0d0d0);
      - "lrd", 0xffb0b0);
      - "lgn", 0xa0ffa0);
      - "lbl", 0xa0a0ff);
      - "lye", 0xffff80);
      - "lma", 0xffc0ff);
      - "lcy", 0xa0ffff);
      - "lbk", 0x404040); a black which is lighter, but darker as dark gray
      pastel colors, especially for background color. They are designates with "p" before the 2-letter color name.
      - "pgr", 0xf0f0f0);
      - "prd", 0xffe0e0);
      - "pgn", 0xe0ffe0);
      - "pbl", 0xf0f0ff);
      - "pye", 0xffffc0);
      - "pma", 0xffe0ff);
      - "pcy", 0xd0ffff);
      dark colors for lines and fonts: They are designates with "p" before the 2-letter color name.
      - "dgr", 0x606060);
      - "drd", 0x800000);
      - "dbn", 0x400010);
      - "dgn", 0x008000);
      - "dbl", 0x000080);
      - "dye", 0x606000);
      - "dma", 0x600060);
      - "dcy", 0x006060);
      Additional a hexa value can be given in form "0xffffff" as name.
      Parameters:
        `name` - The name or 0xhexa
      Returns:
        The proper color from the color container. The color is not created as a new instance if it is contained in the container already. If the color name does not match, a magenta color is returned.

    - #### getStdColor

          public static GralColor getStdColor(int color,
                                              int brightness)

    - #### getColor

          public static GralColor getColor(int value)

    - #### getColor

          public static GralColor getColor(int red,
                                           int green,
                                           int blue)

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`