Class DecVariableValue

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

    public class DecVariableValue
    extends VariableValue
    implements java.awt.event.ActionListener, java.awt.event.FocusListener
    Decimal representation of a value.
    The mask attribute represents the part of the value that's present in the CV.
    Optional attributes factor and offset are applied when going from the variable value to the CV values, or vice-versa:
     Value to put in CVs = ((value in text field) -offset)/factor
     Value to put in text field = ((value in CVs) *factor) +offset
     
    *
    • Constructor Detail

      • DecVariableValue

        public DecVariableValue​(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)
      • DecVariableValue

        public DecVariableValue​(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,
                                int offset,
                                int factor)
    • Method Detail

      • 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
      • updatedTextField

        void updatedTextField()
        Invoked when a permanent change to the JTextField has been made. Note that this does _not_ notify property listeners; that should be done by the invoker, who may or may not know what the old value was. Can be overridden in subclasses that want to display the value differently.
        Overrides:
        updatedTextField in class VariableValue
      • actionPerformed

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

        public void focusGained​(java.awt.event.FocusEvent e)
        FocusListener implementations
        Specified by:
        focusGained in interface java.awt.event.FocusListener
      • focusLost

        public void focusLost​(java.awt.event.FocusEvent e)
        Specified by:
        focusLost in interface java.awt.event.FocusListener
      • 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
      • 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
      • 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
      • 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
      • setValue

        public void setValue​(int value)
        Set a new value in the variable (text box), including notification as needed.

        This does the conversion from string to int, so it's the place where formatting needs to be applied.

        Parameters:
        value - new value.
      • 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