Class Particle

java.lang.Object
  extended by Particle
Direct Known Subclasses:
BoundsParticle, GravityParticle, LineParticle, OrbitParticle, SquareParticle

public class Particle
extends java.lang.Object

A Particle is a 2D colored dot that follows basic physics. It has a velocity and is affected by gravity. It is able to move itself and to draw itself.

Author:
Tim

Constructor Summary
Particle(double hue, double startX, double startY)
          Creates a new Particle based on the given parameters.
 
Method Summary
 void drawSelf(java.awt.Graphics graphics)
          Draw this Particle onto the provided Graphics object
 java.awt.Color getColor()
          Get the color of this particle
 int getTimesMoved()
          Return the number of times this Particle has been moved.
 double getXPosition()
          Return the X position of this Particle
 double getXVelocity()
          Return the X velocity of this Particle
 double getYPosition()
          Return the Y position of this Particle
 double getYVelocity()
           
 void setXPosition(double position)
          Set the x position
 void setXVelocity(double velocity)
          Set the x velocity
 void setYPosition(double position)
          Set the y position
 void setYVelocity(double velocity)
          Sets the y velocity
 void takeOneStep()
          Move this Particle one frame's worth of movement
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Particle

public Particle(double hue,
                double startX,
                double startY)
Creates a new Particle based on the given parameters. You can specify the color and position. The velocity is randomly determined. The coordinates should be in java coordinates, so (0,0) is the upper lefthand corner
If you give 0 for the color, you get green. .2 gives orange, .3 gives pink, .4 gives magenta, .5 gives violet, .6 gives blue, .8 gives cyan, and 1 returns to green.

Parameters:
hue - A number from 0 to 1 that specifies desired hue of the Particle
startX - The starting x coordinate
startY - The starting y coordinate
Method Detail

drawSelf

public void drawSelf(java.awt.Graphics graphics)
Draw this Particle onto the provided Graphics object

Parameters:
graphics - The Graphics object to draw onto.

takeOneStep

public void takeOneStep()
Move this Particle one frame's worth of movement


getTimesMoved

public int getTimesMoved()
Return the number of times this Particle has been moved.

Returns:
The number of times this particle has been moved

getXPosition

public double getXPosition()
Return the X position of this Particle

Returns:
The X position

getYPosition

public double getYPosition()
Return the Y position of this Particle

Returns:
The Y position

getXVelocity

public double getXVelocity()
Return the X velocity of this Particle

Returns:
The X velocity

getYVelocity

public double getYVelocity()
Returns:
the yVelocity

setXPosition

public void setXPosition(double position)
Set the x position

Parameters:
position - the xPosition to set

setYPosition

public void setYPosition(double position)
Set the y position

Parameters:
position - the yPosition to set

setXVelocity

public void setXVelocity(double velocity)
Set the x velocity

Parameters:
velocity - the xVelocity to set

setYVelocity

public void setYVelocity(double velocity)
Sets the y velocity

Parameters:
velocity - the yVelocity to set

getColor

public java.awt.Color getColor()
Get the color of this particle

Returns:
the color of this particle