Class ToolOptions

  • All Implemented Interfaces:
    Options

    public class ToolOptions
    extends AbstractOptions
    Class to manage a set of option name/value pairs for a category. The values may be primitives or WrappedObjects that are containers for its primitive components. The option may be associated with a particular group.

    The name/value pair has a owner so that the option name can be removed from the Options object when it is no longer being used.

    NOTE: Property Names can have DELIMITER characters to create a hierarchy. The Options Dialog shows the hierarchy in tree format.

    • Field Detail

      • PRIMITIVE_CLASSES

        public static final java.util.Set<java.lang.Class<?>> PRIMITIVE_CLASSES
      • WRAPPABLE_CLASSES

        public static final java.util.Set<java.lang.Class<?>> WRAPPABLE_CLASSES
      • XML_ELEMENT_NAME

        public static final java.lang.String XML_ELEMENT_NAME
        See Also:
        Constant Field Values
    • Constructor Detail

      • ToolOptions

        public ToolOptions​(java.lang.String name)
      • ToolOptions

        public ToolOptions​(org.jdom.Element root)
        Construct a new Options object from the given XML element.
        Parameters:
        root - XML that contains the set of options to restore
    • Method Detail

      • getXmlRoot

        public org.jdom.Element getXmlRoot​(boolean includeDefaultBindings)
        Return an XML element for the option names and values. Note: only those options which have been explicitly set will be included.
        Parameters:
        includeDefaultBindings - true to include default key binding values in the xml
        Returns:
        the xml root element
      • addOptionsChangeListener

        public void addOptionsChangeListener​(OptionsChangeListener l)
        Add the options change listener. NOTE: The Options uses WeakReferences to manage the listeners; this means that you must supply a listener and maintain a handle to it, or else the listener will be garbage collected and will never get called. So for this reason, do not create the listener in an anonymous inner class.
        Parameters:
        l - listener to add
      • takeListeners

        public void takeListeners​(ToolOptions oldOptions)
      • removeOptionsChangeListener

        public void removeOptionsChangeListener​(OptionsChangeListener l)
        Remove the options change listener.
        Parameters:
        l - listener to remove
      • removeUnusedOptions

        public void removeUnusedOptions()
        Check each option to ensure that an owner is still registered for it; if there is no owner, then remove the option.
      • copyOptions

        public void copyOptions​(Options newOptions)
        Adds all the options name/value pairs to this Options.
        Parameters:
        newOptions - the new options into which the current options values will be placed
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • validateOptions

        public void validateOptions()
      • registerOptions

        public void registerOptions​(ToolOptions oldOptions)
      • notifyOptionChanged

        protected boolean notifyOptionChanged​(java.lang.String optionName,
                                              java.lang.Object oldValue,
                                              java.lang.Object newValue)
        Specified by:
        notifyOptionChanged in class AbstractOptions