Class Options.DoubleOption
- java.lang.Object
-
- com.biomatters.geneious.publicapi.plugin.Options.Option<T,javax.swing.JSpinner>
-
- com.biomatters.geneious.publicapi.plugin.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.biomatters.geneious.publicapi.documents.XMLSerializable
XMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportType
-
-
Field Summary
-
Fields inherited from interface com.biomatters.geneious.publicapi.documents.XMLSerializable
ROOT_ELEMENT_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DoubleOption(java.lang.String name, java.lang.String label, java.lang.Double defaultValue)
Construct a new Double optionprotected
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 optionprotected
DoubleOption(org.jdom.Element element)
Constructor for XML Serialization.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.swing.JSpinner
createComponent()
Create a graphical component representing this option.protected java.lang.Double
generateValidValue(java.lang.Double candidateValue)
Clamps the value to the permissible range.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.T
getMaximum()
T
getMinimum()
protected java.lang.String
getNormalizedStringValue(java.lang.String value)
For options that may have multiple valid string representations of the same value, this method returns the normalized (canonical) representation of a value.java.lang.String
getPossibleValues()
Provide a descriptive string representation of possible values of this option.javax.swing.JComponent
getUnitComponent()
java.lang.String
getUnits()
If this option represents a value that has units, this is the string representing the units (eg lb or kg).java.lang.Double
getValueFromString(java.lang.String value)
Convert a String into an instance of the object type used by this option.protected void
handleSetEnabled(javax.swing.JSpinner component, boolean enabled)
Set the enabled state of a component.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.void
setMaximum(T maximum)
Changes the maximum value this Option may have.void
setMinimum(T minimum)
Changes the minimum value this Option may have.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.protected void
setValueOnComponent(javax.swing.JSpinner spinner, T value)
Set the value on this component.void
setVisible(boolean visible)
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.org.jdom.Element
toXML()
Convert object to a JDOM element.-
Methods inherited from class com.biomatters.geneious.publicapi.plugin.Options.Option
addChangeListener, addChildOptionsDependent, addDependent, addDependentIfNot, addLayoutDependent, fromXML, getComponent, getComponentWithUnitsAndHelpButton, getDefaultValue, getDependents, getDependentsIfNot, getDescription, getDescriptionAndState, getDisplayedLabel, getExtraPersistentInformation, getHelp, getLabel, getName, getParentOptions, getValue, getValueAsString, getValueAsString, getVerticalWeight, hasComponentBeenCreated, hideWarningMessage, isAdvanced, isAlwaysUsesDefaultPreferenceLocation, isEnabled, isFillHorizontalSpace, isProOnly, isRestoreDefaultApplies, isRestorePreferenceApplies, isSpanningComponent, isVisible, moveToOptions, removeChangeListener, restoreDefault, setAdvanced, setAlwaysUsesDefaultPreferenceLocation, setDefaultValue, setDescription, setDisabledValue, setEnabled, setExtraPersistentInformation, setFillHorizontalSpace, setHelp, setHidden, setHidden, setLabelComponent, setPreferredHeight, setPreferredWidth, setProOnly, setRestoreDefaultApplies, setRestorePreferenceApplies, setShouldSaveValue, setSpanningComponent, setValue, setValue, setValueFromString, setVerticalWeight, setWarningMessage, shouldSaveValue, toString
-
-
-
-
Constructor Detail
-
DoubleOption
protected DoubleOption(org.jdom.Element element) throws XMLSerializationException
Constructor for XML Serialization. SeeXMLSerializable
- Throws:
XMLSerializationException
-
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 optionminimum
- The minimum value that the option can havemaximum
- 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 ofOptions.Option.getValueAsString(Object)
.- Specified by:
getValueFromString
in classOptions.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 classOptions.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 provideOptions.ComboBoxOrRadioOption.getPossibleOptionValues()
to get possible values as a List of OptionValues.- Overrides:
getPossibleValues
in classOptions.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 classOptions.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 thatXMLSerializable.fromXML(org.jdom.Element)
can completely restore the object's representation. It is recommended that the returned element useXMLSerializable.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 callXMLSerializer.classToXML(String, XMLSerializable)
which calls this method internally. PluginDocument implementations of this method may choose to throw anXMLSerializationException
, enclosed in aRuntimeException
.- Specified by:
toXML
in interfaceXMLSerializable
- Overrides:
toXML
in classOptions.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 fromgetUnits()
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 classOptions.Option<T extends java.lang.Number,javax.swing.JSpinner>
- Parameters:
component
- the component to set the enabled state ofenabled
- 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 classOptions.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 ofOptions.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 theOptions.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 classOptions.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 classOptions.Option<T extends java.lang.Number,javax.swing.JSpinner>
- Parameters:
spinner
- a component return fromOptions.Option.createComponent()
value
- the value to set.
-
-