Package generic.theme

Class ColorValue

All Implemented Interfaces:
Comparable<ThemeValue<Color>>

public class ColorValue extends ThemeValue<Color>
A class for storing Color values that have a String id (e.g. color.bg.foo) and either a concrete color or a reference id which is the String id of another ColorValue that it will inherit its color from. So if this class's color value is non-null, the refId will be null and if the class's refId is non-null, then the color value will be null.
  • Field Details

  • Constructor Details

    • ColorValue

      public ColorValue(String id, Color value)
      Constructor used when the ColorValue will have a direct Color value. The refId will be null. Note: if a GColor is passed in as the value, then this will be an indirect ColorValue that inherits its color from the id stored in the GColor.
      Parameters:
      id - the id for this ColorValue
      value - the Color to associate with the given id
    • ColorValue

      public ColorValue(String id, String refId)
      Constructor used when the ColorValue will inherit its color from another ColorValue. The color value field will be null.
      Parameters:
      id - the id for this ColorValue
      refId - the id of another ColorValue that this ColorValue will inherit from
  • Method Details

    • getSerializationString

      public String getSerializationString()
      Description copied from class: ThemeValue
      Returns the "key = value" String for writing this ThemeValue to a file
      Specified by:
      getSerializationString in class ThemeValue<Color>
      Returns:
      the "key = value" String for writing this ThemeValue to a file
    • isExternal

      public boolean isExternal()
      Description copied from class: ThemeValue
      True if this value is one that is one that is defined outside of the application, such as a Java Look and Feel key.
      Specified by:
      isExternal in class ThemeValue<Color>
      Returns:
      true if external
    • isColorKey

      public static boolean isColorKey(String key)
      Returns true if the given key string is a valid external key for a color value
      Parameters:
      key - the key string to test
      Returns:
      true if the given key string is a valid external key for a color value
    • parse

      public static ColorValue parse(String key, String value)
      Parses the value string into a color or reference and creates a new ColorValue using the given key and the parse results.
      Parameters:
      key - the key to associate the parsed value with
      value - the color value to parse
      Returns:
      a ColorValue with the given key and the parsed value
    • getReferredValue

      protected ColorValue getReferredValue(GThemeValueMap values, String refId)
      Description copied from class: ThemeValue
      Returns the ThemeValue referred to by this ThemeValue. Needs to be overridden by concrete classes as they know the correct method to call on the preferredValues map.
      Specified by:
      getReferredValue in class ThemeValue<Color>
      Parameters:
      values - the GThemeValueMap to be used to resolve the reference id
      refId - the id of the reference ThemeValue
      Returns:
      the ThemeValue referred to by this ThemeValue.
    • getUnresolvedReferenceValue

      protected Color getUnresolvedReferenceValue(String primaryId, String unresolvedId)
      Description copied from class: ThemeValue
      Returns the T to be used if the indirect reference couldn't be resolved.
      Specified by:
      getUnresolvedReferenceValue in class ThemeValue<Color>
      Parameters:
      primaryId - the id we are trying to get a value for
      unresolvedId - the reference id that couldn't be resolved
      Returns:
      the default value to be used if the indirect reference couldn't be resolved.
    • installValue

      public void installValue(ThemeManager themeManager)
      Description copied from class: ThemeValue
      Install this value as the current value for the application
      Specified by:
      installValue in class ThemeValue<Color>
      Parameters:
      themeManager - the application ThemeManager