Class ConstantValue

  • All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.util.EventListener

    public class ConstantValue
    extends VariableValue
    Extends VariableValue to represent a constant enum-like-thing. Note that there's no CV associated with this.
    • Constructor Detail

      • ConstantValue

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

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

      • getCvDescription

        public java.lang.String getCvDescription()
        Provide a user-readable description of the CVs accessed by this variable.
        Overrides:
        getCvDescription in class VariableValue
        Returns:
        a user-readable description
      • 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
      • 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
      • 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
      • setToRead

        public void setToRead​(boolean state)
        Description copied from class: VariableValue
        Mark whether this object needs to be read.

        Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.

        Overrides:
        setToRead in class VariableValue
        Parameters:
        state - true if the object needs to be read, false otherwise
        See Also:
        AbstractValue
      • isToRead

        public boolean isToRead()
        Description copied from class: VariableValue
        Ask whether this object needs to be read.

        Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.

        Overrides:
        isToRead in class VariableValue
        Returns:
        true if the object needs to be read, false otherwise
        See Also:
        AbstractValue
      • setToWrite

        public void setToWrite​(boolean state)
        Description copied from class: VariableValue
        Mark whether this object needs to be written.

        Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.

        Overrides:
        setToWrite in class VariableValue
        Parameters:
        state - true if the object needs to be written, false otherwise
        See Also:
        AbstractValue
      • isToWrite

        public boolean isToWrite()
        Description copied from class: VariableValue
        Ask whether this object needs to be written.

        Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.

        Overrides:
        isToWrite in class VariableValue
        Returns:
        true if the object needs to be written, false otherwise
        See Also:
        AbstractValue
      • readAll

        public void readAll()
        Skip actually reading, but set states and notifications anyway.

        This sets the state to READ so that you can have algorithms like "write all variables that aren't in READ state" This is different from the 'normal' VariableValue objects, which rely on the associated CV objects to drive state changes at the end of the write.

        Specified by:
        readAll in class VariableValue
      • writeAll

        public void writeAll()
        Skip actually writing, but set states and notifications anyway.

        This sets the state to STORED so that you can have algorithms like "write all variables that aren't in STORED state" This is different from the 'normal' VariableValue objects, which rely on the associated CV objects to drive state changes at the end of the write.

        Specified by:
        writeAll in class VariableValue
      • propertyChange

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