Package jmri.jmrit.symbolicprog
Class CompositeVariableValue
java.lang.Object
jmri.jmrit.symbolicprog.AbstractValue
jmri.jmrit.symbolicprog.VariableValue
jmri.jmrit.symbolicprog.EnumVariableValue
jmri.jmrit.symbolicprog.CompositeVariableValue
- All Implemented Interfaces:
ActionListener,PropertyChangeListener,EventListener
Extends EnumVariableValue to represent a composition of variable values.
Internally, each "choice" is stored as a list of "setting" items. Numerical values for this type of variable (itself) are strictly sequential, because they are arbitrary.
This version of the class has certain limitations:
- Variables referenced in the definition of one of these must have already been declared earlier in the decoder file. This prevents circular references, and makes it much easier to find the target variables.
- This version of the variable never changes "State" (color), though it does track its value from changes to other variables.
- There should be a final choice (entry) that doesn't define any settings. This will then form the default value when the target variables change.
- Programming operations on a variable of this type doesn't do anything,
because there doesn't seem to be a consistent model of what "read changes"
and "write changes" should do. This has two implications:
- Variables referenced as targets must appear on some programming pane, or they won't be updated by programming operations.
- If this variable references variables that are not on this pane, the user needs to do a read/write all panes operation to record the changes made to this variable.
- To apply a mask when setting a value, use an intermediary variable set from here, which in turn references the goal variable with a mask.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classDefine objects to save and manipulate a particular setting.(package private) static classDefines a list of Setting objects.Nested classes/interfaces inherited from class jmri.jmrit.symbolicprog.EnumVariableValue
EnumVariableValue.TreeLeafNode, EnumVariableValue.VarComboBoxNested classes/interfaces inherited from class jmri.jmrit.symbolicprog.AbstractValue
AbstractValue.ValueState -
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean(package private) boolean(package private) Hashtable<String,CompositeVariableValue.SettingList> (package private) boolean(package private) HashSet<VariableValue>(package private) booleanFields inherited from class jmri.jmrit.symbolicprog.EnumVariableValue
_defaultColor, _maxVal, _minVal, _value, treeNodesFields 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 possible selection.voidaddSetting(String choice, String varName, VariableValue variable, String value) Add a setting to an existing choice.protected voidSee if there's anything to read, and if so do it.protected voidSee if there's anything to write, and if so do it.voiddispose()Dispose of the object.(package private) voidSuspect underlying variables have changed value; check.Get a display representationObjectof this variable.intGet the value as a single integer.booleanDetermine whether this Variable is "changed", so that "read changes" and "write changes" will act on it.booleanisToRead()This variable needs to be read if any of its subsidiary variables needs to be read.booleanThis variable needs to be written if any of its subsidiary variables needs to be written.voidlastItem()Do end of initialization processing.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.voidNotify the connected CVs of a state change from above by way of the variables (e.g. not direct to CVs).voidsetState(AbstractValue.ValueState state) This variable doesn't change state, hence doesn't change color.voidSet 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()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.EnumVariableValue
addItem, addItem, disposeReps, endGroup, getNewRep, getTextValue, getValueObject, getValueString, nItems, setAvailable, setColor, setIntValue, startGroupMethods 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, item, label, maskValAsInt, offsetVal, setBusy, setValue, setValueInCV, simplifyMask, updatedTextField, updateRepresentationMethods inherited from class jmri.jmrit.symbolicprog.AbstractValue
addPropertyChangeListener, getAvailable, removePropertyChangeListener
-
Field Details
-
choiceHash
-
variables
-
amReading
boolean amReading -
readingChanges
boolean readingChanges -
amWriting
boolean amWriting -
writingChanges
boolean writingChanges
-
-
Constructor Details
-
CompositeVariableValue
-
CompositeVariableValue
public CompositeVariableValue()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.- Overrides:
usesCVsin classEnumVariableValue- Returns:
- an array of CVs used by this Variable
-
addChoice
Create a new possible selection.- Parameters:
name- Name of the choice being added
-
addSetting
Add a setting to an existing choice.- Parameters:
choice- existing choice.varName- variable name.variable- variable value.value- setting value.
-
lastItem
Do end of initialization processing.- Overrides:
lastItemin classEnumVariableValue
-
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 classEnumVariableValue- Parameters:
t- the tooltip text to be used- See Also:
-
rangeVal
Description copied from class:VariableValueGets a (usually text) description of the variable type and range.- Overrides:
rangeValin classEnumVariableValue- Returns:
- description of the variable type and range
-
actionPerformed
- Specified by:
actionPerformedin interfaceActionListener- Overrides:
actionPerformedin classEnumVariableValue
-
setState
This variable doesn't change state, hence doesn't change color.- Overrides:
setStatein classVariableValue- Parameters:
state- the desired state as per definitions in AbstractValue- See Also:
-
selectValue
Set to a specific value.Does this by delegating to the SettingList
- Overrides:
selectValuein classEnumVariableValue- 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.
- Overrides:
getIntValuein classEnumVariableValue- 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.- Overrides:
getCommonRepin classEnumVariableValue- Returns:
- the
Objectrepresentation for display purposes
-
setValue
- Overrides:
setValuein classEnumVariableValue
-
setCvState
Notify the connected CVs of a state change from above by way of the variables (e.g. not direct to CVs).- Overrides:
setCvStatein classEnumVariableValue- 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.- Overrides:
isChangedin classEnumVariableValue- Returns:
- true if Variable is "changed"
- See Also:
-
setToRead
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:
-
isToRead
This variable needs to be read if any of its subsidiary variables needs to be read.- Overrides:
isToReadin classVariableValue- Returns:
- true if the object needs to be read, false otherwise
- See Also:
-
setToWrite
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:
-
isToWrite
This variable needs to be written if any of its subsidiary variables needs to be written.- Overrides:
isToWritein classVariableValue- Returns:
- true if the object needs to be written, false otherwise
- See Also:
-
readChanges
Description copied from class:VariableValueRead the contents of this Variable if it's in a state that indicates it was "changed".- Overrides:
readChangesin classEnumVariableValue- See Also:
-
writeChanges
Description copied from class:VariableValueWrite the contents of this Variable if it's in a state that indicates it was "changed".- Overrides:
writeChangesin classEnumVariableValue- See Also:
-
readAll
Description copied from class:VariableValueAlways read the contents of this Variable.- Overrides:
readAllin classEnumVariableValue
-
continueRead
See if there's anything to read, and if so do it. -
writeAll
Description copied from class:VariableValueAlways write the contents of this Variable.- Overrides:
writeAllin classEnumVariableValue
-
continueWrite
See if there's anything to write, and if so do it. -
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener- Overrides:
propertyChangein classEnumVariableValue
-
findValue
void findValue()Suspect underlying variables have changed value; check. First match will succeed, so there should not be multiple matches possible. ("First match" is defined in choice-sequence). -
dispose
Description copied from class:VariableValueDispose of the object.- Overrides:
disposein classEnumVariableValue
-