Class Options.DoubleOption

  • All Implemented Interfaces:
    XMLSerializable
    Enclosing class:
    Options

    public static class Options.DoubleOption
    extends Options.Option<T,​javax.swing.JSpinner>
    An option that stores an Double 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
    • Constructor Detail

      • DoubleOption

        protected DoubleOption​(java.lang.String name,
                               java.lang.String label,
                               java.lang.Double defaultValue)
        Construct a new Double 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.
        label - a label describing this option to be displayed to the user. eg. "My Awesome Option"
        defaultValue - the default value for this option
      • DoubleOption

        protected DoubleOption​(java.lang.String name,
                               java.lang.String label,
                               java.lang.Double defaultValue,
                               java.lang.Double minimum,
                               java.lang.Double maximum)
        Construct a new Double 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.
        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
    • Method Detail

      • getValueFromString

        public java.lang.Double 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.Double,​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.
      • generateValidValue

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

        protected java.lang.String getNormalizedStringValue​(java.lang.String value)
        Description copied from class: Options.Option
        For options that may have multiple valid string representations of the same value, this method returns the normalized (canonical) representation of a value. For example a DoubleOption, "3" may also be represented as "3.0".
        Overrides:
        getNormalizedStringValue in class Options.Option<java.lang.Double,​javax.swing.JSpinner>
        Parameters:
        value - the value to get the normalized representation of.
        Returns:
        the normalized (canonical) representation of value or value if value is not a valid value for this option. The default implementation returns value.
      • 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.