Class LongAddrVariableValue
- java.lang.Object
-
- jmri.jmrit.symbolicprog.AbstractValue
-
- jmri.jmrit.symbolicprog.VariableValue
-
- jmri.jmrit.symbolicprog.LongAddrVariableValue
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.FocusListener
,java.beans.PropertyChangeListener
,java.util.EventListener
public class LongAddrVariableValue extends VariableValue implements java.awt.event.ActionListener, java.awt.event.FocusListener
Extends VariableValue to represent an NMRA long address.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
LongAddrVariableValue.VarTextField
-
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) int
_maxVal
(package private) int
_minVal
(package private) javax.swing.JTextField
_value
(package private) CvValue
highCV
(package private) java.lang.String
oldContents
-
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 LongAddrVariableValue(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, CvValue mHighCV)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
ActionListener implementationsvoid
dispose()
Dispose of the object.(package private) void
enterField()
(package private) void
exitField()
void
focusGained(java.awt.event.FocusEvent e)
FocusListener implementationsvoid
focusLost(java.awt.event.FocusEvent e)
java.awt.Component
getCommonRep()
Get a display representationObject
of this variable.java.lang.String
getCvDescription()
Provide a user-readable description of the CVs accessed by this variable.int
getIntValue()
Get the value as a single integer.java.awt.Component
getNewRep(java.lang.String format)
Creates a newObject
representation for display purposes, using the specified format.java.lang.Object
getValueObject()
java.lang.String
getValueString()
boolean
isChanged()
Determine whether this Variable is "changed", so that "read changes" and "write changes" will act on it.boolean
isToRead()
Ask whether this object needs to be read.boolean
isToWrite()
Ask whether this object needs to be written.void
propertyChange(java.beans.PropertyChangeEvent e)
java.lang.Object
rangeVal()
Gets a (usually text) description of the variable type and range.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
setColor(java.awt.Color c)
Method to handle color changes for states.void
setCvState(AbstractValue.ValueState state)
Notify the connected CVs of a state change from abovevoid
setIntValue(int i)
Set the value from a single number.void
setToolTipText(java.lang.String t)
Set tooltip text to be used by both the "value" and representations of this Variable.void
setToRead(boolean state)
Mark whether this object needs to be read.void
setToWrite(boolean state)
Mark whether this object needs to be written.void
setValue(int value)
(package private) void
updatedTextField()
This should be overridden by any implementation.CvValue[]
usesCVs()
Provide access to CVs used by this Variable.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".-
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, updateRepresentation
-
Methods inherited from class jmri.jmrit.symbolicprog.AbstractValue
addPropertyChangeListener, getAvailable, removePropertyChangeListener, setAvailable
-
-
-
-
Field Detail
-
_maxVal
int _maxVal
-
_minVal
int _minVal
-
oldContents
java.lang.String oldContents
-
_defaultColor
java.awt.Color _defaultColor
-
_value
javax.swing.JTextField _value
-
-
Constructor Detail
-
LongAddrVariableValue
public LongAddrVariableValue(@Nonnull java.lang.String name, @Nonnull java.lang.String comment, @Nonnull java.lang.String cvName, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, @Nonnull java.lang.String cvNum, @Nonnull java.lang.String mask, int minVal, int maxVal, @Nonnull java.util.HashMap<java.lang.String,CvValue> v, @Nonnull javax.swing.JLabel status, @Nonnull java.lang.String stdname, @Nonnull CvValue mHighCV)
-
-
Method Detail
-
usesCVs
public CvValue[] usesCVs()
Description copied from class:VariableValue
Provide access to CVs used by this Variable.- Specified by:
usesCVs
in 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:
getCvDescription
in classVariableValue
- Returns:
- a user-readable description
-
setToolTipText
public void setToolTipText(java.lang.String t)
Description copied from class:VariableValue
Set 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:
setToolTipText
in 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:VariableValue
Gets a (usually text) description of the variable type and range.- Specified by:
rangeVal
in classVariableValue
- Returns:
- description of the variable type and range
-
enterField
void enterField()
-
exitField
void exitField()
-
updatedTextField
void updatedTextField()
Description copied from class:VariableValue
This should be overridden by any implementation.- Overrides:
updatedTextField
in classVariableValue
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
ActionListener implementations- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
focusGained
public void focusGained(java.awt.event.FocusEvent e)
FocusListener implementations- Specified by:
focusGained
in interfacejava.awt.event.FocusListener
-
focusLost
public void focusLost(java.awt.event.FocusEvent e)
- Specified by:
focusLost
in interfacejava.awt.event.FocusListener
-
getValueString
public java.lang.String getValueString()
- Specified by:
getValueString
in classVariableValue
- Returns:
- String that can (usually) be interpreted as an integer
-
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 classVariableValue
- 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 classVariableValue
- Returns:
- the value as an integer
-
getValueObject
public java.lang.Object getValueObject()
- Specified by:
getValueObject
in classVariableValue
- Returns:
- Value as a native-form Object
-
getCommonRep
public java.awt.Component getCommonRep()
Description copied from class:VariableValue
Get a display representationObject
of this variable.
The actual stored value of a variable is not the most interesting thing. Instead, you usually get anObject
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 classVariableValue
- Returns:
- the
Object
representation for display purposes
-
setValue
public void setValue(int value)
-
setColor
void setColor(java.awt.Color c)
Description copied from class:AbstractValue
Method to handle color changes for states.- Specified by:
setColor
in classAbstractValue
- Parameters:
c
- the desired colour
-
getNewRep
public java.awt.Component getNewRep(java.lang.String format)
Description copied from class:VariableValue
Creates a newObject
representation for display purposes, using the specified format.- Specified by:
getNewRep
in classVariableValue
- Parameters:
format
- a name representing- Returns:
- an
Object
representation for display purposes
-
setCvState
public void setCvState(AbstractValue.ValueState state)
Notify the connected CVs of a state change from above- Specified by:
setCvState
in classVariableValue
- Parameters:
state
- the new state to set
-
isChanged
public boolean isChanged()
Description copied from class:VariableValue
Determine whether this Variable is "changed", so that "read changes" and "write changes" will act on it.- Specified by:
isChanged
in 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: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 classVariableValue
- 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 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: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 classVariableValue
- 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 classVariableValue
- Returns:
- true if the object needs to be written, false otherwise
- See Also:
AbstractValue
-
readChanges
public void readChanges()
Description copied from class:VariableValue
Read the contents of this Variable if it's in a state that indicates it was "changed".- Specified by:
readChanges
in classVariableValue
- See Also:
VariableValue.isChanged()
-
writeChanges
public void writeChanges()
Description copied from class:VariableValue
Write the contents of this Variable if it's in a state that indicates it was "changed".- Specified by:
writeChanges
in classVariableValue
- See Also:
VariableValue.isChanged()
-
readAll
public void readAll()
Description copied from class:VariableValue
Always read the contents of this Variable.- Specified by:
readAll
in classVariableValue
-
writeAll
public void writeAll()
Description copied from class:VariableValue
Always write the contents of this Variable.- Specified by:
writeAll
in classVariableValue
-
propertyChange
public void propertyChange(@Nonnull java.beans.PropertyChangeEvent e)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
- Specified by:
propertyChange
in classVariableValue
-
dispose
public void dispose()
Description copied from class:VariableValue
Dispose of the object.- Specified by:
dispose
in classVariableValue
-
-