jmri.jmrit.symbolicprog
Class EnumVariableValue

java.lang.Object
  extended by jmri.jmrit.symbolicprog.AbstractValue
      extended by jmri.jmrit.symbolicprog.VariableValue
          extended by jmri.jmrit.symbolicprog.EnumVariableValue
All Implemented Interfaces:
ActionListener, PropertyChangeListener, EventListener
Direct Known Subclasses:
CompositeVariableValue

public class EnumVariableValue
extends VariableValue
implements ActionListener, PropertyChangeListener

Extends VariableValue to represent a enumerated variable.

Author:
Bob Jacobsen Copyright (C) 2001, 2002, 2003

Nested Class Summary
 class EnumVariableValue.VarComboBox
           
 
Field Summary
 
Fields inherited from class jmri.jmrit.symbolicprog.VariableValue
_cvVector, _status, _tooltipText
 
Fields inherited from class jmri.jmrit.symbolicprog.AbstractValue
DIFF, EDITED, FROMFILE, READ, SAME, STORED, UNKNOWN
 
Constructor Summary
EnumVariableValue()
          Create a null object.
EnumVariableValue(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)
           
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void addItem(String s)
          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)
 void addItem(String s, int value)
          Create a new item in the enumeration, with a specified associated value.
 void dispose()
           
 Component getCommonRep()
           
 int getIntValue()
          Get the value as a single number.
 Component getNewRep(String format)
           
 String getTextValue()
           
 Object getValueObject()
           
 String getValueString()
           
 boolean isChanged()
          Determine whether this Variable is "changed", so that "read changes" and "write changes" will act on it.
 void lastItem()
           
 void nItems(int n)
           
 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"
protected  void selectValue(int value)
          Set to a specific value.
 void setAvailable(boolean a)
           
 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.
 void setToolTipText(String t)
          Set tooltip text to be used by both the "value" and representations of this Variable.
 void setValue(int value)
           
 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"
 
Methods inherited from class jmri.jmrit.symbolicprog.VariableValue
confirmAll, considerChanged, cvName, getComment, getCvNum, getInfoOnly, getMask, getOpsOnly, getReadOnly, getState, getWriteOnly, isBusy, isToRead, isToWrite, item, label, maskVal, newValue, offsetVal, setBusy, setState, setToRead, setToWrite, updateRepresentation
 
Methods inherited from class jmri.jmrit.symbolicprog.AbstractValue
addPropertyChangeListener, getAvailable, removePropertyChangeListener, stateNameFromValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumVariableValue

public EnumVariableValue(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)

EnumVariableValue

public EnumVariableValue()
Create a null object. Normally only used for tests and to pre-load classes.

Method Detail

usesCVs

public CvValue[] usesCVs()
Description copied from class: VariableValue
Provide access to CVs referenced by this operation

Specified by:
usesCVs in class VariableValue

nItems

public void nItems(int n)

addItem

public void addItem(String s)
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

public void addItem(String s,
                    int value)
Create a new item in the enumeration, with a specified associated value.

Parameters:
s - Name of the enumeration item

lastItem

public void lastItem()

setToolTipText

public void setToolTipText(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 class VariableValue
See Also:
VariableValue.updateRepresentation(javax.swing.JComponent)

setAvailable

public void setAvailable(boolean a)
Overrides:
setAvailable in class AbstractValue

rangeVal

public Object rangeVal()
Specified by:
rangeVal in class VariableValue

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

getValueString

public String getValueString()
Specified by:
getValueString in class VariableValue
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 class VariableValue

getTextValue

public String getTextValue()
Overrides:
getTextValue in class VariableValue
Returns:
User-desired value, which may or may not be an integer

getValueObject

public Object getValueObject()
Specified by:
getValueObject in class VariableValue
Returns:
Value as a native-form Object

selectValue

protected void selectValue(int value)
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 -

getIntValue

public int getIntValue()
Description copied from class: VariableValue
Get the value as 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:
getIntValue in class VariableValue

getCommonRep

public Component getCommonRep()
Specified by:
getCommonRep in class VariableValue

setValue

public void setValue(int value)

getNewRep

public Component getNewRep(String format)
Specified by:
getNewRep in class VariableValue

setCvState

public void setCvState(int state)
Notify the connected CVs of a state change from above

Specified by:
setCvState in class VariableValue
Parameters:
state -

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 class VariableValue
See Also:
VariableValue.considerChanged(jmri.jmrit.symbolicprog.CvValue)

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 class VariableValue
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 class VariableValue
See Also:
VariableValue.isChanged()

readAll

public void readAll()
Description copied from class: VariableValue
Always read the contents of this Variable

Specified by:
readAll in class VariableValue

writeAll

public void writeAll()
Description copied from class: VariableValue
Always write the contents of this Variable

Specified by:
writeAll in class VariableValue

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener
Specified by:
propertyChange in class VariableValue

dispose

public void dispose()
Specified by:
dispose in class VariableValue


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads