net.nexttext.behaviour
Class AbstractBehaviour

java.lang.Object
  extended by net.nexttext.behaviour.AbstractBehaviour
Direct Known Subclasses:
Behaviour

public abstract class AbstractBehaviour
extends java.lang.Object

AbstractBehaviours act on a list of TextObjects, and are included in the simulation.

The TextObjects to act on are stored in a list internal to the Behaviour. To include an AbstractBehaviour in the simulation, it is added to the book, which calls the behaveAll() method, triggering the behaviour to call actions on each of its TextObjects. Subclasses of AbstractBehaviour differ in how they implement the behaveAll() method.


Constructor Summary
AbstractBehaviour()
           
 
Method Summary
 void addObject(TextObject to)
          Add a TextObject to this Behaviour's list of objects to act on.
abstract  void behaveAll()
          Behave on every TextObject in the list.
 java.lang.String getDisplayName()
          Returns the display name of this instance.
 void removeObject(TextObject to)
          Stop this behaviour from acting on a TextObject.
 void setDisplayName(java.lang.String name)
          Sets the display name of this Action instance to the specified string.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractBehaviour

public AbstractBehaviour()
Method Detail

setDisplayName

public void setDisplayName(java.lang.String name)
Sets the display name of this Action instance to the specified string.


getDisplayName

public java.lang.String getDisplayName()
Returns the display name of this instance. If no particular display name was specified, the class name is used by default.


behaveAll

public abstract void behaveAll()
Behave on every TextObject in the list.

This method is called as part of the simulation, and when a behaviour has been added to the Book. Different subclasses will implement this method in different ways.


addObject

public void addObject(TextObject to)
Add a TextObject to this Behaviour's list of objects to act on.

Each Action requires a specific set of properties in TextObjects that it acts on. These properties are added to the TextObjects when they are added to a behaviour for each Action which is a part of that behaviour. Subclasses of AbstractBehaviour have to be sure to perform this necessary step, by overriding this method, (but don't forget to call super.addObject()). Behaviour provides a good example of how to do this.

If the TextObject is already in the set, nothing will be done, a single remove will still remove the object from the list.


removeObject

public void removeObject(TextObject to)
Stop this behaviour from acting on a TextObject.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object