Package jmri.jmrit.symbolicprog
Class EnumVariableValue
java.lang.Object
jmri.jmrit.symbolicprog.AbstractValue
jmri.jmrit.symbolicprog.VariableValue
jmri.jmrit.symbolicprog.EnumVariableValue
- All Implemented Interfaces:
ActionListener,PropertyChangeListener,EventListener
- Direct Known Subclasses:
CompositeVariableValue
Extends VariableValue to represent an enumerated variable.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classstatic classNested classes/interfaces inherited from class jmri.jmrit.symbolicprog.AbstractValue
AbstractValue.ValueState -
Field Summary
FieldsModifier and TypeFieldDescription(package private) Color(package private) int(package private) int(package private) Deque<DefaultMutableTreeNode>Fields inherited from class jmri.jmrit.symbolicprog.VariableValue
_cvMap, _status, _tooltipTextFields inherited from class jmri.jmrit.symbolicprog.AbstractValue
prop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidCreate 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)voidCreate a new item in the enumeration, with a specified associated value.voiddispose()Dispose of the object.(package private) voidvoidendGroup()Get a display representationObjectof this variable.intGet the value as a single integer.Creates a newObjectrepresentation for display purposes, using the specified format.booleanDetermine whether this Variable is "changed", so that "read changes" and "write changes" will act on it.voidlastItem()voidnItems(int n) voidrangeVal()Gets a (usually text) description of the variable type and range.voidreadAll()Always read the contents of this Variable.voidRead the contents of this Variable if it's in a state that indicates it was "changed".protected voidselectValue(int value) Set to a specific value.voidsetAvailable(boolean a) Sets the availability status of the object.(package private) voidMethod to handle color changes for states.voidNotify the connected CVs of a state change from abovevoidsetIntValue(int i) Set the value from a single number.voidSet tooltip text to be used by both the "value" and representations of this Variable.voidsetValue(int value) voidstartGroup(String name) CvValue[]usesCVs()Provide access to CVs used by this Variable.voidwriteAll()Always write the contents of this Variable.voidWrite 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, getCvDescription, getCvName, getCvNum, getInfoOnly, getLongValue, getMask, getMaxMask, getOpsOnly, getReadOnly, getState, getValueInCV, getWriteOnly, isBitMask, isBusy, isToRead, isToWrite, item, label, maskValAsInt, offsetVal, setBusy, setState, setToRead, setToWrite, setValue, setValueInCV, simplifyMask, updatedTextField, updateRepresentationMethods inherited from class jmri.jmrit.symbolicprog.AbstractValue
addPropertyChangeListener, getAvailable, removePropertyChangeListener
-
Field Details
-
Constructor Details
-
EnumVariableValue
-
EnumVariableValue
public EnumVariableValue()Create a null object. Normally only used for tests and to pre-load classes.
-
-
Method Details
-
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
-
nItems
-
addItem
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
Create a new item in the enumeration, with a specified associated value.- Parameters:
s- Name of the enumeration itemvalue- item value.
-
startGroup
-
endGroup
-
lastItem
-
setToolTipText
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:
-
setAvailable
Description copied from class:AbstractValueSets the availability status of the object.- Overrides:
setAvailablein classAbstractValue- Parameters:
a-trueif the object should be made available,falseif should be made unavailable
-
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
-
actionPerformed
- Specified by:
actionPerformedin interfaceActionListener
-
getValueString
- Specified by:
getValueStringin classVariableValue- Returns:
- String that can (usually) be interpreted as an integer
-
setIntValue
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
-
getTextValue
- Overrides:
getTextValuein classVariableValue- Returns:
- User-desired value, which may or may not be an integer
-
getValueObject
- Specified by:
getValueObjectin classVariableValue- Returns:
- Value as a native-form Object
-
selectValue
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
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
-
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
-
getNewRep
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
Description copied from class:AbstractValueMethod to handle color changes for states.- Specified by:
setColorin classAbstractValue- Parameters:
c- the desired colour
-
setCvState
Notify the connected CVs of a state change from above- Specified by:
setCvStatein classVariableValue- Parameters:
state- the new state to set
-
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:
-
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:
-
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:
-
readAll
Description copied from class:VariableValueAlways read the contents of this Variable.- Specified by:
readAllin classVariableValue
-
writeAll
Description copied from class:VariableValueAlways write the contents of this Variable.- Specified by:
writeAllin classVariableValue
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener- Specified by:
propertyChangein classVariableValue
-
dispose
Description copied from class:VariableValueDispose of the object.- Specified by:
disposein classVariableValue
-
disposeReps
void disposeReps()
-