jmri.jmrit.symbolicprog
Class ConstantValue

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

public class ConstantValue
extends VariableValue

Extends VariableValue to represent a constant enum-like-thing Note that there's no CV associated with this.

Author:
Bob Jacobsen Copyright (C) 2001

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
ConstantValue()
          Create a null object.
ConstantValue(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 dispose()
           
 Component getCommonRep()
           
 int getIntValue()
          Get the value as a single number.
 Component getNewRep(String format)
           
 Object getValueObject()
           
 String getValueString()
           
 boolean isChanged()
          Determine whether this Variable is "changed", so that "read changes" and "write changes" will act on it.
 boolean isToRead()
          Simple implementation for the case of a single CV.
 boolean isToWrite()
          Simple implementation for the case of a single CV.
 void propertyChange(PropertyChangeEvent e)
           
 Object rangeVal()
           
 void readAll()
          Skip actually reading, but set states and notifications anyway.
 void readChanges()
          Read the contents of this Variable if it's in a state that indicates it was "changed"
 void setCvState(int state)
          No connected CV, so this notify does nothing
 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 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()
          Skip actually writing, but set states and notifications anyway.
 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, getTextValue, getWriteOnly, isBusy, item, label, maskVal, newValue, offsetVal, setBusy, setState, 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
 

Constructor Detail

ConstantValue

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

ConstantValue

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

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)

rangeVal

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

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

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

getValueObject

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

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)
No connected CV, so this notify does nothing

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)

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()
Description copied from class: VariableValue
Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.

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()
Description copied from class: VariableValue
Simple implementation for the case of a single CV. Intended to be sufficient for many subclasses.

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"

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()
Skip actually reading, but set states and notifications anyway.

This sets the state to READ so that you can have algorithms like "write all variables that aren't in READ state" This is different from the 'normal' VariableValue objects, which rely on the associated CV objects to drive state changes at the end of the write.

Specified by:
readAll in class VariableValue

writeAll

public void writeAll()
Skip actually writing, but set states and notifications anyway.

This sets the state to STORED so that you can have algorithms like "write all variables that aren't in STORED state" This is different from the 'normal' VariableValue objects, which rely on the associated CV objects to drive state changes at the end of the write.

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