Package generic.theme

Class 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 Details

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