Package generic.theme

# Class GColor

java.lang.Object
java.awt.Color
generic.theme.GColor

All Implemented Interfaces:
  `Paint`, `Transparency`, `Serializable`

Direct Known Subclasses:
  `GColorUIResource`

public class GColor extends Color
A `Color` whose value is dynamically determined by looking up its id into a global color table that is determined by the active `GTheme`.

The idea is for developers to not use specific colors in their code, but to instead use a GColor with an id that hints at its use. For example, instead of hard coding a component's background color to white by coding "component.setBackground(Color.white)", you would do something like "component.setBackground(new GColor("color.mywidget.bg"). Then in a "[module name].theme.properties" file (located in the module's data directory), you would set the default value by adding this line "color.mywidget.bg = white".

See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class java.awt.Color

  `black, BLACK, blue, BLUE, cyan, CYAN, DARK_GRAY, darkGray, gray, GRAY, green, GREEN, LIGHT_GRAY, lightGray, magenta, MAGENTA, orange, ORANGE, pink, PINK, red, RED, white, WHITE, yellow, YELLOW`

  ### Fields inherited from interface java.awt.Transparency

  `BITMASK, OPAQUE, TRANSLUCENT`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `GColor(GColor gColor)`
  Copy constructor.
  ``
  `GColor(String id)`
  Construct a GColor with an id that will be used to look up the current color associated with that id, which can be changed at runtime.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Color`
  `brighter()`
  `PaintContext`
  `createContext(ColorModel cm, Rectangle r, Rectangle2D r2d, AffineTransform xform, RenderingHints hints)`
  `Color`
  `darker()`
  `boolean`
  `equals(Object obj)`
  `int`
  `getAlpha()`
  `int`
  `getBlue()`
  `float[]`
  `getColorComponents(float[] compArray)`
  `float[]`
  `getColorComponents(ColorSpace cspace, float[] compArray)`
  `ColorSpace`
  `getColorSpace()`
  `float[]`
  `getComponents(float[] compArray)`
  `float[]`
  `getComponents(ColorSpace cspace, float[] compArray)`
  `int`
  `getGreen()`
  `String`
  `getId()`
  Returns the id for this GColor.
  `int`
  `getRed()`
  `int`
  `getRGB()`
  `float[]`
  `getRGBColorComponents(float[] compArray)`
  `float[]`
  `getRGBComponents(float[] compArray)`
  `int`
  `getTransparency()`
  `int`
  `hashCode()`
  `boolean`
  `isUnresolved()`
  Returns true if this GColor could not find a value for its color id in the current theme and is using the default color as its delegate
  `void`
  `refresh(GThemeValueMap currentValues)`
  Reloads the delegate.
  `static void`
  `refreshAll(GThemeValueMap currentValues)`
  Static method for notifying all the existing GColors that colors have changed and they should reload their cached indirect color.
  `String`
  `toDebugString()`
  Generates a more verbose toString()
  `String`
  `toHexString()`
  Returns this color as a hex string that starts with '#'
  `String`
  `toString()`
  `GColor`
  `withAlpha(int newAlpha)`
  Creates a transparent version of this GColor.

  ### Methods inherited from class java.awt.Color

  `decode, getColor, getColor, getColor, getHSBColor, HSBtoRGB, RGBtoHSB`

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

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

- ## Constructor Details

  - ### GColor

    public GColor(String id)
    Construct a GColor with an id that will be used to look up the current color associated with that id, which can be changed at runtime.
    Parameters:
      `id` - the id used to lookup the current value for this color

  - ### GColor

    protected GColor(GColor gColor)
    Copy constructor. Used primarily to convert a GColorUiResource to a GColor without having to lookup the color which can cause errors during theme transitions.
    Parameters:
      `gColor` - the gColor to copy

- ## Method Details

  - ### withAlpha

    public GColor withAlpha(int newAlpha)
    Creates a transparent version of this GColor. If the underlying value of this GColor changes, the transparent version will also change.
    Parameters:
      `newAlpha` - the transparency level for the new color
    Returns:
      a transparent version of this GColor

  - ### getId

    public String getId()
    Returns the id for this GColor.
    Returns:
      the id for this GColor.

  - ### getRed

    public int getRed()
    Overrides:
      `getRed` in class `Color`

  - ### getGreen

    public int getGreen()
    Overrides:
      `getGreen` in class `Color`

  - ### getBlue

    public int getBlue()
    Overrides:
      `getBlue` in class `Color`

  - ### getAlpha

    public int getAlpha()
    Overrides:
      `getAlpha` in class `Color`

  - ### getRGB

    public int getRGB()
    Overrides:
      `getRGB` in class `Color`

  - ### brighter

    public Color brighter()
    Overrides:
      `brighter` in class `Color`

  - ### darker

    public Color darker()
    Overrides:
      `darker` in class `Color`

  - ### isUnresolved

    public boolean isUnresolved()
    Returns true if this GColor could not find a value for its color id in the current theme and is using the default color as its delegate
    Returns:
      true if this GColor could not find a value for its color id in the current theme

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Color`

  - ### toHexString

    public String toHexString()
    Returns this color as a hex string that starts with '#'
    Returns:
      the hex string

  - ### toDebugString

    public String toDebugString()
    Generates a more verbose toString()
    Returns:
      a more verbose toString()

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Color`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Color`

  - ### getRGBComponents

    public float[] getRGBComponents(float[] compArray)
    Overrides:
      `getRGBComponents` in class `Color`

  - ### getRGBColorComponents

    public float[] getRGBColorComponents(float[] compArray)
    Overrides:
      `getRGBColorComponents` in class `Color`

  - ### getComponents

    public float[] getComponents(float[] compArray)
    Overrides:
      `getComponents` in class `Color`

  - ### getColorComponents

    public float[] getColorComponents(float[] compArray)
    Overrides:
      `getColorComponents` in class `Color`

  - ### getComponents

    public float[] getComponents(ColorSpace cspace, float[] compArray)
    Overrides:
      `getComponents` in class `Color`

  - ### getColorComponents

    public float[] getColorComponents(ColorSpace cspace, float[] compArray)
    Overrides:
      `getColorComponents` in class `Color`

  - ### getColorSpace

    public ColorSpace getColorSpace()
    Overrides:
      `getColorSpace` in class `Color`

  - ### createContext

    public PaintContext createContext(ColorModel cm, Rectangle r, Rectangle2D r2d, AffineTransform xform, RenderingHints hints)
    Specified by:
      `createContext` in interface `Paint`
    Overrides:
      `createContext` in class `Color`

  - ### getTransparency

    public int getTransparency()
    Specified by:
      `getTransparency` in interface `Transparency`
    Overrides:
      `getTransparency` in class `Color`

  - ### refresh

    public void refresh(GThemeValueMap currentValues)
    Reloads the delegate.
    Parameters:
      `currentValues` - the map of current theme values

  - ### refreshAll

    public static void refreshAll(GThemeValueMap currentValues)
    Static method for notifying all the existing GColors that colors have changed and they should reload their cached indirect color.
    Parameters:
      `currentValues` - the map of current theme values