Spirograph Problem Set Javadocs

spirograph
Class SetPosGravListener

java.lang.Object
  extended byspirograph.SetPosGravListener
All Implemented Interfaces:
java.util.EventListener, java.awt.event.MouseListener

public class SetPosGravListener
extends java.lang.Object
implements java.awt.event.MouseListener

This code implements a listener which listens to the DotPanel and waits for mouse clicks. Depending on what "mode" it is in, the SetPosGravListener will either add in a new gravitational source, reposition the dot or do nothing. The mode of this listener is change by some of the button listeners in the AdvEnv instance.

Copyright © 1998 Massachusetts Institute of Technology
Copyright © 2003 Franklin W. Olin College of Engineering

Version:
$Id: SetPosGravListener.java,v 1.3 2003/01/17 19:31:08 gus Exp $
Author:
Luis Sarmenta, lfgs@cag.lcs.mit.edu, Henry Wong, henryw@mit.edu, Patrick G. Heck, gus.heck@olin.edu
See Also:
Coord, DotPanel

Field Summary
static int GRAV
          Signifies that a gravity point should be added when the mouse is clicked in the DotPanel.
static int NONE
          Signifies that no action should be taken when the mouse is clicked in the DotPanel.
static int POS
          Signifies that the ball position should be set when the mouse is clicked in the DotPanel.
 
Constructor Summary
SetPosGravListener(Coord xCoord, Coord yCoord, DotPanel myPanel)
          Creates a new SetPosGravListener that knows about a DotPanel and it's associated Coordinates.
 
Method Summary
 void mouseClicked(java.awt.event.MouseEvent e)
          Stub to fulfill MouseListener.
 void mouseEntered(java.awt.event.MouseEvent e)
          Stub to fulfill MouseListener.
 void mouseExited(java.awt.event.MouseEvent e)
          Stub to fulfill MouseListener.
 void mousePressed(java.awt.event.MouseEvent e)
          Perform our mode dependant behavior.
 void mouseReleased(java.awt.event.MouseEvent e)
          Stub to fulfill MouseListener.
 void setMode(int mode)
          Change the mode of operation of this listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
Signifies that no action should be taken when the mouse is clicked in the DotPanel.

See Also:
Constant Field Values

POS

public static final int POS
Signifies that the ball position should be set when the mouse is clicked in the DotPanel.

See Also:
Constant Field Values

GRAV

public static final int GRAV
Signifies that a gravity point should be added when the mouse is clicked in the DotPanel.

See Also:
Constant Field Values
Constructor Detail

SetPosGravListener

public SetPosGravListener(Coord xCoord,
                          Coord yCoord,
                          DotPanel myPanel)
Creates a new SetPosGravListener that knows about a DotPanel and it's associated Coordinates.

Parameters:
xCoord - The x coordinate
yCoord - the y coordinate.
myPanel - The dot panel for which we will be a mouse listener.
Method Detail

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Perform our mode dependant behavior. In GRAV mode, add a gravity point. In POS mode adjust the position of the ball. In NONE mode do nothing.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - The mouse event we are to react to

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Stub to fulfill MouseListener.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - A MouseEvent

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Stub to fulfill MouseListener.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
e - A MouseEvent

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Stub to fulfill MouseListener.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e - A MouseEvent

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Stub to fulfill MouseListener.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - A MouseEvent

setMode

public void setMode(int mode)
Change the mode of operation of this listener. Apropriate values are defined by the NONE POS and GRAV fields of this class.

Parameters:
mode - The new mode for this listener.

Spirograph Problem Set Javadocs