Class Options.RadioOption<ValueType extends Options.OptionValue>

  • All Implemented Interfaces:
    XMLSerializable
    Enclosing class:
    Options

    public static class Options.RadioOption<ValueType extends Options.OptionValue>
    extends Options.Option<ValueType,​ComponentType>
    An option that provides the user with a list of radio buttons to select one of
    • Constructor Detail

      • RadioOption

        protected RadioOption​(org.jdom.Element e)
                       throws XMLSerializationException
        Constructor for XML Serialization. See XMLSerializable
        Parameters:
        e - The JDOM Element from which the constructed object should be initialised.
        Throws:
        XMLSerializationException - if such an exception occurs while initialising the element from XML
      • RadioOption

        protected RadioOption​(java.lang.String name,
                              java.lang.String label,
                              ValueType[] possibleValues,
                              ValueType defaultValue,
                              Options.Alignment alignment)
        Construct a new Radio option. This is a list of options that are provided to the user graphically as a set of radio buttons
        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"
        possibleValues - An array containing all possible values (i.e. all the radio button names)
        defaultValue - the default value for this option, not null
        alignment - the alignment of the radio buttons (horizontally or vertically)
    • Method Detail

      • getAlignment

        public Options.Alignment getAlignment()
        Returns:
        the alignment parameter passed to the constructor which specifies whether the radio options should be horizontally or vertically aligned
        Since:
        API 4.202000 (Geneious 2020.0.0)
      • 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<ValueType extends Options.OptionValue,​javax.swing.JPanel>
        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()
      • getValueFromString

        public ValueType 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<ValueType extends Options.OptionValue,​javax.swing.JPanel>
        Parameters:
        value - the string representation of the object value
        Returns:
        the object value or the default value if the string representation is not valid.
      • moveToOptions

        public boolean moveToOptions​(Options newParentOptions,
                                     java.lang.String optionalNewLabel,
                                     java.lang.String optionalNewName)
        Description copied from class: Options.Option
        Moves this Option from its current parent Options to another parent Options. Any option dependencies will be removed.

        The original parent Options should no longer be used after the move and may be left in an inconsistent state.

        Options that have already had its component constructed cannot be moved - they will return false

        Overrides:
        moveToOptions in class Options.Option<ValueType extends Options.OptionValue,​javax.swing.JPanel>
        Parameters:
        newParentOptions - the Options to move this Option to
        optionalNewLabel - a new label (see Options.Option.getLabel()) to assign to this Option or null to leave it unchanged.
        optionalNewName - a new name (see Options.Option.getName() ()})to assign to this Option or null to leave it unchanged.
        Returns:
        true if this option was successfully moved.
      • createComponent

        protected javax.swing.JPanel 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<ValueType extends Options.OptionValue,​javax.swing.JPanel>
        Returns:
        a graphical component representing this option. May not be null.
      • generateValidValue

        protected ValueType generateValidValue​(ValueType value)
        Description copied from class: Options.Option
        Converts a potentially invalid value into a valid one. The default implementation always returns candidateValue, implying that all values are valid. Subclasses can override this method e.g. to clamp integer values to a certain interval, or to ensure that a disabled radio item cannot be selected. If a new value is determined to be invalid, a subclass may choose to return the current value (Options.Option.getValue() or any arbitrary other value. IMPORTANT: subclasses which implement this method should call Options.Option.setDefaultValue(Object) at the end of their constructor(s)
        Overrides:
        generateValidValue in class Options.Option<ValueType extends Options.OptionValue,​javax.swing.JPanel>
        Parameters:
        value - the value to determine the validity of
        Returns:
        an allowed value.
      • handleSetEnabled

        protected void handleSetEnabled​(javax.swing.JPanel panel,
                                        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<ValueType extends Options.OptionValue,​javax.swing.JPanel>
        Parameters:
        panel - the component to set the enabled state of
        enabled - true if it should be enabled
      • getRadioButtons

        public final java.util.List<javax.swing.AbstractButton> getRadioButtons()
        Get the list of buttons for this radio option. These can be layed out in a new panel.
        Returns:
        list of radio buttons
      • addDependent

        public void addDependent​(ValueType optionValue,
                                 Options.Option dependent,
                                 boolean layoutDependentNearRadioButton)
        Adds a dependent option that will be enabled when the radio button associated with the OptionValue is selected, and disabled when it is not. Optionally (by setting layoutDependentNearRadioButton to true), the component for the dependent can appear immediately under the radio button associated with the given OptionValue in any panel returned by this RadioOption. Use setDependentPosition(com.biomatters.geneious.publicapi.plugin.Options.RadioOption.DependentPosition) to specify the exact dependent positioning in this case. To just layout the component next to this option value without changing its enabled state, use addLayoutDependent(OptionValue, Option)
        Parameters:
        optionValue - The OptionValue that will be the parent of the dependent Option
        dependent - the option whose enabled state (and optionally its position) will change
        layoutDependentNearRadioButton - make the component for the dependent can appear immediately under or to the right (see setDependentPosition) of the radio button associated with the given OptionValue in any panel returned by this RadioOption. Using false for this parameter means that only the enabled state of the dependent is affected.
      • addDependent

        public void addDependent​(ValueType optionValue,
                                 Options dependentOptions,
                                 boolean layoutDependentNearRadioButton)
        Adds a dependent option that will be enabled when the radio button associated with the OptionValue is selected, and disabled when it is not. Optionally (by setting layoutDependentNearRadioButton to true), the component for the dependent can appear immediately under the radio button associated with the given OptionValue in any panel returned by this RadioOption. Use setDependentPosition(com.biomatters.geneious.publicapi.plugin.Options.RadioOption.DependentPosition) to specify the exact dependent positioning in this case.
        Parameters:
        optionValue - The OptionValue that will be the parent of the dependent Option
        dependentOptions - the option whose enabled state (and optionally its position) will change
        layoutDependentNearRadioButton - make the component for the dependent can appear immediately under or to the right (see setDependentPosition) of the radio button associated with the given OptionValue in any panel returned by this RadioOption. Using false for this parameter means that only the enabled state of the dependent is affected.