de.steeringbehaviors.simulation.renderer
Class PolygonShape

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

public class PolygonShape
extends RenderInfo


Field Summary
protected  boolean m_filled
          Switch between filled or outlined polygon
protected  java.util.Vector m_points
          Array with the single polygon points
protected  java.awt.Polygon m_poly
          This is for speeding up the actual painting of the polygon
 
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
PolygonShape()
           
 
Method Summary
 void addPoint(Point2d p)
          Adds a new point to the end of the polygon description.
 void clearPoints()
          Clear the polygon description.
 java.awt.Color getColor()
          Returns the color of the shape
 double getFarthestDistance()
          Returns the distance of the point on the shape that is farthest away from the center of the geometrie.
 boolean getFilled()
           
 java.util.Iterator getPoints()
           
 java.awt.Polygon getPolygon()
           
 boolean isInside(double x, double y)
          Tests if the point is inside the shape
 void moveCenter(Vector2d relMove)
          Transforms the shape in local space.
 void setFilled(boolean filled)
           
 void setPoint(int index, Point2d p)
           
 void setPolygon(java.awt.Polygon p)
           
 
Methods inherited from class de.steeringbehaviors.simulation.renderer.RenderInfo
compareTo, getParent, getPos, getScaleX, getScaleY, getType, getZ, 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_points

protected java.util.Vector m_points
Array with the single polygon points


m_filled

protected boolean m_filled
Switch between filled or outlined polygon


m_poly

protected java.awt.Polygon m_poly
This is for speeding up the actual painting of the polygon

Constructor Detail

PolygonShape

public PolygonShape()
Method Detail

addPoint

public void addPoint(Point2d p)
Adds a new point to the end of the polygon description.

Parameters:
p - Next point to add

clearPoints

public void clearPoints()
Clear the polygon description.


moveCenter

public void moveCenter(Vector2d relMove)
Transforms the shape in local space.

Overrides:
moveCenter in class RenderInfo
Parameters:
relMove - Vector used to move the points

setFilled

public void setFilled(boolean filled)

setPoint

public void setPoint(int index,
                     Point2d p)
Parameters:
index -
p -

setPolygon

public void setPolygon(java.awt.Polygon p)

getColor

public java.awt.Color getColor()
Description copied from class: RenderInfo
Returns the color of the shape

Overrides:
getColor in class RenderInfo
Returns:
The color of the polygon

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

getFilled

public boolean getFilled()
Returns:
Filled or outlined drawing

getPoints

public java.util.Iterator getPoints()

getPolygon

public java.awt.Polygon getPolygon()
Returns:
The polygon used for drawing

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
zoom - The zoom factor used in drawing the shape
Returns:
True if the point is inside, False if not