ControlBeans
Interface ComponentInterface

All Known Implementing Classes:
CButton, CCheckBox, CRadioButton, CRelay, CScrollbar, CSlider, CTextArea, CBarGauge, CTextField, CPlotter

public interface ComponentInterface

This is the interface that all control components must implement. It provides the component with the methods needed for it to be stored in a communicator and have values being passed on to it. Components that wish to send values through the communicator should do so by first sending a registerComponentEvent to all its registered listeners (which normally consists of one communicator). This will alert the communicator to the components presence and it will in return alert the component of its presence by invoking registerCommunicator. After that, the component can send values to the communicator by invoking its putValue methods.

See Also:
AbstractCommunicator

Field Summary
static int DEFAULT_ID
           
 
Method Summary
 void addComponentListener(ComponentListener l)
          Registers a ComponentListener.
 boolean getIsReceiver()
          Gets whether or not this component will receive values.
 boolean getIsSender()
          Gets whether or not this component will send values.
 int[] getTags()
          The communicator uses this method to get all the tags used by this component.
 void putValue(double value, int aTag, double time, int ID)
          Sets the value of this component.
 void putValue(int value, int aTag, double time, int ID)
          Sets the value of this component.
 void putValue(java.lang.String value, int aTag, double time, int ID)
          Sets the value of this component.
 void registerCommunicator(AbstractCommunicator c, int ID)
          The communicator uses this method to alert this component of its presence.
 void removeComponentListener(ComponentListener l)
          Deregisters the ComponentListener.
 void requestValues()
          Called by the communicator to make this component send its value(s).
 void setIsReceiver(boolean value)
          Sets whether or not this component should receive values.
 void setIsSender(boolean value)
          Sets whether or not this component should send values.
 

Field Detail

DEFAULT_ID

public static final int DEFAULT_ID
Method Detail

getIsReceiver

public boolean getIsReceiver()
Gets whether or not this component will receive values.
Returns:
true if this component will receive values to the communicator; false otherwise.

setIsReceiver

public void setIsReceiver(boolean value)
Sets whether or not this component should receive values.
Parameters:
value - true if this component should receive values from the communicator; false otherwise.

getIsSender

public boolean getIsSender()
Gets whether or not this component will send values.
Returns:
true if this component will send values to the communicator; false otherwise.

setIsSender

public void setIsSender(boolean value)
Sets whether or not this component should send values.
Parameters:
value - true if this component should send values to the communicator; false otherwise.

addComponentListener

public void addComponentListener(ComponentListener l)
Registers a ComponentListener. By doing so the ComponentListener can receive component events from this component.
Parameters:
l - the ComponentListener to register.

removeComponentListener

public void removeComponentListener(ComponentListener l)
Deregisters the ComponentListener.
Parameters:
l - the ComponentListener to remove.

registerCommunicator

public void registerCommunicator(AbstractCommunicator c,
                                 int ID)
The communicator uses this method to alert this component of its presence.
NOTE: This method is invoked by AbstractCommunicator and should therefore never be called directly by the user.
Parameters:
c - the communicator in question. Components implementing this interface should store the reference in order for the component to send values to the communicator.
ID - the ID number assigned to this component. Components implementing this interface should store the ID and use it each time they invoke putValue on a communicator.
See Also:
putValue(int, int, double, int), putValue(double, int, double, int), putValue(java.lang.String, int, double, int)

getTags

public int[] getTags()
The communicator uses this method to get all the tags used by this component.
NOTE: This method is invoked by AbstractCommunicator and should therefore never be called directly by the user.
Returns:
all tags used by this component

putValue

public void putValue(int value,
                     int aTag,
                     double time,
                     int ID)
Sets the value of this component. Typically invoked by a communicator that wishes to send a value to this component. Components implementing this interface should ignore the value if ID corresponds to the ID passed on to them when the communicator registered. This is to prevent unwanted "feedback-loops".
Parameters:
value - the value to be set
aTag - the tag of the component
time - a time tag for the value
ID - the ID of the component
See Also:
registerCommunicator(ControlBeans.AbstractCommunicator, int)

putValue

public void putValue(double value,
                     int aTag,
                     double time,
                     int ID)
Sets the value of this component. Typically invoked by a communicator that wishes to send a value to this component. Components implementing this interface should ignore the value if ID corresponds to the ID passed on to them when the communicator registered. This is to prevent unwanted "feedback-loops".
Parameters:
value - the value to be set
aTag - the tag of the component
time - a time tag for the value
ID - the ID of the component
See Also:
registerCommunicator(ControlBeans.AbstractCommunicator, int)

putValue

public void putValue(java.lang.String value,
                     int aTag,
                     double time,
                     int ID)
Sets the value of this component. Typically invoked by a communicator that wishes to send a value to this component. Components implementing this interface should ignore the value if ID corresponds to the ID passed on to them when the communicator registered. This is to prevent unwanted "feedback-loops".
Parameters:
value - the value to be set
aTag - the tag of the component
time - a time tag for the value
ID - the ID of the component
See Also:
registerCommunicator(ControlBeans.AbstractCommunicator, int)

requestValues

public void requestValues()
Called by the communicator to make this component send its value(s). This can be used for initialization.