de.steeringbehaviors.simulation.behaviors
Class Alignment

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

public class Alignment
extends Behavior

class Separation Implements the Alignment behaviour


Field Summary
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
 
Fields inherited from class de.steeringbehaviors.simulation.behaviors.Behavior
m_behaviorName, m_influence, m_needsNeighborhood
 
Constructor Summary
Alignment()
          Constructor
Alignment(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

Constructor Detail

Alignment

public Alignment()
Constructor


Alignment

public Alignment(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