de.steeringbehaviors.simulation.behaviors
Class Behavior

java.lang.Object
  extended by de.steeringbehaviors.simulation.behaviors.Behavior
All Implemented Interfaces:
ObjectAttributes
Direct Known Subclasses:
Alignment, Arrive, Cohesion, Containment, Evade, Flocking, ObstacleAvoidance, OffsetSeek, Pursuit, Seek, Separation, SimplePathfollowing, Wander

public class Behavior
extends java.lang.Object
implements ObjectAttributes

Base class for all steering behaviors


Field Summary
protected  java.lang.String m_behaviorName
          The name of the behavior.
protected  double m_influence
          Influence of the behavior on the overall force
protected  boolean m_needsNeighborhood
          Signals that the behavior needs access to a neighborhood simulation to function correctly
protected  Neighborhood m_neighborhood
          The neighborhood simulation to use for specific behaviors
 
Constructor Summary
Behavior()
          Constructor
 
Method Summary
 Vector2d calculate(Vehicle veh)
          Calculates the resulting force vector for this frame
 java.lang.String getBehaviorName()
           
 double getInfluence()
          Returns the influence of the behaviour on the overall steering force
 boolean needsNeighborhood()
          This function is used to signal if the behavior needs a Neighborhood simulation object to function correctly
 void setAttribute(java.lang.String name, java.lang.String value, java.util.Hashtable objectList)
          Sets a attribute specified by the name
 void setInfluence(double influence)
          Sets the influence of the behaviour
 void setNeighborhood(Neighborhood nh)
           
 boolean setSpecialObject(java.lang.String objectDesc, java.lang.Object specialObject)
          Use this function if you need to pass a special object to certain behaviors, but do not know which behavior really recognizes this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_behaviorName

protected java.lang.String m_behaviorName
The name of the behavior. Each class based on behavior overrides this with its own name.


m_influence

protected double m_influence
Influence of the behavior on the overall force


m_needsNeighborhood

protected boolean m_needsNeighborhood
Signals that the behavior needs access to a neighborhood simulation to function correctly


m_neighborhood

protected Neighborhood m_neighborhood
The neighborhood simulation to use for specific behaviors

Constructor Detail

Behavior

public Behavior()
Constructor

Method Detail

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value,
                         java.util.Hashtable objectList)
Sets a attribute specified by the name

Specified by:
setAttribute in interface ObjectAttributes
Parameters:
name - name of the attribute
value - value of the attribute
objectList - hashtable of all steeringobjects

setInfluence

public void setInfluence(double influence)
Sets the influence of the behaviour

Parameters:
influence - Influence of the behaviour

setNeighborhood

public void setNeighborhood(Neighborhood nh)

setSpecialObject

public boolean setSpecialObject(java.lang.String objectDesc,
                                java.lang.Object specialObject)
Use this function if you need to pass a special object to certain behaviors, but do not know which behavior really recognizes this object. If a behavior recognized the objectDesc, it will return true and cast the object to the correct type internally. If the behavior does not know the objectDesc, it will return false.

Parameters:
objectDesc - A string that represents a certain object type
specialObject - An instance of a special object that corresponds to the objectDesc
Returns:
True if the behvaior recognized the description, otherwise False

getBehaviorName

public java.lang.String getBehaviorName()
Returns:
The name of the behavior class

getInfluence

public double getInfluence()
Returns the influence of the behaviour on the overall steering force

Returns:
Influence of the behaviour

needsNeighborhood

public boolean needsNeighborhood()
This function is used to signal if the behavior needs a Neighborhood simulation object to function correctly

Returns:
True if a Neighborhood object is needed

calculate

public Vector2d calculate(Vehicle veh)
Calculates the resulting force vector for this frame

Parameters:
veh - The vehicle
Returns:
Returns the resulting force