ballworlds.ball
Class Mover

java.lang.Object
  extended by ballworlds.ball.Ball
      extended by ballworlds.ball.Dud
          extended by ballworlds.ball.DudThatMoves
              extended by ballworlds.ball.Mover
All Implemented Interfaces:
Animate, Drawable, Relocatable
Direct Known Subclasses:
Bouncer

public class Mover
extends DudThatMoves

A Mover starts in the exact middle of its world (even if its world is resized). Each Mover has its own fixed velocity that is set at random when the Mover is constructed. Additionally, the Mover is "selectable", "draggable", and "killable" by the mouse.

Author:
David Mutchler. Created March 20, 2009.

Constructor Summary
Mover(BallEnvironment ballEnvironment)
          Adds the Mover to its World at the middle of the World with the default color and diameter for a Mover, and with a constant but randomly chosen velocity.
 
Method Summary
 void act()
          Act unless the Mover is paused.
 void die()
          Removes the Animate object from its World.
 double distanceFrom(Point2D point)
          Returns the distance that the Relocatable object is from the given Point2D.
protected  boolean isPaused()
          Returns the value of the field called 'isPaused'.
 void moveTo(Point2D point)
          Moves the Relocatable object to the given Point2D, by setting its position (part of its Shape) to the given Point2D.
 void pauseOrResume()
          Toggles between the "paused" and "not-paused" state.
 
Methods inherited from class ballworlds.ball.DudThatMoves
getVelocity, setVelocity
 
Methods inherited from class ballworlds.ball.Dud
getBallEnvironment, getColor, getDiameter, getLocation, getShape, setColor, setDiameter, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mover

public Mover(BallEnvironment ballEnvironment)
Adds the Mover to its World at the middle of the World with the default color and diameter for a Mover, and with a constant but randomly chosen velocity.

Parameters:
ballEnvironment - the object that manages Balls in this World
Method Detail

distanceFrom

public double distanceFrom(Point2D point)
Description copied from interface: Relocatable
Returns the distance that the Relocatable object is from the given Point2D.

Specified by:
distanceFrom in interface Relocatable
Overrides:
distanceFrom in class Dud
Parameters:
point - the Point2D from which the distance is desired.
Returns:
the distance that the Relocatable object is from the given Point2D.

moveTo

public void moveTo(Point2D point)
Description copied from interface: Relocatable
Moves the Relocatable object to the given Point2D, by setting its position (part of its Shape) to the given Point2D.

Specified by:
moveTo in interface Relocatable
Overrides:
moveTo in class Dud
Parameters:
point - the Point2D to which the Relocatable object should move.

act

public void act()
Act unless the Mover is paused.

Specified by:
act in interface Animate
Overrides:
act in class DudThatMoves

die

public void die()
Description copied from interface: Animate
Removes the Animate object from its World. Thus, the Animate object is no longer asked to act and is no longer drawn.

Specified by:
die in interface Animate
Overrides:
die in class Dud

pauseOrResume

public void pauseOrResume()
Description copied from interface: Animate
Toggles between the "paused" and "not-paused" state. During the paused state, the act() method should do nothing.

Specified by:
pauseOrResume in interface Animate
Overrides:
pauseOrResume in class Dud

isPaused

protected final boolean isPaused()
Returns the value of the field called 'isPaused'.

Returns:
Returns the isPaused.