Package generic.theme

# Class GIcon

java.lang.Object
generic.theme.GIcon

All Implemented Interfaces:
  `Icon`

Direct Known Subclasses:
  `GIconUIResource`

public class GIcon extends Object implements Icon
An `Icon` whose value is dynamically determined by looking up its id into a global icon table that is determined by the active `GTheme`.

The idea is for developers to not use specific icons in their code, but to instead use a GIcon with an id that hints at its use. For example, instead of hard coding a label's icon by coding "label.setIcon(ResourceManager.loadImage("images/refresh.png", you would do something like label.setIcon(new GIcon("icon.refresh"). 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 "icon.refresh = images/refresh.png".

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GIcon(String id)`
  Construct a GIcon with an id that will be used to look up the current icon associated with that id, which can be changed at runtime.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `Icon`
  `getDelegate()`
  Returns the current delegate for this GIcon.
  `int`
  `getIconHeight()`
  `int`
  `getIconWidth()`
  `String`
  `getId()`
  Returns the id for this GIcon.
  `ImageIcon`
  `getImageIcon()`
  Returns the image for this icon.
  `URL`
  `getUrl()`
  Returns the url used to load the icon delegate of this class.
  `int`
  `hashCode()`
  `void`
  `paintIcon(Component c, Graphics g, int x, int y)`
  `void`
  `refresh(GThemeValueMap currentValues)`
  Reloads the delegate.
  `static void`
  `refreshAll(GThemeValueMap currentValues)`
  Static method for notifying all the existing GIcon that icons have changed and they should reload their cached indirect icon.
  `String`
  `toString()`

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

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

- ## Constructor Details

  - ### GIcon

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

- ## Method Details

  - ### refreshAll

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

  - ### getId

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

  - ### getUrl

    public URL getUrl()
    Returns the url used to load the icon delegate of this class. If the delegate icon was not loaded from a url, then null will be returned.
    Returns:
      the icon or null

  - ### getImageIcon

    public ImageIcon getImageIcon()
    Returns the image for this icon.
    Returns:
      the image

  - ### paintIcon

    public void paintIcon(Component c, Graphics g, int x, int y)
    Specified by:
      `paintIcon` in interface `Icon`

  - ### getIconWidth

    public int getIconWidth()
    Specified by:
      `getIconWidth` in interface `Icon`

  - ### getIconHeight

    public int getIconHeight()
    Specified by:
      `getIconHeight` in interface `Icon`

  - ### refresh

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

  - ### getDelegate

    public Icon getDelegate()
    Returns the current delegate for this GIcon. Note that this delegate can change when the theme changes or is edited.
    Returns:
      the current delegate icon for this GIcon.

  - ### hashCode

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

  - ### equals

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

  - ### toString

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