Package generic.theme

# Class GTheme

java.lang.Object
generic.theme.GThemeValueMap
generic.theme.GTheme

Direct Known Subclasses:
  `DiscoverableGTheme`

public class GTheme extends GThemeValueMap
Class to store all the configurable appearance properties (Colors, Fonts, Icons, Look and Feel) in an application.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static String`
  `FILE_EXTENSION`
  `static final String`
  `FILE_PREFIX`
  `static final String`
  `JAVA_ICON`
  `static String`
  `ZIP_FILE_EXTENSION`

  ### Fields inherited from class generic.theme.GThemeValueMap

  `colorMap, fontMap, iconMap, propertyMap`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GTheme(File file, String name, LafType lafType, boolean useDarkDefaults)`
  Constructor for creating a GTheme with an associated File.
  `GTheme(String name)`
  Creates a new GTheme with the given name, the default `LookAndFeel` for the the platform and not using dark defaults.
  `GTheme(String name, LafType lafType)`
  Creates a new empty GTheme with the given name, `LookAndFeel`, and whether or not to use dark defaults.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `File`
  `getFile()`
  Returns the file associated with this theme.
  `LafType`
  `getLookAndFeelType()`
  Returns the name of the LookAndFeel associated with this GTheme
  `String`
  `getName()`
  Returns the name of this GTheme
  `String`
  `getThemeLocater()`
  Returns a String that can be used to find and restore this theme.
  `int`
  `hashCode()`
  `boolean`
  `hasSupportedLookAndFeel()`
  Returns true if this theme has a `LookAndFeel` that is supported by the current platform.
  `boolean`
  `isReadOnly()`
  Returns true if this theme can not be changed
  `static GTheme`
  `loadTheme(File file)`
  Reads a theme from a file.
  `void`
  `save()`
  Saves this theme to its associated file.
  `void`
  `setColor(String id, Color color)`
  Sets the Color for the given id
  `void`
  `setColorRef(String id, String refId)`
  Sets a referred Color for the given id
  `void`
  `setFont(String id, Font font)`
  Sets the Font for the given id
  `void`
  `setFontRef(String id, String refId)`
  Sets a referred font for the given id
  `void`
  `setIcon(String id, Icon icon)`
  Sets the icon for the given id
  `void`
  `setIconRef(String id, String refId)`
  Sets a referred icon id for the given id
  `String`
  `toString()`
  `boolean`
  `useDarkDefaults()`
  Returns true if this theme should use dark defaults

  ### Methods inherited from class generic.theme.GThemeValueMap

  `addColor, addFont, addIcon, addProperty, checkForUnresolvedReferences, clear, containsColor, containsFont, containsIcon, containsProperty, getChangedValues, getColor, getColorIds, getColors, getExternalIconFiles, getFont, getFontIds, getFonts, getIcon, getIconIds, getIcons, getProperties, getProperty, getPropertyIds, getResolvedColor, getResolvedFont, getResolvedIcon, getResolvedProperty, isEmpty, load, removeColor, removeFont, removeIcon, removeProperty, size`

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

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

- ## Field Details

  - ### FILE_PREFIX

    public static final String FILE_PREFIX
    See Also:
      - Constant Field Values

  - ### JAVA_ICON

    public static final String JAVA_ICON
    See Also:
      - Constant Field Values

  - ### FILE_EXTENSION

    public static String FILE_EXTENSION

  - ### ZIP_FILE_EXTENSION

    public static String ZIP_FILE_EXTENSION

- ## Constructor Details

  - ### GTheme

    public GTheme(String name)
    Creates a new GTheme with the given name, the default `LookAndFeel` for the the platform and not using dark defaults. This theme will be using all the standard defaults from the theme.property files and the defaults from the default LookAndFeel.
    Parameters:
      `name` - the name for this GTheme

  - ### GTheme

    public GTheme(String name, LafType lafType)
    Creates a new empty GTheme with the given name, `LookAndFeel`, and whether or not to use dark defaults.
    Parameters:
      `name` - the name for the new GTheme
      `lafType` - the look and feel type used by this theme

  - ### GTheme

    public GTheme(File file, String name, LafType lafType, boolean useDarkDefaults)
    Constructor for creating a GTheme with an associated File.
    Parameters:
      `file` - the file that this theme will save to
      `name` - the name of the new theme
      `lafType` - the `LafType` for the new theme
      `useDarkDefaults` - true if this new theme uses dark defaults

- ## Method Details

  - ### getName

    public String getName()
    Returns the name of this GTheme
    Returns:
      the name of this GTheme

  - ### getLookAndFeelType

    public LafType getLookAndFeelType()
    Returns the name of the LookAndFeel associated with this GTheme
    Returns:
      the name of the LookAndFeel associated with this GTheme

  - ### useDarkDefaults

    public boolean useDarkDefaults()
    Returns true if this theme should use dark defaults
    Returns:
      true if this theme should use dark defaults

  - ### getThemeLocater

    public String getThemeLocater()
    Returns a String that can be used to find and restore this theme.
    Returns:
      a String that can be used to find and restore this theme.

  - ### getFile

    public File getFile()
    Returns the file associated with this theme.
    Returns:
      the file associated with this theme.

  - ### setColor

    public void setColor(String id, Color color)
    Sets the Color for the given id
    Parameters:
      `id` - the id to associate with the given Color
      `color` - the Color to associate with the given id

  - ### setColorRef

    public void setColorRef(String id, String refId)
    Sets a referred Color for the given id
    Parameters:
      `id` - the id to associate with the refId
      `refId` - the id of an indirect Color lookup for the given id.

  - ### setFont

    public void setFont(String id, Font font)
    Sets the Font for the given id
    Parameters:
      `id` - the id to associate with the given Font
      `font` - the Font to associate with the given id

  - ### setFontRef

    public void setFontRef(String id, String refId)
    Sets a referred font for the given id
    Parameters:
      `id` - the id to associate with the given Font reference id
      `refId` - the id of an indirect Font lookup for the given id.

  - ### setIcon

    public void setIcon(String id, Icon icon)
    Sets the icon for the given id
    Parameters:
      `id` - the id to associate with the given IconPath
      `icon` - the icon to assign to the given id

  - ### setIconRef

    public void setIconRef(String id, String refId)
    Sets a referred icon id for the given id
    Parameters:
      `id` - the id to associate with the given Font
      `refId` - the id of an indirect Icon lookup for the given id.

  - ### toString

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

  - ### hashCode

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

  - ### equals

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

  - ### hasSupportedLookAndFeel

    public boolean hasSupportedLookAndFeel()
    Returns true if this theme has a `LookAndFeel` that is supported by the current platform.
    Returns:
      true if this theme has a `LookAndFeel` that is supported by the current platform.

  - ### save

    public void save() throws IOException
    Saves this theme to its associated file.
    Throws:
      `IOException` - if an I/O error occurs when writing the file

  - ### isReadOnly

    public boolean isReadOnly()
    Returns true if this theme can not be changed
    Returns:
      true if this theme can not be changed

  - ### loadTheme

    public static GTheme loadTheme(File file) throws IOException
    Reads a theme from a file. The file can be either a theme file or a zip file containing a theme file and optionally a set of icon files.
    Parameters:
      `file` - the file to read.
    Returns:
      the theme that was read from the file
    Throws:
      `IOException` - if an error occcured trying to read a theme from the file.