Class OptionBase<T>

  • Type Parameters:
    T - The type of the property of the OptionBase value
    All Implemented Interfaces:
    Option<T>
    Direct Known Subclasses:
    DefaultOption

    public abstract class OptionBase<T>
    extends Object
    implements Option<T>
    A wrapper interface for a single option to be displayed in a SettingsPane control.

    Typically it contains:

    • An optional graphic icon on the left
    • A caption
    • By default, an editor for viewing and modifying the Property associated to this Option

    But this can be modified:

    Since:
    2.0.0
    • Property Detail

      • value

        public abstract Property<T> valueProperty
        Returns the underlying Property, where one exists, that the editor can monitor for changes.
        Specified by:
        valueProperty in interface Option<T>
      • id

        public final StringProperty idProperty
        The id of this Option. This simple string identifier is useful for finding a specific Option within the scene graph. While the id of a Option should be unique within the scene graph, this uniqueness is not enforced. This is analogous to the "id" attribute on an HTML element (CSS ID Specification).

        For example, if a Option is given the id of "myId", then the lookup method can be used to find this option as follows: scene.lookup("#myId");.

        Default value:
        null
        Since:
        4.2.0
        See Also:
        getId(), setId(String)
    • Constructor Detail

      • OptionBase

        protected OptionBase​(String caption)
        Creates an option instance, without graphic and without editor. Using the caption Option.SEPARATOR will create a Separator. Otherwise it will create an empty option
        Parameters:
        caption - a String, usually Option.SEPARATOR
      • OptionBase

        protected OptionBase​(String caption,
                             String description,
                             String category)
        Creates an option instance, without graphic and without editor, intended to open a new view with a new group of sub-options, that are set calling Option.getChildren()
        Parameters:
        caption - a String a short name
        description - a String more descriptive
        category - a String indicating the category, in case the option belongs to a group
      • OptionBase

        protected OptionBase​(Node graphic,
                             String caption,
                             String description,
                             String category)
        Creates an option instance, with graphic and without editor, intended to open a new view with a new group of sub-options, that are set calling Option.getChildren()
        Parameters:
        graphic - a Node with a graphic
        caption - a String a short name
        description - a String more descriptive
        category - a String indicating the category, in case the option belongs to a group
      • OptionBase

        protected OptionBase​(String caption,
                             String description,
                             String category,
                             Property<T> value,
                             boolean isEditable)
        Creates an option instance, without graphic and with default editor, based on the values set for the option
        Parameters:
        caption - a String a short name
        description - a String more descriptive
        category - a String indicating the category, in case the option belongs to a group
        value - the underlying Property that the editor can monitor for changes
        isEditable - if the option is editable or read-only
      • OptionBase

        protected OptionBase​(String caption,
                             String description,
                             String category,
                             Property<T> value,
                             boolean isEditable,
                             Function<Option<T>,​OptionEditor<T>> editorFactory)
        Creates an option instance, without graphic and with custom editor, based on the values set for the option
        Parameters:
        caption - a String a short name
        description - a String more descriptive
        category - a String indicating the category, in case the option belongs to a group
        value - the underlying Property that the editor can monitor for changes
        isEditable - if the option is editable or read-only
        editorFactory - a Function that returns a valid OptionEditor for editing this Option
      • OptionBase

        protected OptionBase​(Node graphic,
                             String caption,
                             String description,
                             String category,
                             Property<T> value,
                             boolean isEditable)
        Creates an option instance, with graphic and with default editor, based on the values set for the option
        Parameters:
        graphic - a Node with a graphic
        caption - a String a short name
        description - a String more descriptive
        category - a String indicating the category, in case the option belongs to a group
        value - the underlying Property that the editor can monitor for changes
        isEditable - if the option is editable or read-only
      • OptionBase

        protected OptionBase​(Node graphic,
                             String caption,
                             String description,
                             String category,
                             Property<T> value,
                             boolean isEditable,
                             Function<Option<T>,​OptionEditor<T>> editorFactory)
        Creates an option instance, with graphic and with custom editor, based on the values set for the option
        Parameters:
        graphic - a Node with a graphic
        caption - a String a short name
        description - a String more descriptive
        category - a String indicating the category, in case the option belongs to a group
        value - the underlying Property that the editor can monitor for changes
        isEditable - if the option is editable or read-only
        editorFactory - a Function that returns a valid OptionEditor for editing this Option
    • Method Detail

      • getGraphic

        public Optional<Node> getGraphic()
        Returns an Optional with the node that will be displayed as a graphic on the left side of the option if not empty
        Specified by:
        getGraphic in interface Option<T>
        Returns:
        Optional with a Node if not empty
      • getCaption

        public String getCaption()
        Returns the display name of the property associated to the Option or the name associated to the group of options. It should be short (i.e. less than two words). This is used to explain to the end user what the option represents.
        Specified by:
        getCaption in interface Option<T>
        Returns:
        String with the name or caption of the Option
      • setExtendedDescription

        public void setExtendedDescription​(String value)
        Sets the long String description that will be shown to the user in an extended View
        Parameters:
        value - a String with a long description
      • getCategory

        public String getCategory()
        Returns a String representation of the category of the property. This is relevant when properties with the same category can be grouped together visually.
        Specified by:
        getCategory in interface Option<T>
        Returns:
        String with the category of the Option
      • valueProperty

        public abstract Property<T> valueProperty()
        Returns the underlying Property, where one exists, that the editor can monitor for changes.
        Specified by:
        valueProperty in interface Option<T>
      • isEditable

        public boolean isEditable()
        Indicates whether the SettingsPane control should allow editing this option, or whether it is read-only.
        Specified by:
        isEditable in interface Option<T>
        Returns:
        boolean if the control is editable or not
      • valueProperty

        public static <T> Property<T> valueProperty​(T value)
        Allows wrapping primitives into a read-only Property
        Type Parameters:
        T - The primitive type
        Parameters:
        value - The value to be set
        Returns:
        the wrapper read-only Property
      • setLayout

        public void setLayout​(Orientation layout)
        Defines the type of layout to apply to the Option
        Parameters:
        layout - the Orientation type
      • idProperty

        public final StringProperty idProperty()
        The id of this Option. This simple string identifier is useful for finding a specific Option within the scene graph. While the id of a Option should be unique within the scene graph, this uniqueness is not enforced. This is analogous to the "id" attribute on an HTML element (CSS ID Specification).

        For example, if a Option is given the id of "myId", then the lookup method can be used to find this option as follows: scene.lookup("#myId");.

        Default value:
        null
        Since:
        4.2.0
        See Also:
        getId(), setId(String)
      • setId

        public final void setId​(String id)
        Sets the value of the property id.
        Property description:
        The id of this Option. This simple string identifier is useful for finding a specific Option within the scene graph. While the id of a Option should be unique within the scene graph, this uniqueness is not enforced. This is analogous to the "id" attribute on an HTML element (CSS ID Specification).

        For example, if a Option is given the id of "myId", then the lookup method can be used to find this option as follows: scene.lookup("#myId");.

        Default value:
        null
        Since:
        4.2.0
      • getId

        public final String getId()
        Gets the value of the property id.
        Property description:
        The id of this Option. This simple string identifier is useful for finding a specific Option within the scene graph. While the id of a Option should be unique within the scene graph, this uniqueness is not enforced. This is analogous to the "id" attribute on an HTML element (CSS ID Specification).

        For example, if a Option is given the id of "myId", then the lookup method can be used to find this option as follows: scene.lookup("#myId");.

        Default value:
        null
        Since:
        4.2.0