source.ucregents.playground.physics
Class FieldForceEntity

java.lang.Object
  extended by source.ucregents.playground.physics.BaseEntity
      extended by source.ucregents.playground.physics.BaseFieldForceEntity
          extended by source.ucregents.playground.physics.FieldForceEntity
All Implemented Interfaces:
java.lang.Cloneable, IForceEntity

public class FieldForceEntity
extends BaseFieldForceEntity

The ForceEntity class creates an entity which produces a "force" which can attract or repel "MovingEntities" and can act uniformly on the playing field or drop off over a distance. The ForceEntity does not move itself.


Constructor Summary
FieldForceEntity()
          Constructs a default field force entity at 0,0 with 1 width and 1 height and 0 magnitude
FieldForceEntity(int x_loc, int y_loc, int width, int height, javax.vecmath.Vector2d force)
          Constructs a custom field force entity with the given parameters
FieldForceEntity(PolygonOrCircle forceShape, boolean isVisible, javax.vecmath.Vector2d force)
          Constructs a custom field force entity with the given parameters
 
Method Summary
 java.lang.Object clone()
           
 void Draw(java.awt.Graphics2D g, boolean verbose)
          Draws the field force
 javax.vecmath.Vector2d getForceFor(MovingEntity be)
          Calculats the force to act on another entity
 double getXComponent()
          Gets the x component of the force field
 double getYComponent()
          Gets the y component of the force field
 void setXComponent(double f)
          Sets the x component of the force field
 void setYComponent(double f)
          Sets the y component of the force field
 
Methods inherited from class source.ucregents.playground.physics.BaseFieldForceEntity
DefaultImageLocation, getResizingObject, IntersectsWith, isCollidable, OnCenterScale, OnLocationChange, OnULScale
 
Methods inherited from class source.ucregents.playground.physics.BaseEntity
calculateAxes, Deserialize, getActualFrameDimensions, getAxes, getAxesClone, getAxis, getBounciness, getCenterPoint, getDrawType, getEvents, getFrameColor, getFrictionConstant, getGradientColor, getImageOffset, getName, getOrientation, getRoundedShapeMass, getScale, getShape, getShapeColor, getShapeFrame, getShapeMass, getSideVectors, getULPoint, getUserEvents, getVertexCount, getVerticesCoordinates, isCircle, isOverlapping, isPolygon, isSelected, isVisible, OnCollisionWith, OnOrientationChange, RegisterEvent, RegisterEvent, RegisterEvents, RemoveEvent, RemoveEvents, resetFrameColor, Scale, ScaleAroundCenter, Serialize, setBounciness, setCenterPoint, setCenterPoint, setCollidable, setDrawType, setFrameColor, setFrictionConstant, setGradientColor, setImageOffset, setName, setOrientation, setScale, setSelected, setShapeColor, setULPoint, setULPoint, setVisible, toString, toXMLElement
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FieldForceEntity

public FieldForceEntity()
Constructs a default field force entity at 0,0 with 1 width and 1 height and 0 magnitude


FieldForceEntity

public FieldForceEntity(int x_loc,
                        int y_loc,
                        int width,
                        int height,
                        javax.vecmath.Vector2d force)
Constructs a custom field force entity with the given parameters

Parameters:
x_loc - X location
y_loc - Y location
width - Field width
height - Field height
force - A vector2d of the force

FieldForceEntity

public FieldForceEntity(PolygonOrCircle forceShape,
                        boolean isVisible,
                        javax.vecmath.Vector2d force)
Constructs a custom field force entity with the given parameters

Parameters:
forceShape - Bounding field rectangle
isVisible - Field Visibility
force - Vector2d of the force
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class BaseFieldForceEntity

Draw

public void Draw(java.awt.Graphics2D g,
                 boolean verbose)
Draws the field force

Overrides:
Draw in class BaseFieldForceEntity
Parameters:
g - The graphics2d to be drawn

getForceFor

public javax.vecmath.Vector2d getForceFor(MovingEntity be)
Calculats the force to act on another entity

Parameters:
be - The base entity to get a force for
Returns:
A vector2d of the force to act on the parameter entity

getXComponent

public double getXComponent()
Gets the x component of the force field

Returns:
The x component of the force field

getYComponent

public double getYComponent()
Gets the y component of the force field

Returns:
The y component of the force field

setXComponent

public void setXComponent(double f)
Sets the x component of the force field

Parameters:
f - The new x component of the force field

setYComponent

public void setYComponent(double f)
Sets the y component of the force field

Parameters:
f - The new y component of the force field