edu.brook.ascape.model
Class DefaultScapeListener

java.lang.Object
  |
  +--edu.brook.ascape.model.DefaultScapeListener

public class DefaultScapeListener
extends java.lang.Object
implements ScapeListener

A listener to an agent scape. When a scape is updated, it is the listener's responsility to update itself, and then inform the scape that updating is finished, so that the scape can continue iterating through its rules. CanvasView provides a good reference implementation of the listener contract.

Since:
1.0
Version:
1.2.6

Field Summary
protected  java.lang.String name
          The name of the view.
 Scape scape
          The scape being listened to.
 
Constructor Summary
DefaultScapeListener()
           
 
Method Summary
 void addScape(Scape scape)
          Add a scape to this canvas.
 void DefaultScapeListener()
          Constructs a default listener.
 void DefaultScapeListener(java.lang.String name)
          Constructs a default listener.
 java.lang.String getName()
          Returns a name for the view as defined by set name.
 void removeScape(Scape scape)
          Removes the scape from this listener.
 void scapeUpdated(ScapeEvent e)
          Sends a REPORT_LISTENER_UPDATED event back to the scape indicating that this listener has been updated.
 void setName(java.lang.String name)
          Sets the name of this view.
 java.lang.String toString()
          Returns a short description of this view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

scape

public Scape scape
The scape being listened to.

name

protected java.lang.String name
The name of the view.
Constructor Detail

DefaultScapeListener

public DefaultScapeListener()
Method Detail

DefaultScapeListener

public void DefaultScapeListener()
Constructs a default listener.

DefaultScapeListener

public void DefaultScapeListener(java.lang.String name)
Constructs a default listener.
Parameters:
name - a user relevant name for this view

addScape

public void addScape(Scape scape)
              throws java.util.TooManyListenersException
Add a scape to this canvas. A default scape listener can be assigned only one scape.
Specified by:
addScape in interface ScapeListener
Parameters:
scape - the scape to make this canvas the observer of
Throws:
java.util.TooManyListenersException - on attempt to add a scape when one is allready added

removeScape

public void removeScape(Scape scape)
Removes the scape from this listener. Null expected.
Specified by:
removeScape in interface ScapeListener
Parameters:
scape - the scape to remove

scapeUpdated

public void scapeUpdated(ScapeEvent e)
Sends a REPORT_LISTENER_UPDATED event back to the scape indicating that this listener has been updated. Call this super method after doing any updates, obviously.
Specified by:
scapeUpdated in interface ScapeListener

getName

public java.lang.String getName()
Returns a name for the view as defined by set name.

setName

public final void setName(java.lang.String name)
Sets the name of this view.
Parameters:
name - a user relevant name for this view

toString

public java.lang.String toString()
Returns a short description of this view. Sames as name unless overridden.
Overrides:
toString in class java.lang.Object

(c) 1998-2000 The Brookings Insitution
Webpage