cs015.Swarm
Class FollowLeaderBehavior

java.lang.Object
  extended byNGP.Timer
      extended bycs015.Swarm.BeeBehavior
          extended bycs015.Swarm.MoveBehavior
              extended bycs015.Swarm.FollowLeaderBehavior
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class FollowLeaderBehavior
extends MoveBehavior

This class represents a behavior that moves one Directional object towards another Directional object.

See Also:
MoveBehavior, BeeBehavior

Constructor Summary
FollowLeaderBehavior(Directional target, Locatable leader)
          This constructor builds this behavior with a Directional to act on and a Directional to follow.
FollowLeaderBehavior(Locatable leader)
          This constructor builds this behavior with a Directional to follow as a leader and a null Directional as its target.
 
Method Summary
 void activate()
          You should not call this method yourself. It will be called for you by the support code.
 BeeBehavior copy()
          This method returns a copy of the behavior.
 
Methods inherited from class cs015.Swarm.BeeBehavior
getTarget, setTarget
 
Methods inherited from class NGP.Timer
actionPerformed, getDelay, setDelay, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FollowLeaderBehavior

public FollowLeaderBehavior(Locatable leader)
This constructor builds this behavior with a Directional to follow as a leader and a null Directional as its target.

Parameters:
leader - the Locatable to follow.

FollowLeaderBehavior

public FollowLeaderBehavior(Directional target,
                            Locatable leader)
This constructor builds this behavior with a Directional to act on and a Directional to follow.

Parameters:
target - The Directional this behavior will act on.
leader - The Directional the target will be following.
Method Detail

activate

public void activate()
You should not call this method yourself. It will be called for you by the support code. This method is called at regular intervals to perform this behavior's actions. When called, this method updates the vector of its target to point towards the leader Directional. It then calls its inherited activate method.

Overrides:
activate in class MoveBehavior

copy

public BeeBehavior copy()
This method returns a copy of the behavior. It's target will be null. You will have to set the behavior's target using setTarget(...) method . The leader of the copy will be the same as the original behavior's.

Specified by:
copy in class BeeBehavior
Returns:
a new FollowLeaderBehavior without a target shape