|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.jmrit.symbolicprog.AbstractValue
jmri.jmrit.symbolicprog.VariableValue
jmri.jmrit.symbolicprog.SpeedTableVarValue
public class SpeedTableVarValue
Represent an entire speed table as a single Variable.
This presents as a set of vertically oriented sliders, with numeric values above them. That it turn is done using VarSlider and DecVariableValue objects respectively. VarSlider is an interior class to color a JSlider by state. The respective VarSlider and DecVariableValue communicate through their underlying CV objects. Changes to CV Values are listened to by this class, which updates the model objects for the VarSliders; the DecVariableValues listen directly.
Color (hence state) of individual sliders (hence CVs) are directly coupled to the state of those CVs.
The state of the entire variable has to be a composite of all the sliders, hence CVs. The mapping is (in order):
A similar pattern is used for a read or write request. Write writes them all; Read reads any that aren't READ or WRITTEN.
Speed tables can have different numbers of entries; 28 is the default, and also the maximum.
The NMRA specification says that speed table entries cannot be non-monotonic (e.g. cannot decrease when moving from lower to higher CV numbers). In earlier versions of the code, this was enforced any time a value was changed (for any reason). This caused a problem when CVs were read that were non-monotonic: That value was read, causing lower CVs to be made consistent, a change in their value which changed their state, so they were read again. To avoid this, the class now only enforces non-monotonicity when the slider is adjusted.
_value is a holdover from the LongAddrVariableValue, which this was copied from; it should be removed.
| Nested Class Summary | |
|---|---|
class |
SpeedTableVarValue.VarSlider
|
| Field Summary | |
|---|---|
(package private) Color |
_defaultColor
|
(package private) int |
_max
|
(package private) int |
_min
|
(package private) int |
_range
|
(package private) int[] |
cvList
|
(package private) boolean |
isReading
|
(package private) boolean |
isWriting
|
(package private) static org.slf4j.Logger |
log
|
(package private) boolean |
mfx
|
(package private) BoundedRangeModel[] |
models
|
(package private) int |
numCvs
|
(package private) int |
nValues
|
(package private) boolean |
onlyChanges
|
(package private) List<JCheckBox> |
stepCheckBoxes
|
(package private) static int |
VHIGH_CV
|
(package private) static int |
VSTART_CV
|
| Fields inherited from class jmri.jmrit.symbolicprog.VariableValue |
|---|
_cvVector, _status, _tooltipText |
| Fields inherited from class jmri.jmrit.symbolicprog.AbstractValue |
|---|
COLOR_DIFF, COLOR_EDITED, COLOR_FROMFILE, COLOR_READ, COLOR_SAME, COLOR_STORED, COLOR_UNKNOWN, DIFF, EDITED, FROMFILE, prop, READ, SAME, STORED, UNKNOWN |
| Constructor Summary | |
|---|---|
SpeedTableVarValue()
Create a null object. |
|
SpeedTableVarValue(String name,
String comment,
String cvName,
boolean readOnly,
boolean infoOnly,
boolean writeOnly,
boolean opsOnly,
int cvNum,
String mask,
int minVal,
int maxVal,
Vector<CvValue> v,
JLabel status,
String stdname,
int entries,
boolean mfxFlag)
Create the object with a "standard format ctor". |
|
| Method Summary | |
|---|---|
void |
dispose()
|
(package private) void |
doForceStraight(ActionEvent e)
Set the values to a straight line from _min to _max |
(package private) void |
doLogCurve(ActionEvent e)
Set a log curve |
(package private) void |
doMatchEnds(ActionEvent e)
Set the values to a straight line from existing ends |
(package private) void |
doRatioCurve(ActionEvent e)
Set a constant ratio curve |
(package private) void |
doShiftLeft(ActionEvent e)
Shift the curve one CV to left. |
(package private) void |
doShiftRight(ActionEvent e)
Shift the curve one CV to right. |
(package private) void |
enforceEndPointsMfx()
Enforce mfx bounds conditions. |
(package private) void |
forceMonotonic(int modifiedStepIndex,
int value)
Check entries on either side to see if they are set monotonically. |
Component |
getCommonRep()
|
int |
getIntValue()
Get the value as a single number. |
Component |
getNewRep(String format)
|
int |
getState()
|
Object |
getValueObject()
|
String |
getValueString()
|
(package private) void |
initStepCheckBoxes()
|
boolean |
isChanged()
Determine whether this Variable is "changed", so that "read changes" and "write changes" will act on it. |
(package private) void |
matchPoints(int modifiedStepIndex)
If there are fixed points specified, set linear step settings to them. |
(package private) void |
matchPointsLeft(int modifiedStepIndex)
|
(package private) void |
matchPointsRight(int modifiedStepIndex)
|
void |
propertyChange(PropertyChangeEvent e)
|
Object |
rangeVal()
|
void |
readAll()
Always read the contents of this Variable |
void |
readChanges()
Read the contents of this Variable if it's in a state that indicates it was "changed" |
(package private) void |
readNext()
|
(package private) void |
setColor(Color c)
|
void |
setCvState(int state)
Notify the connected CVs of a state change from above |
void |
setIntValue(int i)
Set the value from a single number. |
(package private) void |
setModel(int i,
int value)
|
void |
setValue(int value)
|
void |
stateChanged(ChangeEvent e)
Called for new values of a slider. |
CvValue[] |
usesCVs()
Provide access to CVs referenced by this operation |
void |
writeAll()
Always write the contents of this Variable |
void |
writeChanges()
Write the contents of this Variable if it's in a state that indicates it was "changed" |
(package private) void |
writeNext()
|
| Methods inherited from class jmri.jmrit.symbolicprog.VariableValue |
|---|
confirmAll, considerChanged, cvName, getComment, getCvNum, getInfoOnly, getMask, getOpsOnly, getReadOnly, getTextValue, getWriteOnly, isBusy, isToRead, isToWrite, item, label, maskVal, newValue, offsetVal, setBusy, setState, setToolTipText, setToRead, setToWrite, updatedTextField, updateRepresentation |
| Methods inherited from class jmri.jmrit.symbolicprog.AbstractValue |
|---|
addPropertyChangeListener, getAvailable, removePropertyChangeListener, setAvailable, stateNameFromValue |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final int VSTART_CV
static final int VHIGH_CV
int nValues
int numCvs
int[] cvList
BoundedRangeModel[] models
int _min
int _max
int _range
boolean mfx
List<JCheckBox> stepCheckBoxes
Color _defaultColor
boolean isReading
boolean isWriting
boolean onlyChanges
static org.slf4j.Logger log
| Constructor Detail |
|---|
public SpeedTableVarValue(String name,
String comment,
String cvName,
boolean readOnly,
boolean infoOnly,
boolean writeOnly,
boolean opsOnly,
int cvNum,
String mask,
int minVal,
int maxVal,
Vector<CvValue> v,
JLabel status,
String stdname,
int entries,
boolean mfxFlag)
public SpeedTableVarValue()
| Method Detail |
|---|
public Object rangeVal()
rangeVal in class VariableValuepublic CvValue[] usesCVs()
VariableValue
usesCVs in class VariableValuepublic void stateChanged(ChangeEvent e)
Sets the CV(s) as needed.
stateChanged in interface ChangeListenere -
void setModel(int i,
int value)
void forceMonotonic(int modifiedStepIndex,
int value)
modifiedStepIndex - number (index) of the entryvalue - new valuevoid matchPoints(int modifiedStepIndex)
void matchPointsLeft(int modifiedStepIndex)
void matchPointsRight(int modifiedStepIndex)
void enforceEndPointsMfx()
public int getState()
getState in class VariableValuepublic String getValueString()
getValueString in class VariableValuepublic void setIntValue(int i)
VariableValue
setIntValue in class VariableValuepublic int getIntValue()
VariableValue
getIntValue in class VariableValuepublic Object getValueObject()
getValueObject in class VariableValuepublic Component getCommonRep()
getCommonRep in class VariableValuepublic void setValue(int value)
void setColor(Color c)
setColor in class AbstractValuepublic Component getNewRep(String format)
getNewRep in class VariableValuevoid initStepCheckBoxes()
void doForceStraight(ActionEvent e)
void doMatchEnds(ActionEvent e)
void doRatioCurve(ActionEvent e)
void doLogCurve(ActionEvent e)
void doShiftLeft(ActionEvent e)
void doShiftRight(ActionEvent e)
public void setCvState(int state)
setCvState in class VariableValuestate - public boolean isChanged()
VariableValue
isChanged in class VariableValueVariableValue.considerChanged(jmri.jmrit.symbolicprog.CvValue)public void readChanges()
VariableValue
readChanges in class VariableValueVariableValue.isChanged()public void writeChanges()
VariableValue
writeChanges in class VariableValueVariableValue.isChanged()public void readAll()
VariableValue
readAll in class VariableValuepublic void writeAll()
VariableValue
writeAll in class VariableValuevoid readNext()
void writeNext()
public void propertyChange(PropertyChangeEvent e)
propertyChange in interface PropertyChangeListenerpropertyChange in class VariableValuepublic void dispose()
dispose in class VariableValue
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||