Class Options.IntegerOption

  • All Implemented Interfaces:
    XMLSerializable
    Enclosing class:
    Options

    public static class Options.IntegerOption
    extends Options.Option<T,​javax.swing.JSpinner>
    An option that stores an Integer and is displayed graphically to the user as a single line text field with a spinner (up and down arrow) on the right-hand side. Usually an IntegerOption is added to Options using Options.addIntegerOption.
    • Constructor Detail

      • IntegerOption

        protected IntegerOption​(java.lang.String name,
                                java.lang.String label,
                                java.lang.Integer defaultValue,
                                int minimum,
                                int maximum)
        Construct a new Integer option
        Parameters:
        name - the name to be used for referencing this option. For example from scripts or source code which wish to programmatically get or set the value of this option. Names should be in standard Java variable name style eg. "myAwesomeOption".
        label - a label describing this option to be displayed to the user. eg. "My Awesome Option"
        defaultValue - the default value for this option
        minimum - The minimum value that the option can have
        maximum - The maximum value that the option can have
      • IntegerOption

        protected IntegerOption​(java.lang.String name,
                                java.lang.String label,
                                java.lang.Integer defaultValue)
        Construct a new Integer option
        Parameters:
        name - the name to be used for referencing this option. For example from scripts or source code which wish to programmatically get or set the value of this option. Names should be in standard Java variable name style eg. "myAwesomeOption".
        label - a label describing this option to be displayed to the user. eg. "My Awesome Option"
        defaultValue - the default value for this option
    • Method Detail

      • generateValidValue

        protected java.lang.Integer generateValidValue​(java.lang.Integer candidateValue)
        Clamps the value to the permissible range.
        Overrides:
        generateValidValue in class Options.Option<java.lang.Integer,​javax.swing.JSpinner>
        Parameters:
        candidateValue - the value to determine the validity of
        Returns:
        CandidateValue clamped to the range permitted in the constructor.
      • getValueFromString

        public java.lang.Integer getValueFromString​(java.lang.String value)
        Description copied from class: Options.Option
        Convert a String into an instance of the object type used by this option. This method should generally create a new object every time it is invoked. Only disregard this advice if you know what you are doing - e.g. it is safe to maintain an object pool and return the same object more than once if your Option's ValueType is immutable.

        This method is the inverse of Options.Option.getValueAsString(Object) .

        Specified by:
        getValueFromString in class Options.Option<java.lang.Integer,​javax.swing.JSpinner>
        Parameters:
        value - the string representation of the object value
        Returns:
        the object value or the default value if the string representation is not valid.
      • getPossibleValues

        public java.lang.String getPossibleValues()
        Description copied from class: Options.Option
        Provide a descriptive string representation of possible values of this option. For example, combo box and radio options should provide a list of all available values. The default implementation returns null. Radio and ComboBox options provide Options.ComboBoxOrRadioOption.getPossibleOptionValues() to get possible values as a List of OptionValues.
        Overrides:
        getPossibleValues in class Options.Option<java.lang.Integer,​javax.swing.JSpinner>
        Returns:
        a descriptive string representation of possible values of this option or null if this option may have any String value.
        See Also:
        Options.ComboBoxOrRadioOption.getPossibleOptionValues()
      • setPreferredWidthForNumberOfDigits

        public void setPreferredWidthForNumberOfDigits​(int numberOfDigits)
        Calls Options.Option.setPreferredWidth(int) with an appropriate width to accommodate approximately the specified number of digits
        Parameters:
        numberOfDigits - the approximate number of digits to hold at the preferred width
        Since:
        API 4.900 (Geneious 9.0.0)
      • toXML

        public org.jdom.Element toXML()
        Description copied from interface: XMLSerializable
        Convert object to a JDOM element. The representation should be complete so that XMLSerializable.fromXML(org.jdom.Element) can completely restore the object's representation.

        It is recommended that the returned element use XMLSerializable.ROOT_ELEMENT_NAME as its name, in which case it must not define an attribute called "type". In this case, fromXML, will be called with an element whose name may differ from the element return from this function. This recommendation allows a more compact representation of the XML can be stored.

        This method generally should not be called directly. Instead, you should usually call XMLSerializer.classToXML(String, XMLSerializable) which calls this method internally.

        PluginDocument implementations of this method may choose to throw an XMLSerializationException, enclosed in a RuntimeException.

        Specified by:
        toXML in interface XMLSerializable
        Overrides:
        toXML in class Options.Option<T extends java.lang.Number,​javax.swing.JSpinner>
        Returns:
        object encoded as a JDOM element
      • getMinimum

        public final T getMinimum()
      • getMaximum

        public final T getMaximum()
      • setMaximum

        public void setMaximum​(T maximum)
        Changes the maximum value this Option may have. The current value will be automatically clipped to a valid value
        Parameters:
        maximum - the new maximum value.
        Since:
        API 4.900 (Geneious 9.0.0)
      • setMinimum

        public void setMinimum​(T minimum)
        Changes the minimum value this Option may have. The current value will be automatically clipped to a valid value
        Parameters:
        minimum - the new minimum value.
        Since:
        API 4.900 (Geneious 9.0.0)
      • getUnits

        public java.lang.String getUnits()
        If this option represents a value that has units, this is the string representing the units (eg lb or kg). It will appear after the spinner component in the options panel.
        Returns:
        a string representing the units of this option's values. Will not be null.
      • setUnits

        public void setUnits​(java.lang.String units)
        If this option represents a value that has units, set the string representing the units (eg lb or kg) here. It will appear after the spinner component in the options panel. You can only set this value before the options panel has been displayed.
        Parameters:
        units - a string representing the units of this option's values. May be null (but will not be returned from getUnits() as null).
      • handleSetEnabled

        protected void handleSetEnabled​(javax.swing.JSpinner component,
                                        boolean enabled)
        Description copied from class: Options.Option
        Set the enabled state of a component. A sub-class need only override this if it needs to do something more complicated than calling setEnabled on this component
        Overrides:
        handleSetEnabled in class Options.Option<T extends java.lang.Number,​javax.swing.JSpinner>
        Parameters:
        component - the component to set the enabled state of
        enabled - true if it should be enabled
      • setVisible

        public void setVisible​(boolean visible)
        Description copied from class: Options.Option
        Sets the visibility of the graphical component that displays this option together with its label and makes appropriate changes to the size of the window (if any) that contains the graphical component.
        Overrides:
        setVisible in class Options.Option<T extends java.lang.Number,​javax.swing.JSpinner>
        Parameters:
        visible - whether or not the graphical component that displays this option should be visible.
      • setIncrement

        public void setIncrement​(T increment)
        Sets the amount the value of this option changes by when the user clicks the little up/down arrows to the right of it.
        Parameters:
        increment - the amount the value of this option changes by when the user clicks the little up/down arrows to the right of it.
      • getIncrement

        public T getIncrement()
        Gets the amount the value of this option changes by when the user clicks the little up/down arrows to the right of it.
        Returns:
        the amount the value of this option changes by when the user clicks the little up/down arrows to the right of it.
      • createComponent

        protected javax.swing.JSpinner createComponent()
        Description copied from class: Options.Option
        Create a graphical component representing this option. The implementation is responsible for making sure that the returned component is initialised to the current value of Options.Option.getValue(). The implementation is also responsible for making sure that the returned component listens to any changes made to itself and reflects those changes in the value of this option using the Options.Option.setValue(Object) method. This method will only be called once for each instance of an Option. After it has been called, getComponent() will return a cached copy of it.
        Specified by:
        createComponent in class Options.Option<T extends java.lang.Number,​javax.swing.JSpinner>
        Returns:
        a graphical component representing this option. May not be null.
      • getUnitComponent

        public javax.swing.JComponent getUnitComponent()
        Returns:
        a component that contains both the spinner and its associated units component {see setUnits(String)) if applicable.
      • setValueOnComponent

        protected void setValueOnComponent​(javax.swing.JSpinner spinner,
                                           T value)
        Description copied from class: Options.Option
        Set the value on this component.
        Specified by:
        setValueOnComponent in class Options.Option<T extends java.lang.Number,​javax.swing.JSpinner>
        Parameters:
        spinner - a component return from Options.Option.createComponent()
        value - the value to set.