jmri.jmrit.symbolicprog
Class CompositeVariableValue

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

public class CompositeVariableValue
extends EnumVariableValue
implements ActionListener, PropertyChangeListener

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:

  1. 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.
  2. This version of the variable never changes "State" (color), though it does track it's value from changes to other variables.
  3. The should be a final choice (entry) that doesn't define any settings. This will then form the default value when the target variables change.
  4. 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: It's therefore recommended that a CompositeVariableValue just make changes to target variables on the same programming page.

Author:
Bob Jacobsen Copyright (C) 2001, 2005

Nested Class Summary
 
Nested classes/interfaces inherited from class jmri.jmrit.symbolicprog.EnumVariableValue
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
CompositeVariableValue()
          Create a null object.
CompositeVariableValue(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 addChoice(String name)
          Create a new possible selection.
 void addSetting(String choice, String varName, VariableValue variable, String value)
          Add a setting to an existing choice.
protected  void continueRead()
          See if there's anything to read, and if so do it.
protected  void continueWrite()
          See if there's anything to write, and if so do it.
 void dispose()
           
 Component getCommonRep()
           
 int getIntValue()
          Get the value as a single number.
 boolean isChanged()
          Determine whether this Variable is "changed", so that "read changes" and "write changes" will act on it.
 boolean isToRead()
          This variable needs to be read if any of it's subsidiary variables needs to be read.
 boolean isToWrite()
          This variable needs to be written if any of it's subsidiary variables needs to be written.
 void lastItem()
          Do end of initialization processing.
 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 setCvState(int state)
          Notify the connected CVs of a state change from above by way of the variables (e.g. not direct to CVs)
 void setState(int state)
          This variable doesn't change state, hence doesn't change color.
 void setToolTipText(String t)
          Set tooltip text to be used by both the "value" and representations of this Variable.
 void setToRead(boolean state)
          Simple implementation for the case of a single CV.
 void setToWrite(boolean state)
          Simple implementation for the case of a single CV.
 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.EnumVariableValue
addItem, addItem, getNewRep, getTextValue, getValueObject, getValueString, nItems, setAvailable, setIntValue
 
Methods inherited from class jmri.jmrit.symbolicprog.VariableValue
confirmAll, considerChanged, cvName, getComment, getCvNum, getInfoOnly, getMask, getOpsOnly, getReadOnly, getState, getWriteOnly, isBusy, item, label, maskVal, newValue, offsetVal, setBusy, 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

CompositeVariableValue

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

CompositeVariableValue

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

Overrides:
usesCVs in class EnumVariableValue

addChoice

public void addChoice(String name)
Create a new possible selection.

Parameters:
name - Name of the choice being added

addSetting

public void addSetting(String choice,
                       String varName,
                       VariableValue variable,
                       String value)
Add a setting to an existing choice.


lastItem

public void lastItem()
Do end of initialization processing.

Overrides:
lastItem in class EnumVariableValue

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 EnumVariableValue
See Also:
VariableValue.updateRepresentation(javax.swing.JComponent)

rangeVal

public Object rangeVal()
Overrides:
rangeVal in class EnumVariableValue

actionPerformed

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

setState

public void setState(int state)
This variable doesn't change state, hence doesn't change color.

Overrides:
setState in class VariableValue

selectValue

protected void selectValue(int value)
Set to a specific value.

Does this by delegating to the SettingList

Overrides:
selectValue in class EnumVariableValue
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.

Overrides:
getIntValue in class EnumVariableValue

getCommonRep

public Component getCommonRep()
Overrides:
getCommonRep in class EnumVariableValue

setValue

public void setValue(int value)
Overrides:
setValue in class EnumVariableValue

setCvState

public void setCvState(int state)
Notify the connected CVs of a state change from above by way of the variables (e.g. not direct to CVs)

Overrides:
setCvState in class EnumVariableValue
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.

Overrides:
isChanged in class EnumVariableValue
See Also:
VariableValue.considerChanged(jmri.jmrit.symbolicprog.CvValue)

setToRead

public void setToRead(boolean state)
Description copied from class: VariableValue
Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.

Overrides:
setToRead in class VariableValue

isToRead

public boolean isToRead()
This variable needs to be read if any of it's subsidiary variables needs to be read.

Overrides:
isToRead in class VariableValue

setToWrite

public void setToWrite(boolean state)
Description copied from class: VariableValue
Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.

Overrides:
setToWrite in class VariableValue

isToWrite

public boolean isToWrite()
This variable needs to be written if any of it's subsidiary variables needs to be written.

Overrides:
isToWrite in class VariableValue

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"

Overrides:
readChanges in class EnumVariableValue
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"

Overrides:
writeChanges in class EnumVariableValue
See Also:
VariableValue.isChanged()

readAll

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

Overrides:
readAll in class EnumVariableValue

continueRead

protected void continueRead()
See if there's anything to read, and if so do it.


writeAll

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

Overrides:
writeAll in class EnumVariableValue

continueWrite

protected void continueWrite()
See if there's anything to write, and if so do it.


propertyChange

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

dispose

public void dispose()
Overrides:
dispose in class EnumVariableValue


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