Package generic.theme

Class ApplicationThemeManager

java.lang.Object
generic.theme.ThemeManager
generic.theme.ApplicationThemeManager

public class ApplicationThemeManager extends ThemeManager
This is the fully functional ThemeManager that manages themes in a application. To activate the theme functionality, Applications (or tests) must call initialize()
  • Field Details

  • Constructor Details

    • ApplicationThemeManager

      protected ApplicationThemeManager()
  • Method Details

    • initialize

      public static void initialize()
      Initialized the Theme and its values for the application.
    • doInitialize

      protected void doInitialize()
    • restoreThemeValues

      public void restoreThemeValues()
      Description copied from class: ThemeManager
      Restores all the current application back to the values as specified by the active theme. In other words, reverts any changes to the active theme that haven't been saved.
      Overrides:
      restoreThemeValues in class ThemeManager
    • restoreColor

      public void restoreColor(String id)
      Description copied from class: ThemeManager
      Restores the current color value for the given color id to the value established by the current theme.
      Overrides:
      restoreColor in class ThemeManager
      Parameters:
      id - the color id to restore back to the original theme value
    • restoreFont

      public void restoreFont(String id)
      Description copied from class: ThemeManager
      Restores the current font value for the given font id to the value established by the current theme.
      Overrides:
      restoreFont in class ThemeManager
      Parameters:
      id - the font id to restore back to the original theme value
    • restoreIcon

      public void restoreIcon(String id)
      Description copied from class: ThemeManager
      Restores the current icon value for the given icon id to the value established by the current theme.
      Overrides:
      restoreIcon in class ThemeManager
      Parameters:
      id - the icon id to restore back to the original theme value
    • isChangedColor

      public boolean isChangedColor(String id)
      Description copied from class: ThemeManager
      Returns true if the color associated with the given id has been changed from the current theme value for that id.
      Overrides:
      isChangedColor in class ThemeManager
      Parameters:
      id - the color id to check if it has been changed
      Returns:
      true if the color associated with the given id has been changed from the current theme value for that id.
    • isChangedFont

      public boolean isChangedFont(String id)
      Description copied from class: ThemeManager
      Returns true if the font associated with the given id has been changed from the current theme value for that id.
      Overrides:
      isChangedFont in class ThemeManager
      Parameters:
      id - the font id to check if it has been changed
      Returns:
      true if the font associated with the given id has been changed from the current theme value for that id.
    • isChangedIcon

      public boolean isChangedIcon(String id)
      Description copied from class: ThemeManager
      Returns true if the Icon associated with the given id has been changed from the current theme value for that id.
      Overrides:
      isChangedIcon in class ThemeManager
      Parameters:
      id - the Icon id to check if it has been changed
      Returns:
      true if the Icon associated with the given id has been changed from the current theme value for that id.
    • setTheme

      public void setTheme(GTheme theme)
      Description copied from class: ThemeManager
      Sets the application's active theme to the given theme.
      Overrides:
      setTheme in class ThemeManager
      Parameters:
      theme - the theme to make active
    • setLookAndFeel

      public void setLookAndFeel(LafType lafType, boolean useDarkDefaults)
      Description copied from class: ThemeManager
      Sets the current LookAndFeel. This is used by theme editors to allow users to see the effects of changing LookAndFeels when configuring a theme. Setting this different from the activeTheme's LookAndFeel setting means the the current theme is in an unsaved state and causes the ThemeManager.hasThemeChanges() method to return true.
      Overrides:
      setLookAndFeel in class ThemeManager
      Parameters:
      lafType - the LafType to set the LookAndFeel to
      useDarkDefaults - true if the application should used dark defaults with this LookAndFeel
    • addTheme

      public void addTheme(GTheme newTheme)
      Description copied from class: ThemeManager
      Adds the given theme to set of all themes.
      Overrides:
      addTheme in class ThemeManager
      Parameters:
      newTheme - the theme to add
    • deleteTheme

      public void deleteTheme(GTheme theme)
      Description copied from class: ThemeManager
      Removes the theme from the set of all themes. Also, if the theme has an associated file, the file will be deleted.
      Overrides:
      deleteTheme in class ThemeManager
      Parameters:
      theme - the theme to delete
    • getAllThemes

      public Set<GTheme> getAllThemes()
      Description copied from class: ThemeManager
      Returns a set of all known themes.
      Overrides:
      getAllThemes in class ThemeManager
      Returns:
      a set of all known themes.
    • getSupportedThemes

      public List<GTheme> getSupportedThemes()
      Description copied from class: ThemeManager
      Returns a set of all known themes that are supported on the current platform.
      Overrides:
      getSupportedThemes in class ThemeManager
      Returns:
      a set of all known themes that are supported on the current platform.
    • getTheme

      public GTheme getTheme(String themeName)
      Description copied from class: ThemeManager
      Returns the known theme that has the given name.
      Overrides:
      getTheme in class ThemeManager
      Parameters:
      themeName - the name of the theme to retrieve
      Returns:
      the known theme that has the given name
    • setFont

      public void setFont(FontValue newValue)
      Description copied from class: ThemeManager
      Updates the current value for the font id in the newValue
      Overrides:
      setFont in class ThemeManager
      Parameters:
      newValue - the new FontValue to install in the current values.
    • setColor

      public void setColor(ColorValue newValue)
      Description copied from class: ThemeManager
      Updates the current value for the color id in the newValue
      Overrides:
      setColor in class ThemeManager
      Parameters:
      newValue - the new ColorValue to install in the current values.
    • setIcon

      public void setIcon(IconValue newValue)
      Description copied from class: ThemeManager
      Updates the current value for the Icon id in the newValue
      Overrides:
      setIcon in class ThemeManager
      Parameters:
      newValue - the new IconValue to install in the current values.
    • getGColorUiResource

      public GColorUIResource getGColorUiResource(String id)
      Gets a UIResource version of the GColor for the given id. Using this method ensures that the same instance is used for a given id. This fixes an issue with some LookAndFeels that internally use '==' comparisons.
      Parameters:
      id - the id to get a GColorUIResource for
      Returns:
      a GColorUIResource for the given id
    • setJavaDefaults

      public void setJavaDefaults(GThemeValueMap map)
      Sets the map of Java default UI values. These are the UI values defined by the current Java Look and Feel.
      Parameters:
      map - the default theme values defined by the LookAndFeel
    • hasThemeChanges

      public boolean hasThemeChanges()
      Description copied from class: ThemeManager
      Returns true if there are any unsaved changes to the current theme.
      Overrides:
      hasThemeChanges in class ThemeManager
      Returns:
      true if there are any unsaved changes to the current theme.
    • hasThemeValueChanges

      public boolean hasThemeValueChanges()
      Description copied from class: ThemeManager
      Returns true if any theme values have changed. This does not take into account the current Look and Feel. Use ThemeManager.hasThemeChanges() to also account for changes to the Look and Feel.
      Overrides:
      hasThemeValueChanges in class ThemeManager
      Returns:
      true if any theme values have changed
    • registerFont

      public void registerFont(Component component, String fontId)
      Description copied from class: ThemeManager
      Binds the component to the font identified by the given font id. Whenever the font for the font id changes, the component will updated with the new font.
      Overrides:
      registerFont in class ThemeManager
      Parameters:
      component - the component to set/update the font
      fontId - the id of the font to register with the given component
    • registerFont

      public void registerFont(Component component, String fontId, int fontStyle)
      Description copied from class: ThemeManager
      Binds the component to the font identified by the given font id. Whenever the font for the font id changes, the component will updated with the new font.

      This method is fairly niche and should not be called by most clients. Instead, call ThemeManager.registerFont(Component, String).

      Overrides:
      registerFont in class ThemeManager
      Parameters:
      component - the component to set/update the font
      fontId - the id of the font to register with the given component
      fontStyle - the font style
    • buildCurrentValues

      protected void buildCurrentValues()
      Description copied from class: ThemeManager
      This method is called to create the internal set of theme value used by the application. To do this, we use a layered approach to install values, with the last values added overwriting any pre-existing values with the same key. The values are added in the following order:
       java defaults -> light values -> dark values -> look and feel values -> property file values -> theme values
       

      At the point this method is called, this is the state of these various values:

      • The 'javaValues' are normalized in the form of 'laf.font.TextArea'
      • The 'applicationDefaults' contains values loaded from the theme.properties files:
             font.listing.base
             font.monospaced
             [color]Viewport.background = color.bg
             [laf.font]TextArea.font = font.monospaced
             [laf.boolean]Button.rollover = true
             
      • The 'activeTheme' values are those loaded by the current theme, which has any changes made to the default values
      Overrides:
      buildCurrentValues in class ThemeManager
    • loadThemeFiles

      protected Collection<GTheme> loadThemeFiles()
    • refreshGThemeValues

      public void refreshGThemeValues()