Class EnumVariableValue

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.beans.PropertyChangeListener, java.util.EventListener
    Direct Known Subclasses:
    CompositeVariableValue

    public class EnumVariableValue
    extends VariableValue
    implements java.awt.event.ActionListener
    Extends VariableValue to represent an enumerated variable.
    See Also:
    VariableValue
    • Constructor Detail

      • EnumVariableValue

        public EnumVariableValue​(java.lang.String name,
                                 java.lang.String comment,
                                 java.lang.String cvName,
                                 boolean readOnly,
                                 boolean infoOnly,
                                 boolean writeOnly,
                                 boolean opsOnly,
                                 java.lang.String cvNum,
                                 java.lang.String mask,
                                 int minVal,
                                 int maxVal,
                                 java.util.HashMap<java.lang.String,​CvValue> v,
                                 javax.swing.JLabel status,
                                 java.lang.String stdname)
      • EnumVariableValue

        public EnumVariableValue()
        Create a null object. Normally only used for tests and to pre-load classes.
    • Method Detail

      • nItems

        public void nItems​(int n)
      • addItem

        public void addItem​(java.lang.String s)
        Create a new item in the enumeration, with an associated value one more than the last item (or zero if this is the first one added)
        Parameters:
        s - Name of the enumeration item
      • addItem

        public void addItem​(java.lang.String s,
                            int value)
        Create a new item in the enumeration, with a specified associated value.
        Parameters:
        s - Name of the enumeration item
        value - item value.
      • startGroup

        public void startGroup​(java.lang.String name)
      • setAvailable

        public void setAvailable​(boolean a)
        Description copied from class: AbstractValue
        Sets the availability status of the object.
        Overrides:
        setAvailable in class AbstractValue
        Parameters:
        a - true if the object should be made available, false if should be made unavailable
      • rangeVal

        public java.lang.Object rangeVal()
        Description copied from class: VariableValue
        Gets a (usually text) description of the variable type and range.
        Specified by:
        rangeVal in class VariableValue
        Returns:
        description of the variable type and range
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • setIntValue

        public void setIntValue​(int i)
        Description copied from class: VariableValue
        Set the value from a single number.

        In some cases, e.g. speed tables, this will result in complex behavior, where setIntValue(getIntValue()) results in something unexpected.

        Specified by:
        setIntValue in class VariableValue
        Parameters:
        i - the integer value to set
      • selectValue

        protected void selectValue​(int value)
        Set to a specific value.

        This searches for the displayed value, and sets the enum to that particular one. It used to work off an index, but now it looks for the value.

        If the value is larger than any defined, a new one is created.

        Parameters:
        value - What to set to.
      • getIntValue

        public int getIntValue()
        Description copied from class: VariableValue
        Get the value as a single integer.

        In some cases, e.g. speed tables, this will result in complex behavior, where setIntValue(getIntValue()) results in something unexpected.

        Specified by:
        getIntValue in class VariableValue
        Returns:
        the value as an integer
      • getCommonRep

        public java.awt.Component getCommonRep()
        Description copied from class: VariableValue
        Get a display representation Object of this variable.

        The actual stored value of a variable is not the most interesting thing. Instead, you usually get an Object representation for display in a table, etc. Modification of the state of that object then gets reflected back, causing the underlying CV objects to change.
        Specified by:
        getCommonRep in class VariableValue
        Returns:
        the Object representation for display purposes
      • setValue

        public void setValue​(int value)
      • getNewRep

        public java.awt.Component getNewRep​(java.lang.String format)
        Description copied from class: VariableValue
        Creates a new Object representation for display purposes, using the specified format.
        Specified by:
        getNewRep in class VariableValue
        Parameters:
        format - a name representing
        Returns:
        an Object representation for display purposes
      • setColor

        void setColor​(java.awt.Color c)
        Description copied from class: AbstractValue
        Method to handle color changes for states.
        Specified by:
        setColor in class AbstractValue
        Parameters:
        c - the desired colour
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent e)
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
        Specified by:
        propertyChange in class VariableValue