All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ControlBeans.AbstractCommunicator

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.JPanel
                                   |
                                   +----ControlBeans.AbstractCommunicator

public abstract class AbstractCommunicator
extends JPanel
implements ComponentListener
This class is the class from which all communicator classes should be inherited. AbstractCommuncator contains the methods and mechanisms needed to allow components to register with it and have values passed on to them. It is also prepared to allow custom communication with other classes, thus passing values to and from the components which have registered.


Variable Index

 o CURRENT_TIME
Constant used by classes invoking putValue.
 o myID
The ID of the AbstractCommunicator.

Constructor Index

 o AbstractCommunicator()
Constructs a new AbstractCommunicator.

Method Index

 o putValue(double, int, double, int)
This method is invoked by components that wish to send double values through this communicator.
 o putValue(int, int, double, int)
This method is invoked by components that wish to send integer values through this communicator.
 o putValue(String, int, double, int)
This method is invoked by components that wish to send string values through this communicator.
 o registerComponentEvent(ComponentEvent)
Inherited from ComponentListener.
 o requestValues()
Sends a request to all components to make them send their value(s).
 o sendValue(double, int, double)
This method should be implemented by subclasses that wish to communicate with other classes.
 o sendValue(int, int, double)
This method should be implemented by subclasses that wish to communicate with other classes.
 o sendValue(String, int, double)
This method should be implemented by subclasses that wish to communicate with other classes.

Variables

 o myID
 protected static final int myID
The ID of the AbstractCommunicator.

 o CURRENT_TIME
 public static final double CURRENT_TIME
Constant used by classes invoking putValue. If a value being passed has time set to this constant, this communicator will change the time to the number of milliseconds passed since the creation of it.

Constructors

 o AbstractCommunicator
 public AbstractCommunicator()
Constructs a new AbstractCommunicator.

Methods

 o registerComponentEvent
 public void registerComponentEvent(ComponentEvent e)
Inherited from ComponentListener. This method receives a component that wishes to register with this communicator. The component is stored within it and a reply is sent to the component, thus alerting the component of the communicators presence.

Parameters:
e - the event itself.
 o putValue
 public final void putValue(int value,
                            int aTag,
                            double time,
                            int ID)
This method is invoked by components that wish to send integer values through this communicator.
If time corresponds to AbstractCommunicator.CURRENT_TIME, time will be set to the number of milliseconds passed since the creation of this communicator.
If ID does not correspond to AbstractCommunicator.myID, this method will invoke sendValue().
Subclasses that wish to send values to the components registered with this communicator should also invoke this method with ID set to AbstractCommuncator.myID (thus preventing the invokation of sendValue()).

Parameters:
value - the value to be transmitted
aTag - the tag of components to receive the value
time - a time tag for the value
ID - the ID-number of component which sent the value
 o putValue
 public final void putValue(double value,
                            int aTag,
                            double time,
                            int ID)
This method is invoked by components that wish to send double values through this communicator.
If time corresponds to AbstractCommunicator.CURRENT_TIME, time will be set to the number of milliseconds passed since the creation of this communicator.
If ID does not correspond to AbstractCommunicator.myID, this method will invoke sendValue().
Subclasses that wish to send values to the components registered with this communicator should also invoke this method with ID set to AbstractCommuncator.myID (thus preventing the invokation of sendValue()).

Parameters:
value - the value to be transmitted
aTag - the tag of components to receive the value
time - a time tag for the value
ID - the ID-number of component which sent the value
 o putValue
 public final void putValue(String value,
                            int aTag,
                            double time,
                            int ID)
This method is invoked by components that wish to send string values through this communicator.
If time corresponds to AbstractCommunicator.CURRENT_TIME, time will be set to the number of milliseconds passed since the creation of this communicator.
If ID does not correspond to AbstractCommunicator.myID, this method will invoke sendValue().
Subclasses that wish to send values to the components registered with this communicator should also invoke this method with ID set to AbstractCommuncator.myID (thus preventing the invokation of sendValue()).

Parameters:
value - the value to be transmitted
aTag - the tag of components to receive the value
time - a time tag for the value
ID - the ID-number of component which sent the value
 o requestValues
 public final void requestValues()
Sends a request to all components to make them send their value(s).

 o sendValue
 protected abstract void sendValue(int value,
                                   int aTag,
                                   double time)
This method should be implemented by subclasses that wish to communicate with other classes. This method will be invoked by putValue if ID does not correspont to AbstractCommuncator.myID. The method putValue is in turn invoked by a component when it wishes to send a value.

Parameters:
value - the value to be transmitted
aTag - the tag of components to receive the value
time - a time tag for the value
 o sendValue
 protected abstract void sendValue(double value,
                                   int aTag,
                                   double time)
This method should be implemented by subclasses that wish to communicate with other classes. This method will be invoked by putValue if ID does not correspont to AbstractCommuncator.myID. The method putValue is in turn invoked by a component when it wishes to send a value.

Parameters:
value - the value to be transmitted
aTag - the tag of components to receive the value
time - a time tag for the value
 o sendValue
 protected abstract void sendValue(String value,
                                   int aTag,
                                   double time)
This method should be implemented by subclasses that wish to communicate with other classes. This method will be invoked by putValue if ID does not correspont to AbstractCommuncator.myID. The method putValue is in turn invoked by a component when it wishes to send a value.

Parameters:
value - the value to be transmitted
aTag - the tag of components to receive the value
time - a time tag for the value

All Packages  Class Hierarchy  This Package  Previous  Next  Index