visad.collab
Class DisplayMonitorImpl

java.lang.Object
  extended by visad.collab.DisplayMonitorImpl
All Implemented Interfaces:
Serializable, EventListener, DisplayMonitor, ControlListener, DisplayListener, MessageListener, ScalarMapListener

public class DisplayMonitorImpl
extends Object
implements DisplayMonitor

DisplayMonitorImpl is the Display monitor implementation.

DisplayMonitorImpl is not Serializable and should not be copied between JVMs.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface visad.collab.DisplayMonitor
UNKNOWN_LISTENER_ID
 
Constructor Summary
DisplayMonitorImpl(DisplayImpl dpy)
          Creates a monitor for the specified Display.
 
Method Summary
 void addListener(MonitorCallback listener, int id)
          Adds the specified listener to receive MonitorEvents when the monitored Display's state changes.
 void addListener(RemoteDisplay rmtDpy, int id)
          Adds the specified remote display to receive MonitorEvents when the monitored Display's state changes.
 void addRemoteListener(RemoteDisplay rd)
          Initializes links so that MonitorEvents will be exchanged with the specified remote Display.
 int checkID(int id)
          Returns a suggestion for a unique listener identifier which is equal to or greater than the supplied ID.
 void controlChanged(ControlEvent evt)
          Handles Control changes.
 void controlChanged(ScalarMapControlEvent evt)
          Handles ScalarMap control changes.
 void destroy()
          destroy this monitor
 void displayChanged(DisplayEvent evt)
          Handles notification of objects being added to or removed from the Display.
 int getConnectionID(RemoteDisplay rmtDpy)
          Return the ID associated with the specified RemoteDisplay.
 boolean hasEventQueued(Control ctl)
          Returns true if there is a MonitorEvent for the specified Control waiting to be delivered to any listener.
 boolean hasEventQueued(int listenerID, Control ctl)
          Returns true if there is a MonitorEvent for the specified Control waiting to be delivered to the listener with the specified id.
 boolean isEmpty()
           
 void mapChanged(ScalarMapEvent evt)
          Handles ScalarMap data changes.
 void notifyListeners(MonitorEvent evt)
          Forwards the MonitorEvent to all the listeners associated with this DisplayMonitor.
 void receiveMessage(MessageEvent msg)
          Handles MessageEvent forwarding.
 void removeListener(MonitorCallback l)
          Stops forwarding MonitorEvents to the specified listener.
 void setDisplaySync(DisplaySync sync)
          Set the display synchronization object for this display
 String toString()
          Returns the name of this DisplayMonitor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DisplayMonitorImpl

public DisplayMonitorImpl(DisplayImpl dpy)
Creates a monitor for the specified Display.

Parameters:
dpy - The Display to monitor.
Method Detail

addListener

public void addListener(MonitorCallback listener,
                        int id)
                 throws RemoteException,
                        VisADException
Adds the specified listener to receive MonitorEvents when the monitored Display's state changes.

Specified by:
addListener in interface DisplayMonitor
Parameters:
listener - The listener to add.
id - The unique listener identifier.
Throws:
VisADException - If the listener Vector is uninitialized.
RemoteException - If there was an RMI-related problem.

addListener

public void addListener(RemoteDisplay rmtDpy,
                        int id)
                 throws RemoteException,
                        VisADException
Adds the specified remote display to receive MonitorEvents when the monitored Display's state changes.

Specified by:
addListener in interface DisplayMonitor
Parameters:
rmtDpy - The remote display to add.
id - The unique listener identifier.
Throws:
VisADException - If the listener Vector is uninitialized.
RemoteException - If there was an RMI-related problem.

addRemoteListener

public void addRemoteListener(RemoteDisplay rd)
                       throws RemoteException,
                              RemoteVisADException
Initializes links so that MonitorEvents will be exchanged with the specified remote Display.

Specified by:
addRemoteListener in interface DisplayMonitor
Parameters:
rd - The remote Display to synchronize.
Throws:
RemoteException - If there was an RMI-related problem.
RemoteVisADException - If the inter-Display links could not be made.

checkID

public int checkID(int id)
Returns a suggestion for a unique listener identifier which is equal to or greater than the supplied ID.

Specified by:
checkID in interface DisplayMonitor
Parameters:
id - The identifier to check.

controlChanged

public void controlChanged(ControlEvent evt)
Handles Control changes.

If the ControlEvent is not ignored, a ControlMonitorEvent will be sent to all listeners.

Specified by:
controlChanged in interface ControlListener
Parameters:
evt - The details of the Control change.

controlChanged

public void controlChanged(ScalarMapControlEvent evt)
Handles ScalarMap control changes.
This is just a stub which ignores the event.

Specified by:
controlChanged in interface ScalarMapListener
Parameters:
evt - The details of the ScalarMap change.

destroy

public void destroy()
destroy this monitor

Specified by:
destroy in interface DisplayMonitor

displayChanged

public void displayChanged(DisplayEvent evt)
Handles notification of objects being added to or removed from the Display.

If the DisplayEvent is not ignored, a MapMonitorEvent or ReferenceMonitorEvent will be sent to all listeners.

Specified by:
displayChanged in interface DisplayListener
Parameters:
evt - The details of the Display change.

getConnectionID

public int getConnectionID(RemoteDisplay rmtDpy)
Return the ID associated with the specified RemoteDisplay.

Specified by:
getConnectionID in interface DisplayMonitor
Returns:
UNKNOWN_LISTENER_ID if not found; otherwise, returns the ID.

hasEventQueued

public boolean hasEventQueued(Control ctl)
Returns true if there is a MonitorEvent for the specified Control waiting to be delivered to any listener.

Specified by:
hasEventQueued in interface DisplayMonitor
Parameters:
ctl - The Control being found.

hasEventQueued

public boolean hasEventQueued(int listenerID,
                              Control ctl)
Returns true if there is a MonitorEvent for the specified Control waiting to be delivered to the listener with the specified id.

Specified by:
hasEventQueued in interface DisplayMonitor
Parameters:
listenerID - The identifier for the listener.
ctl - The Control being found.

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface DisplayMonitor

mapChanged

public void mapChanged(ScalarMapEvent evt)
Handles ScalarMap data changes.

If the ScalarMapEvent is not ignored, a MapMonitorEvent will be sent to all listeners.

Specified by:
mapChanged in interface ScalarMapListener
Parameters:
evt - The details of the ScalarMap change.

notifyListeners

public void notifyListeners(MonitorEvent evt)
Forwards the MonitorEvent to all the listeners associated with this DisplayMonitor.

Specified by:
notifyListeners in interface DisplayMonitor
Parameters:
evt - The event to forward.

receiveMessage

public void receiveMessage(MessageEvent msg)
Handles MessageEvent forwarding.

Specified by:
receiveMessage in interface MessageListener
Parameters:
msg - The message to forward.

removeListener

public void removeListener(MonitorCallback l)
Stops forwarding MonitorEvents to the specified listener.

Parameters:
l - Listener to remove.

setDisplaySync

public void setDisplaySync(DisplaySync sync)
Set the display synchronization object for this display

Specified by:
setDisplaySync in interface DisplayMonitor

toString

public String toString()
Returns the name of this DisplayMonitor.

Overrides:
toString in class Object