Class Options.LabelOption
- java.lang.Object
-
- com.biomatters.geneious.publicapi.plugin.Options.Option<java.lang.String,javax.swing.JLabel>
-
- com.biomatters.geneious.publicapi.plugin.Options.LabelOption
-
- All Implemented Interfaces:
XMLSerializable
- Enclosing class:
- Options
public static class Options.LabelOption extends Options.Option<java.lang.String,javax.swing.JLabel>
An option that is only used for display purposes. It displays a label.
-
-
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 LabelOption(java.lang.String name, java.lang.String label)
Constructs a LabelOption.protected
LabelOption(org.jdom.Element element)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.swing.JLabel
createComponent()
Create a graphical component representing this option.javax.swing.Icon
getIcon()
Returns the currently set icon, or null if none is set.java.lang.String
getValueFromString(java.lang.String value)
Convert a String into an instance of the object type used by this option.protected void
handleSetEnabled(javax.swing.JLabel component, boolean enabled)
Set the enabled state of a component.boolean
isCenterText()
Returns true if the label text will be drawn centeredboolean
isRestorePreferenceApplies()
Returns true if callingOptions.restorePreferences()
should restore this setting to its value saved in preferences, andOptions.Option.shouldSaveValue()
returns trueboolean
isSelectable()
boolean
isVisibleOnlyWhenEnabled()
Returns true if the component for this option will only be visible if the option is enabled.void
setCenterText(boolean centerText)
Whether to draw the label text centeredvoid
setIcon(javax.swing.Icon icon)
Sets an icon that will be displayed to the left of the label.void
setSelectable(boolean selectable)
Sets whether or not the text in this label is selectable by the user.protected void
setValueOnComponent(javax.swing.JLabel component, java.lang.String 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.void
setVisibleOnlyWhenEnabled(boolean visibleOnlyWhenEnabled)
If true, then callingOptions.Option.setEnabled(boolean)
will additionally have the effect of callingsetVisible(boolean)
boolean
shouldSaveValue()
If this method returns false, then the option will not save its value to preferences, nor will it save its value when you callOptions.valuesToXML(String)
on its parent options.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, generateValidValue, getComponent, getComponentWithUnitsAndHelpButton, getDefaultValue, getDependents, getDependentsIfNot, getDescription, getDescriptionAndState, getDisplayedLabel, getExtraPersistentInformation, getHelp, getLabel, getName, getNormalizedStringValue, getParentOptions, getPossibleValues, getValue, getValueAsString, getValueAsString, getVerticalWeight, hasComponentBeenCreated, hideWarningMessage, isAdvanced, isAlwaysUsesDefaultPreferenceLocation, isEnabled, isFillHorizontalSpace, isProOnly, isRestoreDefaultApplies, 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, toString
-
-
-
-
Constructor Detail
-
LabelOption
protected LabelOption(org.jdom.Element element) throws XMLSerializationException
- Throws:
XMLSerializationException
-
LabelOption
public LabelOption(java.lang.String name, java.lang.String label)
Constructs a LabelOption. Note that the parameter 'name' is automatically assigned when you use the methodOptions.addLabel(String)
- 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
- The label that this option will take
-
-
Method Detail
-
isRestorePreferenceApplies
public boolean isRestorePreferenceApplies()
Description copied from class:Options.Option
Returns true if callingOptions.restorePreferences()
should restore this setting to its value saved in preferences, andOptions.Option.shouldSaveValue()
returns true- Overrides:
isRestorePreferenceApplies
in classOptions.Option<java.lang.String,javax.swing.JLabel>
- Returns:
- true if calling
Options.restorePreferences()
should restore this setting to its value saved in preferences, and()
returns true
-
shouldSaveValue
public boolean shouldSaveValue()
Description copied from class:Options.Option
If this method returns false, then the option will not save its value to preferences, nor will it save its value when you callOptions.valuesToXML(String)
on its parent options.- Overrides:
shouldSaveValue
in classOptions.Option<java.lang.String,javax.swing.JLabel>
- Returns:
- whether this option should save its values both to preferences, and
Options.valuesToXML(String)
- See Also:
Options.Option.isRestorePreferenceApplies()
-
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<java.lang.String,javax.swing.JLabel>
- Returns:
- object encoded as a JDOM element
-
getValueFromString
public java.lang.String 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.String,javax.swing.JLabel>
- Parameters:
value
- the string representation of the object value- Returns:
- the object value or the default value if the string representation is not valid.
-
setValueOnComponent
protected void setValueOnComponent(javax.swing.JLabel component, java.lang.String value)
Description copied from class:Options.Option
Set the value on this component.- Specified by:
setValueOnComponent
in classOptions.Option<java.lang.String,javax.swing.JLabel>
- Parameters:
component
- a component return fromOptions.Option.createComponent()
value
- the value to set.
-
createComponent
protected javax.swing.JLabel 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<java.lang.String,javax.swing.JLabel>
- Returns:
- a graphical component representing this option. May not be null.
-
isSelectable
public boolean isSelectable()
- Returns:
- true if the text in this label is selectable by the user.
- Since:
- API 4.700 (Geneious 7.0.0)
-
setSelectable
public void setSelectable(boolean selectable)
Sets whether or not the text in this label is selectable by the user. Additionally, the text will be treated as html and multiple html links within the label will be clickable.- Parameters:
selectable
- true for this label to be selectable by the user- Throws:
java.lang.IllegalStateException
- if this label has had its component instantiated already.java.lang.UnsupportedOperationException
- ifsetCenterText(boolean)
orsetIcon(javax.swing.Icon)
have been called on this label- Since:
- API 4.700 (Geneious 7.0.0)
-
setCenterText
public void setCenterText(boolean centerText)
Whether to draw the label text centered- Parameters:
centerText
- true if you want the label text to be drawn centered- Throws:
java.lang.UnsupportedOperationException
- ifsetSelectable(boolean)
has been called on this label
-
isCenterText
public boolean isCenterText()
Returns true if the label text will be drawn centered- Returns:
- true if the label text will be drawn centered
-
setIcon
public void setIcon(javax.swing.Icon icon)
Sets an icon that will be displayed to the left of the label. For example you could use this to set a warning icon on a label.- Parameters:
icon
- the icon to set- Throws:
java.lang.UnsupportedOperationException
- ifsetSelectable(boolean)
has been called on this label
-
getIcon
public javax.swing.Icon getIcon()
Returns the currently set icon, or null if none is set.- Returns:
- the currently set icon, or null if none is set.
-
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<java.lang.String,javax.swing.JLabel>
- Parameters:
visible
- whether or not the graphical component that displays this option should be visible.
-
setVisibleOnlyWhenEnabled
public void setVisibleOnlyWhenEnabled(boolean visibleOnlyWhenEnabled)
If true, then callingOptions.Option.setEnabled(boolean)
will additionally have the effect of callingsetVisible(boolean)
- Parameters:
visibleOnlyWhenEnabled
-
-
isVisibleOnlyWhenEnabled
public boolean isVisibleOnlyWhenEnabled()
Returns true if the component for this option will only be visible if the option is enabled.- Returns:
- true if the component for this option will only be visible if the option is enabled.
-
handleSetEnabled
protected void handleSetEnabled(javax.swing.JLabel 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<java.lang.String,javax.swing.JLabel>
- Parameters:
component
- the component to set the enabled state ofenabled
- true if it should be enabled
-
-