de.steeringbehaviors.simulation.renderer
Class VectorShape

java.lang.Object
  extended by de.steeringbehaviors.simulation.renderer.RenderInfo
      extended by de.steeringbehaviors.simulation.renderer.VectorShape
All Implemented Interfaces:
java.lang.Comparable

public class VectorShape
extends RenderInfo

Version:
Author:
tom

Field Summary
protected  Vector2d m_drawVector
          The Vector as drawn on the screen
protected  double m_length
          Length of the vector
protected  Vector2d m_vector
          The vector
 
Fields inherited from class de.steeringbehaviors.simulation.renderer.RenderInfo
CIRCLE, INFOBOX, m_color, m_parent, m_pos, m_scaleX, m_scaleY, m_type, m_z, POLYGONSHAPE, RENDERINFO, TILE, VECTORSHAPE
 
Constructor Summary
VectorShape()
          Creates new VectorShape.
VectorShape(Vector2d vector)
          Creates new VectorShape
VectorShape(Vector2d vector, double length)
          Creates new VectorShape
 
Method Summary
 Vector2d getDrawVector()
           
 double getFarthestDistance()
          Returns the distance of the point on the shape that is farthest away from the center of the geometrie.
 double getLength()
           
 Vector2d getVector()
           
 boolean isInside(double x, double y)
          Tests if the point is inside the shape
 void setDrawVector(Vector2d vect)
           
 void setLength(double length)
           
 void setVector(Vector2d vector)
          Sets a new vector to be used for displaying.
 
Methods inherited from class de.steeringbehaviors.simulation.renderer.RenderInfo
compareTo, getColor, getParent, getPos, getScaleX, getScaleY, getType, getZ, moveCenter, setColor, setParent, setPos, setScaleX, setScaleY, setZ
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_vector

protected Vector2d m_vector
The vector


m_length

protected double m_length
Length of the vector


m_drawVector

protected Vector2d m_drawVector
The Vector as drawn on the screen

Constructor Detail

VectorShape

public VectorShape()
Creates new VectorShape. The vector is initialized to (1.0, 0.0) and a length of zero.


VectorShape

public VectorShape(Vector2d vector)
Creates new VectorShape


VectorShape

public VectorShape(Vector2d vector,
                   double length)
Creates new VectorShape

Method Detail

setDrawVector

public void setDrawVector(Vector2d vect)

setVector

public void setVector(Vector2d vector)
Sets a new vector to be used for displaying. The vector will be normalized automatically.

Parameters:
vector - The new vector

setLength

public void setLength(double length)
Parameters:
length - The new length of the vector

getDrawVector

public Vector2d getDrawVector()

getFarthestDistance

public double getFarthestDistance()
Returns the distance of the point on the shape that is farthest away from the center of the geometrie.

Overrides:
getFarthestDistance in class RenderInfo
Returns:
The farthest distance from the center of the geometrie

getLength

public double getLength()
Returns:
The length of the vector

getVector

public Vector2d getVector()
Returns:
The Vector

isInside

public boolean isInside(double x,
                        double y)
Tests if the point is inside the shape

Overrides:
isInside in class RenderInfo
Parameters:
x - The x position in screen coordinates
y - The y position in screen coordinates
Returns:
True if the point is inside, False if not