Class 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.
    • Constructor Detail

      • 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 method Options.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

      • 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<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 of Options.Option.getValueAsString(Object) .

        Specified by:
        getValueFromString in class Options.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 class Options.Option<java.lang.String,​javax.swing.JLabel>
        Parameters:
        component - a component return from Options.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 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<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 - if setCenterText(boolean) or setIcon(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 - if setSelectable(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 - if setSelectable(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 class Options.Option<java.lang.String,​javax.swing.JLabel>
        Parameters:
        visible - whether or not the graphical component that displays this option should be visible.
      • 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 class Options.Option<java.lang.String,​javax.swing.JLabel>
        Parameters:
        component - the component to set the enabled state of
        enabled - true if it should be enabled