Package resources

Class Settings

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<java.lang.String>

    public class Settings
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Iterable<java.lang.String>
    A collection of keys (names) that map to String values. Settings are generally used to store configuration information: the configurable feature is given a key name, and that key name can then be used to look up the feature's current value.

    The main application uses settings to control program behaviour and store user preferences. (For example, the user setting with the key name find-incremental will have a value of either yes or no depending on whether the incremental search option is currently selected in the find and replace window for code editors.) Game components may use settings to control how cards are laid out. In some cases, settings are also used to localize text for the game language.

    Internally, all setting values are stored as strings. However, a number of methods are provided that accept other data types and convert back and forth between strings automatically. Some of these expect the key name to include a specific suffix, and will append this to the key name if it is not present. The use of suffixes helps to distinguish the intended type of the setting when it is listed in a .settings file.

    Settings instances can have another settings instance as a parent. If the value of a key is requested, and it is not defined in a given instance, then that instance will ask its parent to return its value for the key. This process continues recursively until a value is found or a settings instance is reached that has no parent. Another way to understand this is that a settings instance defines a scope (in the sense of programming language theory) within the scope defined by its parent. The most common place where plug-in developers encounter such scopes is with the private settings instances found in GameComponents. These are always children of the game settings for the game that the component belongs to, which in turn is a child of the shared global settings instance. Thus, plug-in developers can store the default values for settings used by the game component in the game's settings instance. This avoids unnecessary duplication and makes it easier to change those defaults in future versions of the plug-in. It also allows the end user to "hack" the layout of a component by modifying the component's private settings to override values normally defined in the game's settings, such as image templates and text regions.

    Most settings instances have a chain of parents that ultimately leads back to the global shared settings instance, which combines application default settings, temporary setting changes, and user preferences in a single space. Note that the shared settings instance is read-only. You can, however, change user preference settings.

    Since:
    0.95
    Author:
    Chris Jennings
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Settings.Colour
      A Color subclass that is specialized to convert more easily to and from setting values.
      static class  Settings.ParseError
      Thrown by methods that attempt to convert setting values to objects when the conversion fails due to an error in the format of the value.
      static class  Settings.Region
      A specialized Rectangle that is more easily converted to or from a setting value.
      static class  Settings.Region2D
      A specialized Rectangle2D that is more easily converted to or from a setting value.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.beans.PropertyChangeListener DEBUG_LISTENER
      A PropertyChangeListener that will print diagnostic information to the script console when a setting changes.
    • Constructor Summary

      Constructors 
      Constructor Description
      Settings()
      Creates a new, empty Settings scope whose parent is the shared global scope.
      Settings​(Settings parent)
      Create a new settings scope within the scope of parent.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
      Adds a property change listener for this scope.
      void addSettingsFrom​(java.lang.String resource)
      Adds settings stored in a .settings resource file to this settings object.
      void addSettingsFrom​(java.util.Map<java.lang.String,​java.lang.String> settingMap)
      Adds entries stored in a map collection to this settings instance.
      void addSettingsFrom​(Settings sourceSettings)
      Adds entries from another Settings instance to this instance.
      boolean applyWindowSettings​(java.lang.String prefix, java.awt.Window window)
      Restores the position and size of a window from the last time its settings were stored in this settings object.
      static Settings.Colour color​(java.lang.String value)
      Cover method for colour(java.lang.String).
      static Settings.Colour colour​(java.lang.String value)
      Returns a Settings.Colour parsed from a string value.
      Settings createNamespace​(java.lang.String namespace)
      Returns a view of these settings within a namespace.
      static PageShape.CupShape cupShape​(java.lang.String value)
      Returns a CupShape for changing the flow of markup text from the specified value.
      static Settings forProperties​(java.lang.String name, java.util.Properties toWrap)
      Returns a view of an existing java.util.Properties object as a Settings object.
      java.lang.String get​(java.lang.String key)
      Returns a setting value, or null if it is not defined.
      java.lang.String get​(java.lang.String key, java.lang.String defaultValue)
      Returns a setting value, or a default value if it is not defined.
      boolean getBoolean​(java.lang.String key)
      Returns a boolean value based on the value of key.
      boolean getBoolean​(java.lang.String key, boolean defaultValue)
      Returns a boolean value based on the value of key.
      Settings.Colour getColor​(java.lang.String key)
      Returns the value of the specified key as a Settings.Colour; the key name will have -colour appended if necessary.
      Settings.Colour getColor​(java.lang.String key, int defaultValue)
      Returns the value of the specified key as a Settings.Colour; the key name will have -colour appended if necessary.
      Settings.Colour getColor​(java.lang.String key, java.awt.Color defaultValue)
      Returns the value of the specified key as a Settings.Colour; the key name will have -colour appended if necessary.
      Settings.Colour getColour​(java.lang.String key)
      Returns the value of the specified key as a Settings.Colour; the key name will have -colour appended if necessary.
      Settings.Colour getColour​(java.lang.String key, int defaultValue)
      Returns the value of the specified key as a Settings.Colour; the key name will have -colour appended if necessary.
      Settings.Colour getColour​(java.lang.String key, java.awt.Color defaultValue)
      Returns the value of the specified key as a Settings.Colour; the key name will have -colour appended if necessary.
      PageShape getCupShape​(java.lang.String key)
      Returns a CupShape for changing the flow of markup text from the value of the specified key; the key name will have -region appended if necessary.
      double getDouble​(java.lang.String key)
      Returns the value of the specified key as a double value.
      double getDouble​(java.lang.String key, double defaultValue)
      Returns the value of the specified key as a double value.
      java.lang.String getExpansionCode()
      Returns the code(s) for the selected expansion(s), assuming that these settings are a game component's private settings.
      int getExpansionVariant​(Sheet<? extends GameComponent> sheetWithDefaultValue)
      Returns the expansion logical variant index for the selected expansion, assuming that these settings are a game component's private settings.
      float getFloat​(java.lang.String key)
      Returns the value of the specified key as a float value.
      float getFloat​(java.lang.String key, float defaultValue)
      Returns the value of the specified key as an float value.
      javax.swing.Icon getIconResource​(java.lang.String key)
      Return an icon for the resource identified by the value of the specified key.
      java.awt.image.BufferedImage getImageResource​(java.lang.String key)
      Return an image for the resource identified by the value of the specified key.
      int getInt​(java.lang.String key)
      Returns an integer value based on the value of key.
      int getInt​(java.lang.String key, int defaultValue)
      Returns the value of the specified key as an integer value.
      java.util.Set<java.lang.String> getKeySet()
      Returns an immutable set of all of the keys that have values defined at this scope.
      java.lang.String getLocalized​(java.lang.String key, java.util.Locale loc)
      Returns a setting value which can be localized.
      java.awt.image.BufferedImage getNumberedImageResource​(java.lang.String key, int number)
      Returns an image resource that is one in a numbered sequence.
      java.lang.String getOverride​(java.lang.String key)
      Returns a setting value, or null if it is not defined.
      Settings getParent()
      Returns the parent scope of this Settings, or null if this is the shared scope.
      float getPointSize​(java.lang.String key)
      Returns a font point size from the specified key; the key name will have -pointsize appended if necessary.
      float getPointSize​(java.lang.String key, float defaultValue)
      Returns a font point size from the specified key; the key name will have -pointsize appended if necessary.
      java.awt.Font getPointSize​(java.lang.String key, java.awt.Font sourceFont)
      Returns a font based on the specified font but with the point size given in the the specified key; the key name will have -pointsize appended if necessary.
      Settings.Region getRegion​(java.lang.String key)
      Returns the Settings.Region represented by the value of the specified key; the key name will have -region appended if necessary.
      Settings.Region getRegion​(java.lang.String key, Settings.Region defaultValue)
      Returns the Settings.Region represented by the value of the specified key; the key name will have -region appended if necessary.
      Settings.Region2D getRegion2D​(java.lang.String key)
      Returns the Settings.Region2D represented by the value of the specified key; the key name will have -region appended if necessary.
      Settings.Region2D getRegion2D​(java.lang.String key, Settings.Region2D defaultValue)
      Returns the Settings.Region2D represented by the value of the specified key; the key name will have -region appended if necessary.
      java.net.URL getResourceURL​(java.lang.String key)
      Returns the URL of a resource from the value of the specified key.
      static Settings getShared()
      Returns the Settings instance that represents the shared global scope.
      java.lang.String getText​(java.lang.String key)
      Returns the value of a text key.
      int getTextAlignment​(java.lang.String key)
      Returns an alignment value suitable for use with a markup renderer from the value of the specified key; the key name will have -alignment appended if necessary.
      void getTextAlignment​(java.lang.String key, MarkupRenderer renderer)
      Sets the text alignment of a markup renderer to match the value of an alignment key; the key name will have -alignment appended if necessary.
      int getTextFittingMethod​(java.lang.String key)
      Returns a text-fitting method constant from the value of the specified key; the key name will have -text-fitting appended if necessary.
      TextStyle getTextStyle​(java.lang.String key, TextStyle base)
      Returns a TextStyle suitable for use with markup from the value of the specified key; the key name will have -style appended if necessary.
      float[] getTint​(java.lang.String key)
      Returns the value of the specified key as a tint configuration; the key name will have -tint appended if necessary.
      float[] getTint​(java.lang.String key, float[] defaultValue)
      Returns the value of the specified key as a tint configuration; the key name will have -tint appended if necessary.
      static Settings getUser()
      Returns the Settings instance that represents user settings.
      java.util.Set<java.lang.String> getVisibleKeySet()
      Returns an immutable set of all of the keys that are visible from this scope, including all parent scopes.
      boolean getYesNo​(java.lang.String key)
      Returns a boolean value based on the value of key.
      boolean getYesNo​(java.lang.String key, boolean defaultValue)
      Returns a boolean value based on the value of key.
      static int integer​(java.lang.String value)
      Parses a string into an integer value.
      protected boolean isSerializedParent()  
      java.util.Iterator<java.lang.String> iterator()
      Returns an iterator over the keys in this settings instance.
      static double number​(java.lang.String value)
      Parses a string into a double value.
      static Settings.Region region​(java.lang.String value)
      Returns a Settings.Region defined by a comma-separated list of four integers in the specified value.
      static Settings.Region2D region2D​(java.lang.String value)
      Returns a Settings.Region2D defined by a comma-separated list of four numbers in the specified value.
      java.lang.String registerFontFamily​(java.lang.String key)
      Registers a font family using the value of a setting key.
      void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
      Removes a listener that was previously added to this Settings.
      void reset​(java.lang.String key)
      Removes the specified key from this scope.
      void set​(java.lang.String key, java.lang.String value)
      Sets the value of a key at this scope.
      void setBoolean​(java.lang.String key, boolean value)
      Sets the value of a key with a boolean value.
      void setColor​(java.lang.String key, java.awt.Color colour)
      Sets the value of the specified key to a suitable value for the specified colour; the key name will have -colour appended if necessary.
      void setColour​(java.lang.String key, java.awt.Color colour)
      Sets the value of the specified key to a suitable value for the specified colour; the key name will have -colour appended if necessary.
      void setDouble​(java.lang.String key, double value)
      Sets the value of a key to a double value suitable for reading with getDouble(java.lang.String).
      void setFloat​(java.lang.String key, float value)
      Sets the value of a key to a float value suitable for reading with getFloat(java.lang.String).
      void setInt​(java.lang.String key, int value)
      Sets the value of a key to an integer value suitable for reading with getInt(java.lang.String).
      void setRegion​(java.lang.String key, Settings.Region region)
      Sets the specified key to a suitable value for the given region; the key name will have -region appended if necessary.
      void setRegion2D​(java.lang.String key, Settings.Region2D region)
      Sets the specified key to a suitable value for the given region; the key name will have -region appended if necessary.
      void setSettings​(java.lang.String... keyValuePairs)
      Sets multiple key, value pairs with a single method call.
      void setText​(java.lang.String key, java.lang.String value)
      Sets the value of a text key.
      void setTint​(java.lang.String key, float[] tintConfiguration)
      Sets the specified key to a suitable value for the given tint configuration; the key name will have -tint appended if necessary.
      void setTint​(java.lang.String key, float hFactor, float sFactor, float bFactor)
      Sets the specified key to a suitable value for the given tint configuration; the key name will have -tint appended if necessary.
      void setYesNo​(java.lang.String key, boolean value)
      Sets the value of a key with a boolean value suitable for reading with getYesNo(java.lang.String).
      int size()
      Returns the number of keys that are defined at this scope.
      void storeWindowSettings​(java.lang.String prefix, java.awt.Window window)
      Saves the position of a window for later recall by writing it as a group of settings.
      static int textAlignment​(java.lang.String value)
      Returns an alignment value suitable for use with a MarkupRenderer.
      static TextStyle textStyle​(java.lang.String value, TextStyle base)
      Returns a TextStyle suitable for use with markup from the specified value.
      static float[] tint​(java.lang.String value)
      Returns a tint configuration parsed from a string value.
      java.lang.String toString()
      Returns a string that describes this settings instance.
      static boolean yesNo​(java.lang.String value)
      Returns a boolean value for an arbitrary string using the same rules as those used by getYesNo(java.lang.String).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • DEBUG_LISTENER

        public static final java.beans.PropertyChangeListener DEBUG_LISTENER
        A PropertyChangeListener that will print diagnostic information to the script console when a setting changes.
        Since:
        2.1
    • Constructor Detail

      • Settings

        public Settings()
        Creates a new, empty Settings scope whose parent is the shared global scope.
      • Settings

        public Settings​(Settings parent)
        Create a new settings scope within the scope of parent. Passing null or Settings.getShared() for the parent will use the shared global scope.
        Parameters:
        parent - the parent scope that will be used to look up keys not defined in this scope
        Since:
        2.00.7
    • Method Detail

      • getShared

        public static Settings getShared()
        Returns the Settings instance that represents the shared global scope.

        Currently, attempting to set or reset a setting key in the shared scope will cause an UnsupportedOperationException to be thrown, although this may change in the future.

        Returns:
        the shared global settings scope
      • getUser

        public static Settings getUser()
        Returns the Settings instance that represents user settings. User settings are used to store data that must persist between program runs, such as the recent file list and preference choices.

        Because user settings take precedence over the standard Strange Eons settings, it can also be used to permanently modify a setting defined by a default value in the shared setting scope. However, this is not usually recommended. The preferred way to achieve this is to write an extension that temporarily changes the setting for the duration of the program run. This way, the extension can be uninstalled to eliminate the effect at a later time. (See RawSettings.setGlobalSetting(java.lang.String, java.lang.String).)

        The user settings scope should not generally be used to directly store preference settings for a third-party plug-in. Instead, use PluginContext.getSettings() to get a namespace within the user settings that is unique to the plug-in. This ensures that your setting names will not conflict with the standard application settings or other plug-ins.

        Returns:
        the shared user settings scope
        Since:
        2.00.8
      • forProperties

        public static Settings forProperties​(java.lang.String name,
                                             java.util.Properties toWrap)
        Returns a view of an existing java.util.Properties object as a Settings object. The Settings object is fully backed by the Properties object: changes to one will affect the other.
        Parameters:
        toWrap - the Properties to be treated as Settings
        name - a name that will be used to help distinguish the Settings instance when its toString() method is called; may be null
        Returns:
        a view of the properties as settings
        Since:
        2.1
      • createNamespace

        public final Settings createNamespace​(java.lang.String namespace)
        Returns a view of these settings within a namespace. All keys accessed through the returned Settings will add the namespace prefix to their keys. Namespace names always end in a colon (:), a character not normally used in key names. If the supplied name does not end in a colon, a colon will be added to the name automatically. For example, if the namespace "alpha" is created, and the returned settings instance is asked to get or set the value of the "arbitrary-example" key, it will look up the key named "alpha:arbitrary-example" in this settings instance.

        Plug-ins may obtain a private namespace through their PluginContext for storing preferences in user settings without fear of conflicting with other plug-ins (as long as conventions for key names are followed).

        Parameters:
        namespace - the space to restrict key names to
        Returns:
        a view of this Settings instance that is confined to the specified namespace
        Throws:
        java.lang.NullPointerException - if the specified namespace is null
        Since:
        2.1 alpha 1
      • getParent

        public Settings getParent()
        Returns the parent scope of this Settings, or null if this is the shared scope.
        Returns:
        the parent scope that will be used to look up keys not defined in this scope
        Since:
        2.00.7
      • getKeySet

        public java.util.Set<java.lang.String> getKeySet()
        Returns an immutable set of all of the keys that have values defined at this scope. Keys that are visible from this scope because they exist in a parent scope, but which are not actually defined in this scope, are not included. To get all of the keys that are visible from this scope, use getVisibleKeySet() instead.

        Note that the returned set represents a copy of the keys defined at this scope when the method was called. It does not change when this underlying Settings instance is modified.

        Returns:
        an immutable set of the names of all keys that have been set at this scope
        Since:
        2.00.7
      • iterator

        public java.util.Iterator<java.lang.String> iterator()
        Returns an iterator over the keys in this settings instance.
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.String>
        Returns:
        an iterator over the setting keys defined in this scope
        See Also:
        getKeySet()
      • getVisibleKeySet

        public java.util.Set<java.lang.String> getVisibleKeySet()
        Returns an immutable set of all of the keys that are visible from this scope, including all parent scopes.

        Note that the returned set represents a copy of the keys visible from this scope when the method was called.

        Returns:
        a set of the names of the keys that are visible from this scope
        Since:
        2.00.7
      • size

        public int size()
        Returns the number of keys that are defined at this scope. Additional keys may be visible from this scope if they are defined in a parent scope. If you need to know the total number of unique keys that are visible from this scope, call getVisibleKeySet().size().
        Returns:
        the number of keys defined at this scope
        Since:
        2.00.7
      • get

        public java.lang.String get​(java.lang.String key)
        Returns a setting value, or null if it is not defined.
        Parameters:
        key - the key to fetch the value of
        Returns:
        the value of key, or null
        Throws:
        java.lang.NullPointerException - if the key is null
      • get

        public java.lang.String get​(java.lang.String key,
                                    java.lang.String defaultValue)
        Returns a setting value, or a default value if it is not defined.
        Parameters:
        key - the key to fetch the value of
        defaultValue - the default value to return if get(key) == null
        Returns:
        the value of the key, or its default
        Throws:
        java.lang.NullPointerException - if the key is null
      • getLocalized

        public java.lang.String getLocalized​(java.lang.String key,
                                             java.util.Locale loc)
        Returns a setting value which can be localized. Key names are generated in the order [key_ll_CC, key_ll, key] (where key is the supplied key name, and ll and CC and the language and country codes of the specified locale) and the first key found is returned. If no key is found, null is returned.

        Note: While this method is useful in some situations, in most cases it is preferable to use Language.getResourceChain(java.lang.String, java.lang.String) to load an appropriate sequence of .settings files and merge them using addSettingsFrom(java.lang.String).

        Parameters:
        key - the key to fetch the value of
        loc - the locale to try to find a more specialized value for
        Returns:
        the value of the key, localized if possible, or null
        Throws:
        java.lang.NullPointerException - if the key is null
      • getOverride

        public java.lang.String getOverride​(java.lang.String key)
        Returns a setting value, or null if it is not defined. This method searches only the local scope, without delegating to parent setting scopes.
        Parameters:
        key - the key to fetch the value of
        Returns:
        the value of key, or null
        Throws:
        java.lang.NullPointerException - if the key is null
      • set

        public void set​(java.lang.String key,
                        java.lang.String value)
        Sets the value of a key at this scope.
        Parameters:
        key - the key to whose value at this scope should be changed
        value - the value to set for this scope
        Throws:
        java.lang.NullPointerException - if the supplied key is null
      • reset

        public void reset​(java.lang.String key)
        Removes the specified key from this scope. When a key is removed, a subsequent get of the key will search the parent scope, just as if the key had never been set. That is, the key's value is reset to the default value stored in the parent.
        Parameters:
        key - the key to be removed
        Throws:
        java.lang.NullPointerException - if the key is null
      • setSettings

        public void setSettings​(java.lang.String... keyValuePairs)
        Sets multiple key, value pairs with a single method call.
        Parameters:
        keyValuePairs - an array where elements at even indices are key names and elements at odd indices define the value to be associated with the key at the previous index
        Throws:
        java.lang.NullPointerException - if the array of setting pairs is null, or if any individual key name is null
        java.lang.IllegalArgumentException - if the array of setting pairs has an odd length
      • addSettingsFrom

        public void addSettingsFrom​(java.lang.String resource)
                             throws java.io.IOException,
                                    java.io.FileNotFoundException
        Adds settings stored in a .settings resource file to this settings object. The resource file defines keys and values using lines with the format key = value. Long entries may be broken over multiple physical lines by ending each physical line except the last with a backslash. Spaces, newlines, equals signs, colons, hashes, and backslashes may be inserted using the escape sequence , \n, \=, \:, \#, and \\, respectively. Unicode characters may be inserted using standard Java-style \uXXXX escape sequences, and must be used for characters outside of the ISO8859-15 character set. Note that if you edit the file in the built-in code editor, the editor will convert such characters to escape sequences automatically.
        Parameters:
        resource - a file relative to the resources folder
        Throws:
        java.io.FileNotFoundException - if the specified resource does not exist
        java.io.IOException - if an error occurs while loading the settings
      • addSettingsFrom

        public void addSettingsFrom​(java.util.Map<java.lang.String,​java.lang.String> settingMap)
        Adds entries stored in a map collection to this settings instance.
        Parameters:
        settingMap - a map of keys and associated values
        Throws:
        java.lang.NullPointerException - if the map is null
      • addSettingsFrom

        public void addSettingsFrom​(Settings sourceSettings)
        Adds entries from another Settings instance to this instance. If a key is defined in both instances, the current value in this instance will be replaced. Keys from the source's parent, if any, are not copied.
        Parameters:
        sourceSettings - the settings instance to copy from
      • getText

        public final java.lang.String getText​(java.lang.String key)
        Returns the value of a text key. This is essentially the same as get(java.lang.String), with the following exceptions:
        1. the key name will have -text appended if necessary
        2. if the key is not defined, instead of returning null the method will return [MISSING: <i>key name</i>]
        This is useful when the contents of a key will be displayed directly on a game component, as a missing or reset key will be immediately obvious to the viewer.
        Parameters:
        key - the name of a text key, with or without the -text suffix
        Returns:
        the value of the key, with the -text suffix, or a special undefined string if the key does not exist
      • setText

        public final void setText​(java.lang.String key,
                                  java.lang.String value)
        Sets the value of a text key. This is equivalent to calling set(java.lang.String, java.lang.String), except that the key will have the suffix -text appended if necessary.
        Parameters:
        key - the text key to change the value of
        value - the new value for the key
      • getYesNo

        public final boolean getYesNo​(java.lang.String key)
        Returns a boolean value based on the value of key. Any of "yes", "true", or "1" are mapped to true, and all other values are mapped to false (including null).
        Parameters:
        key - the name of the setting key
        Returns:
        true if the value of the setting is "yes", "true", or "1"
        See Also:
        setYesNo(java.lang.String, boolean)
      • getYesNo

        public final boolean getYesNo​(java.lang.String key,
                                      boolean defaultValue)
        Returns a boolean value based on the value of key. Any of "yes", "true", or "1" are mapped to true, and all other values are mapped to false.
        Parameters:
        key - the name of the setting key
        defaultValue - the default value to return if the key is not defined
        Returns:
        true if the value of the setting is "yes", "true", or "1"
        See Also:
        setYesNo(java.lang.String, boolean)
      • setYesNo

        public final void setYesNo​(java.lang.String key,
                                   boolean value)
        Sets the value of a key with a boolean value suitable for reading with getYesNo(java.lang.String).
        Parameters:
        key - the name of the key to set
        value - the value to convert into a setting
        See Also:
        getYesNo(java.lang.String)
      • getBoolean

        public final boolean getBoolean​(java.lang.String key)
        Returns a boolean value based on the value of key. This is a cover for getYesNo(java.lang.String).
        Parameters:
        key - the name of the setting key
        Returns:
        true if the value of the setting is "yes", "true", or "1"
      • getBoolean

        public final boolean getBoolean​(java.lang.String key,
                                        boolean defaultValue)
        Returns a boolean value based on the value of key. This is a cover for getYesNo(java.lang.String, boolean).
        Parameters:
        key - the name of the setting key
        defaultValue - the default value to return if the key is not defined
        Returns:
        true if the value of the setting is "yes", "true", or "1"
      • setBoolean

        public final void setBoolean​(java.lang.String key,
                                     boolean value)
        Sets the value of a key with a boolean value. This is a cover for setYesNo(java.lang.String, boolean).
        Parameters:
        key - the name of the key to set
        value - the value to convert into a setting
        See Also:
        getYesNo(java.lang.String)
      • yesNo

        public static boolean yesNo​(java.lang.String value)
        Returns a boolean value for an arbitrary string using the same rules as those used by getYesNo(java.lang.String). Namely: any of "yes", "true", or "1" are mapped to true, and all other values are mapped to false (including null).
        Parameters:
        value - the value to parse
        Returns:
        true if the value is "yes", "true", or "1" (not case sensitive)
      • getInt

        public final int getInt​(java.lang.String key)
        Returns an integer value based on the value of key. The conversion of the value is performed as if by integer(java.lang.String).
        Parameters:
        key - the name of the setting key
        Returns:
        the integer value of the setting
        Throws:
        Settings.ParseError - if the value is not valid or is not defined
      • getInt

        public final int getInt​(java.lang.String key,
                                int defaultValue)
        Returns the value of the specified key as an integer value. If the value is invalid or not defined, the default value is returned.
        Parameters:
        key - the key to look up
        defaultValue - the default value for the key
        Returns:
        the integer value of the key, or the default
      • setInt

        public final void setInt​(java.lang.String key,
                                 int value)
        Sets the value of a key to an integer value suitable for reading with getInt(java.lang.String).
        Parameters:
        key - the name of the key to set
        value - the value to convert into a setting
        See Also:
        getInt(java.lang.String)
      • integer

        public static int integer​(java.lang.String value)
        Parses a string into an integer value. Values that fit the following pattern can be parsed:
                    [+|-][0x|0X|#|0][digits]
        A basic integer value consists of an optional sign (+ or -) followed by decimal digits. If the digits follow 0x, 0X, or #, then the value is treated as a hexadecimal (base 16) number. In this case, the digits may include the letters a-f (or A-F). If the digits follow 0, then the value is treated as an octal (base 8) number. In this case the allowed digits are 0-7 inclusive.

        If the value includes a decimal point ('.'), then the value will be parsed up to the decimal point and any following digits ignored.

        If the value cannot be parsed, or if it falls outside of the range Integer.MIN_VALUE...Integer.MAX_VALUE, a Settings.ParseError is thrown.

        Parameters:
        value - the string to convert to an integer
        Returns:
        the converted value, or Integer.MIN_VALUE
        Throws:
        Settings.ParseError - if the value is not valid
      • getFloat

        public final float getFloat​(java.lang.String key)
        Returns the value of the specified key as a float value. The conversion of the value is performed as if by number(java.lang.String), except for being single precision floating point rather than double precision floating point.
        Parameters:
        key - the name of the setting key
        Returns:
        the float value of the setting
        Throws:
        Settings.ParseError - if the value is not valid as defined above
      • getFloat

        public final float getFloat​(java.lang.String key,
                                    float defaultValue)
        Returns the value of the specified key as an float value. If the value is invalid or not defined, the default value is returned.
        Parameters:
        key - the key to look up
        defaultValue - the default value for the key
        Returns:
        the float value of the key, or the default
      • setFloat

        public final void setFloat​(java.lang.String key,
                                   float value)
        Sets the value of a key to a float value suitable for reading with getFloat(java.lang.String).
        Parameters:
        key - the name of the key to set
        value - the value to convert into a setting
        See Also:
        getFloat(java.lang.String)
      • getDouble

        public final double getDouble​(java.lang.String key)
        Returns the value of the specified key as a double value. The conversion of the value is performed as if by number(java.lang.String).
        Parameters:
        key - the name of the setting key
        Returns:
        the float value of the setting
        Throws:
        Settings.ParseError - if the value is not valid
        See Also:
        setDouble(java.lang.String, double)
      • getDouble

        public final double getDouble​(java.lang.String key,
                                      double defaultValue)
        Returns the value of the specified key as a double value. If the value is invalid or not defined, the default value is returned.
        Parameters:
        key - the key to look up
        defaultValue - the default value for the key
        Returns:
        the double value of the key, or the default
        See Also:
        setDouble(java.lang.String, double)
      • setDouble

        public final void setDouble​(java.lang.String key,
                                    double value)
        Sets the value of a key to a double value suitable for reading with getDouble(java.lang.String).
        Parameters:
        key - the name of the key to set
        value - the value to convert into a setting
        See Also:
        getDouble(java.lang.String)
      • number

        public static double number​(java.lang.String value)
        Parses a string into a double value. The value is parsed as if by Double.parseDouble(java.lang.String), except that surrounding whitespace is ignored.
        Parameters:
        value - the string to convert to a floating-point number
        Returns:
        the parsed value
        Throws:
        Settings.ParseError - if the value is not valid as defined above
      • getColour

        public final Settings.Colour getColour​(java.lang.String key)
        Returns the value of the specified key as a Settings.Colour; the key name will have -colour appended if necessary. The colour must be expressed in one of the formats described under colour(java.lang.String).
        Parameters:
        key - the the name of a key, with or without the -colour suffix
        Returns:
        a colour created by interpreting the value of the key
        Throws:
        Settings.ParseError - if the value is null or invalid
        See Also:
        colour(java.lang.String)
      • getColour

        public final Settings.Colour getColour​(java.lang.String key,
                                               java.awt.Color defaultValue)
        Returns the value of the specified key as a Settings.Colour; the key name will have -colour appended if necessary. If the value is invalid or not defined, the default value is returned.
        Parameters:
        key - the the name of a key, with or without the -colour suffix
        defaultValue - the default value for the key
        Returns:
        a colour created by interpreting the value of the key
        See Also:
        colour(java.lang.String)
      • getColour

        public final Settings.Colour getColour​(java.lang.String key,
                                               int defaultValue)
        Returns the value of the specified key as a Settings.Colour; the key name will have -colour appended if necessary. If the value is invalid or not defined, a Colour is created for the ARGB value represented by defaultValue and returned.
        Parameters:
        key - the the name of a key, with or without the -colour suffix
        defaultValue - the default value for the key
        Returns:
        a colour created by interpreting the value of the key
        See Also:
        colour(java.lang.String)
      • setColour

        public final void setColour​(java.lang.String key,
                                    java.awt.Color colour)
        Sets the value of the specified key to a suitable value for the specified colour; the key name will have -colour appended if necessary.
        Parameters:
        key - the name of the key to set, with or without -colour
        colour - the colour value to write as a setting
      • getColor

        public final Settings.Colour getColor​(java.lang.String key)
        Returns the value of the specified key as a Settings.Colour; the key name will have -colour appended if necessary. This is a cover for getColour(java.lang.String).
        Parameters:
        key - the the name of a key, with or without the -colour suffix
        Returns:
        a colour created by interpreting the value of the key
        Throws:
        Settings.ParseError - if the value is null or invalid
      • getColor

        public final Settings.Colour getColor​(java.lang.String key,
                                              java.awt.Color defaultValue)
        Returns the value of the specified key as a Settings.Colour; the key name will have -colour appended if necessary. This is a cover for getColour(java.lang.String, java.awt.Color).
        Parameters:
        key - the the name of a key, with or without the -colour suffix
        defaultValue - the default value for the key
        Returns:
        a colour created by interpreting the value of the key
      • getColor

        public final Settings.Colour getColor​(java.lang.String key,
                                              int defaultValue)
        Returns the value of the specified key as a Settings.Colour; the key name will have -colour appended if necessary. This is a cover for getColour(java.lang.String, int).
        Parameters:
        key - the the name of a key, with or without the -colour suffix
        defaultValue - the default value for the key
        Returns:
        a colour created by interpreting the value of the key
      • setColor

        public final void setColor​(java.lang.String key,
                                   java.awt.Color colour)
        Sets the value of the specified key to a suitable value for the specified colour; the key name will have -colour appended if necessary. This is a cover for setColour(java.lang.String, java.awt.Color).
        Parameters:
        key - the name of the key to set, with or without -colour
        colour - the colour value to write as a setting
      • colour

        public static Settings.Colour colour​(java.lang.String value)
        Returns a Settings.Colour parsed from a string value. The colour must be expressed using one of the following formats:

        RGB colour value, hexadecimal: [#][AA]RRGGBB
        A colour in the sRGB colour space defined using either 6 or 8 hexadecimal (base 16) digits. The colour value may optionally start with a '#' character, like colour values in HTML.

        Each pair of hexadecimal digits defines the level of red (RR), green (GG), or blue (BB) used in the resulting colour: 00 means no amount of that primary should be used, and ff (equivalent to decimal 255) means the maximum amount of that primary should be used. For example, the purest, brightest possible red colour would be specified as #ff0000; that is, the maximum amount of red and no amount of any other primary.

        If the colour value consists of exactly 6 hexadecimal digits, then it will be completely opaque. If there are 8 hexadecimal digits, then the first two digits specify an opacity (or alpha) value for the colour, also as a value between 00 and ff. A value of 00 is completely transparent (effectively invisible), while values between 00 and ff specify increasing degrees of translucency. For example, a colour with an alpha value of 80 (128 in decimal) would show 50% of the underlying colour when painted onto a surface.

        RGB colour value, decimal: [rgb[a]](R,G,B[,A])
        A colour in the sRGB colour space defined using either 3 or 4 fractional values. This is essentially the same as the above format, but it uses decimal colour components instead of hexadecimal. The colour value must be placed inside parentheses, and may optionally be prefixed with either "rgb" or "rgba" (like colour values in HTML). For legibility, you can add one or more spaces between the components.

        Each fraction defines the level of red (R), green (G), or blue (B) as a value between 0 and 1. For example, the colour #ff0000 above would be expressed as (1, 0, 0); the colour 50% grey would be expressed as (0.5, 0.5, 0.5). If a fourth value is supplied, it defines the alpha value of the colour. For example, the value (1, 1, 1, 0.5) yields a 50% translucent white.

        HSB colour value, decimal: hsb[a](H,S,B[,A])
        A colour in the HSB (HSV) colour space defined using either 3 or four decimal numbers, representing the Hue, Saturation, Brightness, and an optional Alpha value. The hue value is an angle, measured in degrees, which defines a point on the edge of a colour wheel where 0° is pure red, 120° is pure green, and 240° is pure blue. The saturation value is a number between 0 and 1, where 0 is desaturated (grey) and 1 is fully saturated. The brightness value is also a number between 0 and 1, where 0 represents black and 1 represents maximum brightness. If a fourth value is supplied, it defines the alpha value of the colour as described above. For example, the value hsb(180, 1, 1, 0.8) yields pure cyan with an alpha of 80%.

        Parameters:
        value - a string of that describes a colour using one of the above formats
        Returns:
        the colour represented by the supplied value
        Throws:
        Settings.ParseError
        Since:
        2.00.7
        See Also:
        getColor(java.lang.String)
      • color

        public static Settings.Colour color​(java.lang.String value)
        Cover method for colour(java.lang.String).
        Parameters:
        value - a string of that describes a colour
        Returns:
        the colour represented by the supplied value
        Since:
        2.00.7
      • getTint

        public final float[] getTint​(java.lang.String key)
        Returns the value of the specified key as a tint configuration; the key name will have -tint appended if necessary. The tint must be expressed using the format described under tint(java.lang.String). The returned float array is suitable for use with a TintingFilter.
        Parameters:
        key - the the name of a key, with or without the -tint suffix
        Returns:
        a tint configuration created by interpreting the value of the key
        Throws:
        Settings.ParseError - if the value is null or invalid
        See Also:
        tint(java.lang.String), setTint(java.lang.String, float[])
      • getTint

        public final float[] getTint​(java.lang.String key,
                                     float[] defaultValue)
        Returns the value of the specified key as a tint configuration; the key name will have -tint appended if necessary. If the value is invalid or not defined, the default value is returned. Note that it is up to the caller to ensure that if a default is supplied that it is a valid tint configuration (namely, that is has length three).
        Parameters:
        key - the key to look up, with or without the -tint suffix
        defaultValue - the default value for the key
        Returns:
        the tint configuration extracted from the key, or the default
        See Also:
        tint(java.lang.String), setTint(java.lang.String, float[])
      • setTint

        public final void setTint​(java.lang.String key,
                                  float[] tintConfiguration)
        Sets the specified key to a suitable value for the given tint configuration; the key name will have -tint appended if necessary. The tint configuration will be taken from the first three elements of the specified array.
        Parameters:
        key - the key to modify, with or without the -tint suffix
        tintConfiguration - an array of at least three float values containing the tint configuration as the first three elements
        Throws:
        java.lang.IllegalArgumentException - if the array has less than three elements
      • setTint

        public final void setTint​(java.lang.String key,
                                  float hFactor,
                                  float sFactor,
                                  float bFactor)
        Sets the specified key to a suitable value for the given tint configuration; the key name will have -tint appended if necessary.
        Parameters:
        key - the key to modify, with or without the -tint suffix
        hFactor - the hue adjustment factor for the tint configuration
        sFactor - the saturation adjustment factor for the tint configuration
        bFactor - the brightness adjustment factor for the tint configuration
      • tint

        public static float[] tint​(java.lang.String value)
        Returns a tint configuration parsed from a string value. A tint configuration is used to express colours in relative terms. A tint setting consists of the following components, analogous to how HSB colours are defined by colour(java.lang.String):
                    [tint(]H,S,B[)]
        The value of H is a positive or negative change in the hue angle, expressed in degrees, such as -90.0. The values for S and B are scaling factors that are applied to the saturation and brightness values, respectively. The "tint" keyword and parentheses are optional.

        The tint configuration returned from this method consists of an array of three floating point values containing the hue, saturation, and brightness components as above, except that the angle is converted to a value between 0 and 1 by dividing it by 360. This is the same format that is expected by TintingFilters.

        Parameters:
        value - the string to convert into a tint configuration using the format described above
        Returns:
        a tint configuration for the value
        Throws:
        Settings.ParseError - if the value is null or invalid
        Since:
        2.00.7
        See Also:
        getTint(java.lang.String), TintFilter, tints scripting library
      • getRegion

        public final Settings.Region getRegion​(java.lang.String key)
        Returns the Settings.Region represented by the value of the specified key; the key name will have -region appended if necessary. The returned region is limited to integer precision. The region value must use one of the following forms:

        <i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>
        A list of four numbers that specify the x-position, y-position, width, and height of the region.

        d(<i>parent</i>, <i>dx</i>, <i>dy</i>, <i>dw</i>, <i>dh</i>)
        This form allows you to specify one region in terms of another region. For example, if a region key has the value d(other,5,-10,0,0), then the value of the region would be determined by looking up the value of the region with the key name "other-region", and then shifting it to the right by 5 units and up by 10 units.

        Parameters:
        key - the the name of a key, with or without the -region suffix
        Returns:
        the region described by the value of the key, or null if the key is not defined
        Throws:
        Settings.ParseError - if the value does not have the correct syntax, or if any region referenced by the value is missing
        See Also:
        setRegion(java.lang.String, resources.Settings.Region), region(java.lang.String), Settings.Region
      • getRegion

        public final Settings.Region getRegion​(java.lang.String key,
                                               Settings.Region defaultValue)
        Returns the Settings.Region represented by the value of the specified key; the key name will have -region appended if necessary. If the value is not defined or is invalid, the default value is returned.
        Parameters:
        key - the the name of a key, with or without the -region suffix
        defaultValue - the region to region if the key value is missing or invalid
        Returns:
        the region described by the value of the key
      • setRegion

        public final void setRegion​(java.lang.String key,
                                    Settings.Region region)
        Sets the specified key to a suitable value for the given region; the key name will have -region appended if necessary.
        Parameters:
        key - the key to modify, with or without the -region suffix
        region - the region to write as a setting value
      • region

        public static Settings.Region region​(java.lang.String value)
        Returns a Settings.Region defined by a comma-separated list of four integers in the specified value. The value must describe a region using the first of the formats described above.
        Parameters:
        value - a string containing a description of the region
        Returns:
        the region described by the value
        Throws:
        Settings.ParseError - if the value is not a valid region description
      • getRegion2D

        public final Settings.Region2D getRegion2D​(java.lang.String key,
                                                   Settings.Region2D defaultValue)
        Returns the Settings.Region2D represented by the value of the specified key; the key name will have -region appended if necessary. If the value is not defined or is invalid, the default value is returned.
        Parameters:
        key - the the name of a key, with or without the -region suffix
        defaultValue - the region to region if the key value is missing or invalid
        Returns:
        the region described by the value of the key
      • setRegion2D

        public final void setRegion2D​(java.lang.String key,
                                      Settings.Region2D region)
        Sets the specified key to a suitable value for the given region; the key name will have -region appended if necessary.
        Parameters:
        key - the key to modify, with or without the -region suffix
        region - the region to write as a setting value
      • region2D

        public static Settings.Region2D region2D​(java.lang.String value)
        Returns a Settings.Region2D defined by a comma-separated list of four numbers in the specified value.
        Parameters:
        value - a string containing a description of the region
        Returns:
        the region described by the value
        Throws:
        Settings.ParseError - if the value is not a valid region description
      • getCupShape

        public final PageShape getCupShape​(java.lang.String key)
        Returns a CupShape for changing the flow of markup text from the value of the specified key; the key name will have -region appended if necessary. The value of the key is a comma-separated list of 5 numbers, specifying the left and right insets at the top of the shape, the y-position at which to switch to the bottom insets, and finally the left and right insets at the bottom of the shape.
        Parameters:
        key - the key whose value will be used to create a cup shape, with or without the -shape suffix
        Returns:
        the cup shape described by the key's value
        Since:
        2.1
        See Also:
        cupShape(java.lang.String)
      • cupShape

        public static PageShape.CupShape cupShape​(java.lang.String value)
        Returns a CupShape for changing the flow of markup text from the specified value. The supplied string must be a comma-separated list of 5 numbers, specifying the left and right insets at the top of the shape, the y-position at which to switch to the bottom insets, and finally the left and right insets at the bottom of the shape.
        Parameters:
        value - the value to parse into a cup shape description
        Returns:
        the cup shape described by the value
        Since:
        2.1
        See Also:
        cupShape(java.lang.String)
      • getPointSize

        public final float getPointSize​(java.lang.String key)
        Returns a font point size from the specified key; the key name will have -pointsize appended if necessary.
        Parameters:
        key - the name of the setting key, with or without the -pointsize suffix
        Returns:
        the float value of the key
        Throws:
        Settings.ParseError - if the value is undefined or invalid
      • getPointSize

        public final float getPointSize​(java.lang.String key,
                                        float defaultValue)
        Returns a font point size from the specified key; the key name will have -pointsize appended if necessary. If the value is not defined or invalid, the default value is returned.
        Parameters:
        key - the name of the setting key, with or without the -pointsize suffix
        defaultValue - the value to use if the key is not valid
        Returns:
        the float value of the key
        Since:
        3.0
      • getPointSize

        public final java.awt.Font getPointSize​(java.lang.String key,
                                                java.awt.Font sourceFont)
        Returns a font based on the specified font but with the point size given in the the specified key; the key name will have -pointsize appended if necessary. If the value is not defined, invalid, or is the same as the source font's point size, the source font will be returned. Otherwise, a new font is returned that is identical to the source font except that its point size matches the size defined by the value of the key.
        Parameters:
        key - the name of the setting key, with or without the -pointsize suffix
        sourceFont - the font to use to derive a font at the specified point size
        Returns:
        a version of the source font with the point size given by the value of the key
        Since:
        3.0
      • textAlignment

        public static int textAlignment​(java.lang.String value)
        Returns an alignment value suitable for use with a MarkupRenderer. The alignment value is a comma-separated list of the following case-insensitive tokens:
        left
        sets the horizontal alignment to left-aligned
        right
        sets the horizontal alignment to right-aligned
        center
        sets the horizontal alignment to center-aligned
        centre
        synonym for center
        top
        sets the vertical alignment to top-aligned
        bottom
        sets the vertical alignment to bottom-aligned
        middle
        sets the vertical alignment to center-aligned
        justified
        sets text justification to justified
        unjustified
        sets text justification to unjustified
        ragged
        synonym for unjustified
        * default value for category

        The tokens are divided into three categories: horizontal alignment, vertical alignment, and justification. If more than one token in the same category appears in the list, the rightmost value takes precedence. For example, the value right, top, left would result in left- and top-aligned text. If any category is left unspecified, the default value for the category is used.

        Parameters:
        value - the text alignment value to parse
        Returns:
        the bitwise or of the last-specified alignment value in each category
      • getTextStyle

        public final TextStyle getTextStyle​(java.lang.String key,
                                            TextStyle base)
        Returns a TextStyle suitable for use with markup from the value of the specified key; the key name will have -style appended if necessary. The value will converted into a text style as described under textStyle(java.lang.String, ca.cgjennings.layout.TextStyle).
        Parameters:
        key - the the name of a key, with or without the -style suffix
        base - a baseline style to modify, or null to create a new style
        Returns:
        the text style described by the value of the key
        Throws:
        Settings.ParseError - if the value is missing or is invalid
      • textStyle

        public static TextStyle textStyle​(java.lang.String value,
                                          TextStyle base)
        Returns a TextStyle suitable for use with markup from the specified value. If a base text style is provided, then that style will be modified with the style information embedded in the value. Otherwise, a new, empty style will be created and filled in from the value. The value describes zero or more style settings using the following format:

        Style settings are separated from each other by semicolons (';'). Each style setting consists of two parts, a key name and a value, separated by a colon (':'). The key is the name of a TextAttribute key. It not case sensitive, and you may substitute spaces for underscores. For example, the key name "underline" matches TextAttribute.UNDERLINE, and the key name "numeric shaping" matches TextAttribute.NUMERIC_SHAPING. By default, a value must be the name of one of the predefined values found in TextAttribute; these names are also case insensitive and allow the use of spaces for underscores. For example, the following style setting would enable underlined text:
        underline: underline on

        Some attribute keys require values that are not predefined. For example, the FAMILY key requires a string that names the desired font. The parser lets you describe strings, colours, integers and floating point numbers literally. Other values can be set using script expressions.

        Examples and Additional Information
        String values must be explicitly marked off with quotes (' or "), or the text will be interpreted as a text attribute constant. When setting a text attribute constant, you can leave off the prefix for the key type. In this example, the parser infers that oblique means POSTURE_OBLIQUE from the fact that the key is POSTURE:
        family: 'Helvetica'; posture: oblique

        Integers and floating point values are written as an optional sign followed by a sequence of digits. Sequences that include a decimal point are interpreted as floating point values. Colour values are specified using the same formats as described under colour(java.lang.String); colours described with a sequence of hex digits must start with a '#' to distinguish them from integers.

        Placing braces around a value causes it to be interpreted as a script expression. The expression is evaluated, and the result becomes the value assigned to the attribute. This can be used to determine a value dynamically at runtime or to create appropriate objects for keys that take values not supported by the parser, such as TransformAttribute:
        family: {ResourceKit.bodyFamily}; size: 10; foreground: #ff0000;

        Parameters:
        value - the style specification to parse; see above for format
        base - a baseline style to modify, or null to create a new style
        Returns:
        the modified baseline style, or a new style if the baseline style was null
        See Also:
        MarkupRenderer, TextStyle, markup scripting library
      • getTextFittingMethod

        public int getTextFittingMethod​(java.lang.String key)
        Returns a text-fitting method constant from the value of the specified key; the key name will have -text-fitting appended if necessary. The value is mapped to a text-fitting constant as follows:
         "none"    MarkupRenderer.FIT_NONE
         "spacing" MarkupRenderer.FIT_TIGHTEN_LINE_SPACING
         "scaling" MarkupRenderer.FIT_SCALE_TEXT
         "both"    MarkupRenderer.FIT_BOTH
         
        Parameters:
        key - the key, with or without the -text-fitting suffix
        Returns:
        a text fitting constant suitable for use with a MarkupRenderer.
      • getExpansionVariant

        public int getExpansionVariant​(Sheet<? extends GameComponent> sheetWithDefaultValue)
        Returns the expansion logical variant index for the selected expansion, assuming that these settings are a game component's private settings. If no variant is set, returns 0. If the variant is a boolean value (which was a valid value in versions of Strange Eons prior to 3), it will be silently converted to "0" or "1".

        If the settings do not define a value for the variant key (Expansion.VARIANT_SETTING_KEY) and a non-null Sheet instance is provided, then a default value will be determined by looking up the value of the key sheetWithDefaultValue.getExpansionSymbolKey() + "-invert". This is for backwards compatibility with components from previous versions. To set a default variant for a component, it is recommended that you set the value of the Expansion.VARIANT_SETTING_KEY key with the desired default variant when the component is first created.

        Parameters:
        sheetWithDefaultValue - optional sheet to use to determine a default value
        Returns:
        the logical variant index for the component, or "0" if none is set
        See Also:
        getExpansionCode()
      • getImageResource

        public final java.awt.image.BufferedImage getImageResource​(java.lang.String key)
        Return an image for the resource identified by the value of the specified key. The value of the key is treated as a resource identifier and loaded as if by ResourceKit.getImage(java.lang.String). If the value of the key is null, a placeholder "missing image" graphic is returned.
        Parameters:
        key - a key whose value points to an image file
        Returns:
        the image specified by the value of the key
        Since:
        2.1
      • getNumberedImageResource

        public final java.awt.image.BufferedImage getNumberedImageResource​(java.lang.String key,
                                                                           int number)
        Returns an image resource that is one in a numbered sequence. The value of the key should include the string "00". This string will be replaced by the value of the specified number. If the number is less than 10, it will be preceded by a 0. The value, after the number has been replaced, will be passed to ResourceKit.getImage(java.lang.String) to load an appropriate image. If the value of the key is null, a placeholder "missing image" graphic is returned.

        For example, suppose the following files are included in a plug-in:

         resources/xyzzy/sample-00-image.png
         resources/xyzzy/sample-01-image.png
         resources/xyzzy/sample-02-image.png
         
        If the value of the key sample-images is xyzzy/sample-00-image.png, then calling getNumberedImageResource( "sample-images", 2 ) would return the sample-02-image.png resource as an image.
        Parameters:
        key - the key that contains the base name of the image resource
        number - the index of the desired image in the sequence
        Returns:
        the image for the specified number in the sequence, as determined by the above algorithm
        Throws:
        java.lang.IllegalArgumentException - if the number is negative
      • getIconResource

        public final javax.swing.Icon getIconResource​(java.lang.String key)
        Return an icon for the resource identified by the value of the specified key. The value of the key is treated as a resource identifier and loaded as if by ResourceKit.getIcon(java.lang.String). If the value of the key is null, a placeholder "missing image" icon is returned.
        Parameters:
        key - a key whose value points to an image file
        Returns:
        an icon of the image
        Since:
        2.00.7
      • registerFontFamily

        public final java.lang.String registerFontFamily​(java.lang.String key)
        Registers a font family using the value of a setting key. The value of the key must be a comma-separated list of font resources. If the registration fails, an error will be displayed and a fallback family will be returned.
        Parameters:
        key - the name of the family key to register
        Returns:
        the family name to use for the font
        Throws:
        java.lang.NullPointerException - if the key is null
        Since:
        3.0
        See Also:
        ResourceKit.registerFontFamily(java.lang.String)
      • storeWindowSettings

        public final void storeWindowSettings​(java.lang.String prefix,
                                              java.awt.Window window)
        Saves the position of a window for later recall by writing it as a group of settings. The prefix is a unique prefix for that window. To restore the position later, call applyWindowSettings(java.lang.String, java.awt.Window) using the same prefix. Usually used with user settings.
        Parameters:
        prefix - a unique name for the window
        window - the window whose shape should be written into settings
      • applyWindowSettings

        public final boolean applyWindowSettings​(java.lang.String prefix,
                                                 java.awt.Window window)
        Restores the position and size of a window from the last time its settings were stored in this settings object.
        Parameters:
        prefix - the unique prefix chosen for this window when it was stored
        window - the window to be restored
        Returns:
        true if there were settings to restore; otherwise you should use a default placement algorithm to place the window
      • toString

        public java.lang.String toString()
        Returns a string that describes this settings instance.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a description of the settings scope
      • addPropertyChangeListener

        public final void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Adds a property change listener for this scope. The listener will be notified when any key's value changes at this scope. The name of the property specified by the event is the name of the key that is changing. Changes made in parent scopes will not fire an event, but you may also add listeners to each of the parent scopes.
        Parameters:
        listener - the listener to call when a key's value changes
        Since:
        2.1
      • removePropertyChangeListener

        public final void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Removes a listener that was previously added to this Settings.
        Parameters:
        listener - the listener to remove
        Since:
        2.1
      • isSerializedParent

        protected boolean isSerializedParent()