fishbowl
Class MovingBodyAdapter

java.lang.Object
  extended by fishbowl.MovingBodyAdapter
All Implemented Interfaces:
CenterLocatable, Colorable, ColorableGraphic, Graphic, Locatable, Rotatable, Sizeable, MovingBody

public abstract class MovingBodyAdapter
extends Object
implements MovingBody

Normal users can ignore this class. A class that implements many of the methods of MovingBody by delegating the work to Shape objects. This class is only made available for those wishing to create new type of MovingBody classes. Created: Sat Jan 31 14:56:17 2004

Author:
Phil Ventura

Field Summary
protected  Shape _delegate
          The Shape object to delegate calls to.
protected  Vector _vector
          Vector used for motion.
 
Constructor Summary
MovingBodyAdapter(Shape delegate)
          Creates a new MovingBodyAdapter instance.
MovingBodyAdapter(Shape delegate, int x_low, int x_high, int y_low, int y_high)
           
 
Method Summary
 boolean contains(Point param1)
          Delegated to the shape.
 Rectangle getBounds()
          Delegated to the shape.
 Point getCenterLocation()
          Delegated to the shape.
 Color getColor()
          Delegated to the shape.
 Dimension getDimension()
          Delegated to the shape.
 Integer getDx()
          Get the change in x.
 Integer getDy()
          Get the change in y.
 Point getLocation()
          Delegated to the shape.
 Integer getRotation()
          Delegated to the shape.
 Vector getVector()
          Returns the motion vector for this MovingBody
 void hide()
          Delegated to the shape.
 boolean intersects(Graphic param1)
          Delegated to the shape.
 void mouseClicked(MouseEvent param1)
          Delegated to the shape.
 void mouseDragged(MouseEvent param1)
          Delegated to the shape.
 void mouseEntered(MouseEvent param1)
          Delegated to the shape.
 void mouseExited(MouseEvent param1)
          Delegated to the shape.
 void mouseMoved(MouseEvent param1)
          Delegated to the shape.
 void mousePressed(MouseEvent param1)
          Delegated to the shape.
 void mouseReleased(MouseEvent param1)
          Delegated to the shape.
 void paint(Graphics2D param1)
          Delegated to the shape.
 void react()
           
 void setColor(Color param1)
          Delegated to the shape.
 void setDimension(Dimension param1)
          Delegated to the shape.
 void setFrameDelay(int milliseconds)
          Sets the delay in milliseconds between calls to move().
 void setLocation(Point param1)
          Delegated to the shape.
 void setRotation(int param1)
          Delegated to the shape.
 void setVector(Vector newVector)
          Change the vector motion of this MovingBody
 void show()
          Delegated to the shape.
 void startBouncing()
          Start (global) bouncing behavior.
 void stopBouncing()
          Stop (global) bouncing behavior.
 void update()
          Update the position of the ball based on the velocity, if the ball hits a wall, reverses velocity in the appropriate direction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cse115.graphics.Graphic
actualPaint, addMouseListener, addMouseMotionListener, getMouseListeners, getMouseMotionListeners, getShape, setContainer
 
Methods inherited from interface cse115.graphics.CenterLocatable
setCenterLocation
 
Methods inherited from interface cse115.graphics.Locatable
move
 
Methods inherited from interface cse115.graphics.Rotatable
rotate, setRotation
 

Field Detail

_vector

protected Vector _vector
Vector used for motion.


_delegate

protected Shape _delegate
The Shape object to delegate calls to.

Constructor Detail

MovingBodyAdapter

public MovingBodyAdapter(Shape delegate)
Creates a new MovingBodyAdapter instance.

Parameters:
delegate - the shape that does the work.

MovingBodyAdapter

public MovingBodyAdapter(Shape delegate,
                         int x_low,
                         int x_high,
                         int y_low,
                         int y_high)
Method Detail

update

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

Specified by:
update in interface MovingBody

getDx

public Integer getDx()
Get the change in x.

Returns:
the change in x.

getDy

public Integer getDy()
Get the change in y.

Returns:
the change in y.

setFrameDelay

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

Parameters:
milliseconds - the delay in milliseconds.

startBouncing

public void startBouncing()
Start (global) bouncing behavior.


stopBouncing

public void stopBouncing()
Stop (global) bouncing behavior.


contains

public boolean contains(Point param1)
Delegated to the shape.

Specified by:
contains in interface Graphic
Parameters:
param1 - The point to check
Returns:
true if this graphic contains p false if not
See Also:
NGP.Graphic#contains(Point)

intersects

public boolean intersects(Graphic param1)
Delegated to the shape.

Specified by:
intersects in interface Graphic
Parameters:
param1 - the graphic to test for intersection
Returns:
true if this graphic intersects with g
See Also:
NGP.Graphic#intersects(Graphic)

paint

public void paint(Graphics2D param1)
Delegated to the shape.

Specified by:
paint in interface Graphic
Parameters:
param1 - The Graphics2D object used to do the painting
See Also:
NGP.Graphic#paint(Graphics2D)

hide

public void hide()
Delegated to the shape.

See Also:
NGP.Graphic#hide()

show

public void show()
Delegated to the shape.

See Also:
NGP.Graphic#show()

getBounds

public Rectangle getBounds()
Delegated to the shape.

Specified by:
getBounds in interface Graphic
Returns:
a java.awt.Rectangle representing the bounds
See Also:
NGP.Graphic#getBounds()

getCenterLocation

public Point getCenterLocation()
Delegated to the shape.

Specified by:
getCenterLocation in interface CenterLocatable
Returns:
The point at the center of this Object
See Also:
NGP.Graphic#getCenterLocation()

setColor

public void setColor(Color param1)
Delegated to the shape.

Specified by:
setColor in interface Colorable
Parameters:
param1 - the java.awt.Color to set the Object to become
See Also:
NGP.Colorable#setColor(Color)

getColor

public Color getColor()
Delegated to the shape.

Specified by:
getColor in interface Colorable
Returns:
the java.awt.Color of this Object
See Also:
NGP.Colorable#getColor()

mouseDragged

public void mouseDragged(MouseEvent param1)
Delegated to the shape.

See Also:
MouseMotionListener.mouseDragged(MouseEvent)

mouseMoved

public void mouseMoved(MouseEvent param1)
Delegated to the shape.

See Also:
MouseMotionListener.mouseMoved(MouseEvent)

mouseClicked

public void mouseClicked(MouseEvent param1)
Delegated to the shape.

See Also:
MouseListener.mouseClicked(MouseEvent)

mouseEntered

public void mouseEntered(MouseEvent param1)
Delegated to the shape.

See Also:
MouseListener.mouseEntered(MouseEvent)

mouseExited

public void mouseExited(MouseEvent param1)
Delegated to the shape.

See Also:
MouseListener.mouseExited(MouseEvent)

mousePressed

public void mousePressed(MouseEvent param1)
Delegated to the shape.

See Also:
MouseListener.mousePressed(MouseEvent)

mouseReleased

public void mouseReleased(MouseEvent param1)
Delegated to the shape.

See Also:
MouseListener.mouseReleased(MouseEvent)

setDimension

public void setDimension(Dimension param1)
Delegated to the shape.

Specified by:
setDimension in interface Sizeable
Parameters:
param1 - The dimension to set the Object to be
See Also:
NGP.Sizeable#setDimension(Dimension)

getDimension

public Dimension getDimension()
Delegated to the shape.

Specified by:
getDimension in interface Sizeable
Returns:
the Object's Dimension
See Also:
NGP.Sizeable#getDimension()

getLocation

public Point getLocation()
Delegated to the shape.

Specified by:
getLocation in interface Locatable
Returns:
a java.awt.Point representing the current location of the Object
See Also:
NGP.Locatable#getLocation()

setLocation

public void setLocation(Point param1)
Delegated to the shape.

Specified by:
setLocation in interface Locatable
Parameters:
param1 - the point at which to locate this Object
See Also:
NGP.Locatable#setLocation(Point)

setRotation

public void setRotation(int param1)
Delegated to the shape.

See Also:
NGP.Rotatable#setRotation(int)

getRotation

public Integer getRotation()
Delegated to the shape.

Specified by:
getRotation in interface Rotatable
Returns:
An Integer (between 0 and 359) representing the current angle of rotation
See Also:
NGP.Rotatable#getRotation()

setVector

public void setVector(Vector newVector)
Change the vector motion of this MovingBody

Specified by:
setVector in interface MovingBody
Parameters:
newVector - The new vector motion for this shape.

getVector

public Vector getVector()
Returns the motion vector for this MovingBody

Specified by:
getVector in interface MovingBody
Returns:
the vector for the motion of this shape

react

public void react()
See Also:
NGP.Reactor#react()