de.steeringbehaviors.simulation.behaviors
Class Flocking

java.lang.Object
  extended by de.steeringbehaviors.simulation.behaviors.Behavior
      extended by de.steeringbehaviors.simulation.behaviors.Flocking
All Implemented Interfaces:
ObjectAttributes

public class Flocking
extends Behavior

class Separation Implements the Flocking behaviour


Field Summary
protected  Alignment m_alignment
          Alignment behavior used in this behavior
protected  Cohesion m_cohesion
          Cohesion behavior used in this behavior
protected  int m_nearAreaRadius
          Radius of the area to be searched for relevant vehicles
protected  java.util.Vector m_nearVehicles
          Area of vehicles currently in the relevant area
protected  Neighborhood m_neighborhood
          Neighboorhood object used for area searches
protected  Separation m_separation
          Separation behavior used in this behavior
 
Fields inherited from class de.steeringbehaviors.simulation.behaviors.Behavior
m_behaviorName, m_influence, m_needsNeighborhood
 
Constructor Summary
Flocking()
          Constructor
Flocking(int nearAreaRadius, int influence)
          Constructor
 
Method Summary
 Vector2d calculate(Vehicle v)
          Calculates the resulting force vector for this frame
 void setAttribute(java.lang.String name, java.lang.String value, java.util.Hashtable objectList)
          Sets a attribute specified by the name
 void setInfluence(int influence)
          Sets the influence of the behaviour
 void setNearAreaRadius(int nearAreaRadius)
          Sets the radius of the area to be searched for relevant vehicles
 void setNeighborhood(Neighborhood nhood)
          Sets the neighborhood object to be used
 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 de.steeringbehaviors.simulation.behaviors.Behavior
getBehaviorName, getInfluence, needsNeighborhood, setInfluence
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_neighborhood

protected Neighborhood m_neighborhood
Neighboorhood object used for area searches


m_nearVehicles

protected java.util.Vector m_nearVehicles
Area of vehicles currently in the relevant area


m_nearAreaRadius

protected int m_nearAreaRadius
Radius of the area to be searched for relevant vehicles


m_separation

protected Separation m_separation
Separation behavior used in this behavior


m_alignment

protected Alignment m_alignment
Alignment behavior used in this behavior


m_cohesion

protected Cohesion m_cohesion
Cohesion behavior used in this behavior

Constructor Detail

Flocking

public Flocking()
Constructor


Flocking

public Flocking(int nearAreaRadius,
                int influence)
Constructor

Parameters:
nearAreaRadius - Radius of the area to be searched for relevant vehicles
influence - Influence of the behaviour
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
Overrides:
setAttribute in class Behavior
Parameters:
name - name of the attribute
value - value of the attribute
objectList - hashtable of all steeringobjects

setInfluence

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

Parameters:
influence - New influence

setNearAreaRadius

public void setNearAreaRadius(int nearAreaRadius)
Sets the radius of the area to be searched for relevant vehicles

Parameters:
nearAreaRadius - New area radius

setNeighborhood

public void setNeighborhood(Neighborhood nhood)
Sets the neighborhood object to be used

Overrides:
setNeighborhood in class Behavior
Parameters:
nhood - New neighborhood

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.

Overrides:
setSpecialObject in class Behavior
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

calculate

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

Overrides:
calculate in class Behavior
Parameters:
veh - The vehicle
Returns:
Returns the resulting force