Class ConstantValue
- java.lang.Object
-
- jmri.jmrit.symbolicprog.AbstractValue
-
- jmri.jmrit.symbolicprog.VariableValue
-
- jmri.jmrit.symbolicprog.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrit.symbolicprog.AbstractValue
AbstractValue.ValueState
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.awt.Color_defaultColor(package private) java.lang.String[]_itemArray(package private) int_nstored(package private) javax.swing.JComboBox<java.lang.Integer>_value(package private) java.util.List<javax.swing.JCheckBox>comboCBs(package private) java.util.List<javax.swing.JRadioButton>comboRBs-
Fields inherited from class jmri.jmrit.symbolicprog.VariableValue
_cvMap, _status, _tooltipText
-
Fields inherited from class jmri.jmrit.symbolicprog.AbstractValue
prop
-
-
Constructor Summary
Constructors Constructor Description ConstantValue()Create a null object.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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()Dispose of the object.java.awt.ComponentgetCommonRep()Get a display representationObjectof this variable.java.lang.StringgetCvDescription()Provide a user-readable description of the CVs accessed by this variable.intgetIntValue()Get the value as a single integer.java.awt.ComponentgetNewRep(java.lang.String format)Creates a newObjectrepresentation for display purposes, using the specified format.java.lang.ObjectgetValueObject()java.lang.StringgetValueString()booleanisChanged()Determine whether this Variable is "changed", so that "read changes" and "write changes" will act on it.booleanisToRead()Ask whether this object needs to be read.booleanisToWrite()Ask whether this object needs to be written.voidpropertyChange(java.beans.PropertyChangeEvent e)java.lang.ObjectrangeVal()Gets a (usually text) description of the variable type and range.voidreadAll()Skip actually reading, but set states and notifications anyway.voidreadChanges()Read the contents of this Variable if it's in a state that indicates it was "changed".(package private) voidsetColor(java.awt.Color c)Method to handle color changes for states.voidsetCvState(AbstractValue.ValueState state)No connected CV, so this notify does nothingvoidsetIntValue(int i)Set the value from a single number.voidsetToolTipText(java.lang.String t)Set tooltip text to be used by both the "value" and representations of this Variable.voidsetToRead(boolean state)Mark whether this object needs to be read.voidsetToWrite(boolean state)Mark whether this object needs to be written.voidsetValue(int value)CvValue[]usesCVs()Provide access to CVs used by this Variable.voidwriteAll()Skip actually writing, but set states and notifications anyway.voidwriteChanges()Write the contents of this Variable if it's in a state that indicates it was "changed".-
Methods inherited from class jmri.jmrit.symbolicprog.VariableValue
confirmAll, considerChanged, cvName, getComment, getCvName, getCvNum, getInfoOnly, getLongValue, getMask, getMaxMask, getOpsOnly, getReadOnly, getState, getTextValue, getValueInCV, getWriteOnly, isBitMask, isBusy, item, label, maskValAsInt, offsetVal, setBusy, setState, setValue, setValueInCV, simplifyMask, updatedTextField, updateRepresentation
-
Methods inherited from class jmri.jmrit.symbolicprog.AbstractValue
addPropertyChangeListener, getAvailable, removePropertyChangeListener, setAvailable
-
-
-
-
Field Detail
-
_value
javax.swing.JComboBox<java.lang.Integer> _value
-
_itemArray
java.lang.String[] _itemArray
-
_nstored
int _nstored
-
_defaultColor
java.awt.Color _defaultColor
-
comboCBs
java.util.List<javax.swing.JCheckBox> comboCBs
-
comboRBs
java.util.List<javax.swing.JRadioButton> comboRBs
-
-
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
-
usesCVs
public CvValue[] usesCVs()
Description copied from class:VariableValueProvide access to CVs used by this Variable.- Specified by:
usesCVsin classVariableValue- Returns:
- an array of CVs used by this Variable
-
getCvDescription
public java.lang.String getCvDescription()
Provide a user-readable description of the CVs accessed by this variable.- Overrides:
getCvDescriptionin classVariableValue- Returns:
- a user-readable description
-
setToolTipText
public void setToolTipText(java.lang.String t)
Description copied from class:VariableValueSet tooltip text to be used by both the "value" and representations of this Variable.This is expected to be overridden in subclasses to change their internal info.
- Overrides:
setToolTipTextin classVariableValue- Parameters:
t- the tooltip text to be used- See Also:
VariableValue.updateRepresentation(javax.swing.JComponent)
-
rangeVal
public java.lang.Object rangeVal()
Description copied from class:VariableValueGets a (usually text) description of the variable type and range.- Specified by:
rangeValin classVariableValue- Returns:
- description of the variable type and range
-
getValueString
public java.lang.String getValueString()
- Specified by:
getValueStringin classVariableValue- Returns:
- String that can (usually) be interpreted as an integer
-
setIntValue
public void setIntValue(int i)
Description copied from class:VariableValueSet 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:
setIntValuein classVariableValue- Parameters:
i- the integer value to set
-
getIntValue
public int getIntValue()
Description copied from class:VariableValueGet 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:
getIntValuein classVariableValue- Returns:
- the value as an integer
-
getValueObject
public java.lang.Object getValueObject()
- Specified by:
getValueObjectin classVariableValue- Returns:
- Value as a native-form Object
-
getCommonRep
public java.awt.Component getCommonRep()
Description copied from class:VariableValueGet a display representationObjectof this variable.
The actual stored value of a variable is not the most interesting thing. Instead, you usually get anObjectrepresentation 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:
getCommonRepin classVariableValue- Returns:
- the
Objectrepresentation for display purposes
-
setValue
public void setValue(int value)
-
getNewRep
public java.awt.Component getNewRep(java.lang.String format)
Description copied from class:VariableValueCreates a newObjectrepresentation for display purposes, using the specified format.- Specified by:
getNewRepin classVariableValue- Parameters:
format- a name representing- Returns:
- an
Objectrepresentation for display purposes
-
setColor
void setColor(java.awt.Color c)
Description copied from class:AbstractValueMethod to handle color changes for states.- Specified by:
setColorin classAbstractValue- Parameters:
c- the desired colour
-
setCvState
public void setCvState(AbstractValue.ValueState state)
No connected CV, so this notify does nothing- Specified by:
setCvStatein classVariableValue- Parameters:
state- the new state to set
-
isChanged
public boolean isChanged()
Description copied from class:VariableValueDetermine whether this Variable is "changed", so that "read changes" and "write changes" will act on it.- Specified by:
isChangedin classVariableValue- Returns:
- true if Variable is "changed"
- See Also:
VariableValue.considerChanged(jmri.jmrit.symbolicprog.CvValue)
-
setToRead
public void setToRead(boolean state)
Description copied from class:VariableValueMark whether this object needs to be read.Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.
- Overrides:
setToReadin classVariableValue- Parameters:
state- true if the object needs to be read, false otherwise- See Also:
AbstractValue
-
isToRead
public boolean isToRead()
Description copied from class:VariableValueAsk whether this object needs to be read.Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.
- Overrides:
isToReadin classVariableValue- Returns:
- true if the object needs to be read, false otherwise
- See Also:
AbstractValue
-
setToWrite
public void setToWrite(boolean state)
Description copied from class:VariableValueMark whether this object needs to be written.Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.
- Overrides:
setToWritein classVariableValue- Parameters:
state- true if the object needs to be written, false otherwise- See Also:
AbstractValue
-
isToWrite
public boolean isToWrite()
Description copied from class:VariableValueAsk whether this object needs to be written.Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.
- Overrides:
isToWritein classVariableValue- Returns:
- true if the object needs to be written, false otherwise
- See Also:
AbstractValue
-
readChanges
public void readChanges()
Description copied from class:VariableValueRead the contents of this Variable if it's in a state that indicates it was "changed".- Specified by:
readChangesin classVariableValue- See Also:
VariableValue.isChanged()
-
writeChanges
public void writeChanges()
Description copied from class:VariableValueWrite the contents of this Variable if it's in a state that indicates it was "changed".- Specified by:
writeChangesin classVariableValue- See Also:
VariableValue.isChanged()
-
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:
readAllin classVariableValue
-
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:
writeAllin classVariableValue
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener- Specified by:
propertyChangein classVariableValue
-
dispose
public void dispose()
Description copied from class:VariableValueDispose of the object.- Specified by:
disposein classVariableValue
-
-