CSE115.BouncyShapes
Class Oval

java.lang.Object
  extended byNGP.Graphics.Shape
      extended byNGP.Graphics.RectangularShape
          extended byNGP.Graphics.FilledRectangularShape
              extended byNGP.Graphics.FilledEllipse
                  extended byCSE115.BouncyShapes.Oval
All Implemented Interfaces:
Colorable, EventListener, Graphic, Locatable, MouseListener, MouseMotionListener, Reactor, Rotatable, Shape, Sizeable

public class Oval
extends FilledEllipse
implements Shape

A oval that moves when told to. Must be used with either cs015.SP.Frame or cs015.SP.Applet (or their subclasses). Created: Sun Feb 10 15:00:55 2002

Author:
Carl G. Alphonce

Field Summary
 
Fields inherited from class NGP.Graphics.Shape
_awtShape, _dpanel
 
Fields inherited from interface NGP.Colorable
DEFAULT_GRAY
 
Constructor Summary
Oval()
          Creates a new Oval instance.
 
Method Summary
 int getDx()
          Get the change in x.
 int getDy()
          Get the change in y.
 void setAcceleration(Vector dV)
          Sets the acceleration (change in velocity) of the oval using a vector.
 void setDimension(Dimension d)
           
 void setFrameDelay(int milliseconds)
          Sets the delay in milliseconds between calls to move().
 void setSize(int newHeight)
          Set the diameter.
 void setVelocity(int dx, int dy)
          Sets the velocity, in the x and y directions of the oval.
 void update()
          Update the position of the oval based on the velocity, if the oval hits a wall, reverses velocity in the appropriate direction.
 
Methods inherited from class NGP.Graphics.FilledRectangularShape
actualPaint
 
Methods inherited from class NGP.Graphics.RectangularShape
getDimension, getLocation, setCenterLocation, setLocation, unwrap, wrap
 
Methods inherited from class NGP.Graphics.Shape
contains, drag, getBounds, getCenterLocation, getColor, getDrawingPanel, getRotation, hide, intersects, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, paint, react, setColor, setDrawingPanel, setRotation, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface NGP.Graphic
contains, getBounds, getCenterLocation, getDrawingPanel, hide, intersects, paint, setDrawingPanel, show
 
Methods inherited from interface NGP.Reactor
react
 
Methods inherited from interface java.awt.event.MouseListener
mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased
 
Methods inherited from interface java.awt.event.MouseMotionListener
mouseDragged, mouseMoved
 
Methods inherited from interface NGP.Rotatable
getRotation, setRotation
 
Methods inherited from interface NGP.Locatable
getLocation, setLocation
 
Methods inherited from interface NGP.Sizeable
getDimension
 
Methods inherited from interface NGP.Colorable
getColor, setColor
 

Constructor Detail

Oval

public Oval()
Creates a new Oval instance.

Method Detail

update

public void update()
Update the position of the oval based on the velocity, if the oval hits a wall, reverses velocity in the appropriate direction.

Specified by:
update in interface Shape

setAcceleration

public void setAcceleration(Vector dV)
Sets the acceleration (change in velocity) of the oval using a vector.

Specified by:
setAcceleration in interface Shape
Parameters:
dV - the acceleration (change in velocity) vector

setVelocity

public void setVelocity(int dx,
                        int dy)
Sets the velocity, in the x and y directions of the oval.

Parameters:
dx - the new change in x value.
dy - the new change in y value.

getDx

public int getDx()
Get the change in x.

Returns:
the change in x.

getDy

public int getDy()
Get the change in y.

Returns:
the change in y.

setSize

public void setSize(int newHeight)
Set the diameter.

Parameters:
newHeight - the new height.

setDimension

public void setDimension(Dimension d)
Specified by:
setDimension in interface Sizeable

setFrameDelay

public void setFrameDelay(int milliseconds)
Sets the delay in milliseconds between calls to move().

Parameters:
milliseconds - the delay in milliseconds.