tipgame
Class Mouse

java.lang.Object
  extended by tipgame.Mouse
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Externalizable, java.io.Serializable, java.util.EventListener

public class Mouse
extends java.lang.Object
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Externalizable

Author:
Jam Jenkins Extends Mouse to translate the coordinates such that (0, 0) is in the upper left of the AnimationCanvas.
See Also:
Serialized Form

Field Summary
private  java.awt.Point leftClick
          position of left mouse click
private  java.awt.Point middleClick
          position of middle mouse click
private  java.awt.Point mouseClick
          position of mouse click
private  boolean mouseDown
          whether mouse is down or not
private  java.awt.Point mousePosition
          position of the mouse
private  java.util.Observer observer
          observer
private  java.awt.Point rightClick
          position of right mouse click
 
Constructor Summary
Mouse()
          Creates a new instance of Mouse
 
Method Summary
 void clear()
          clear all pending mouse events
 void clearClicks()
          clears all mouse clicks
 java.awt.Point getClickPosition()
          determines the last position of a click and once called, clears that click
 java.awt.Point getLeftClickPosition()
          determines the last position of a left click and once called, clears that click
 java.awt.Point getMiddleClickPosition()
          determines the last position of a middle click and once called, clears that click
 java.awt.Point getMousePosition()
          gets the last position of the mouse.
 java.awt.Point getRightClickPosition()
          determines the last position of a right click and once called, clears that click
 void mouseClicked(java.awt.event.MouseEvent mouseEvent)
          stores the MouseEvent for later polling.
 void mouseDragged(java.awt.event.MouseEvent mouseEvent)
           
 void mouseEntered(java.awt.event.MouseEvent mouseEvent)
          stores the MouseEvent for later polling.
 void mouseExited(java.awt.event.MouseEvent mouseEvent)
          stores the MouseEvent for later polling.
 void mouseMoved(java.awt.event.MouseEvent mouseEvent)
          stores the MouseEvent for later polling.
 boolean mousePressed()
           
 void mousePressed(java.awt.event.MouseEvent mouseEvent)
          stores the MouseEvent for later polling.
 void mouseReleased(java.awt.event.MouseEvent mouseEvent)
          stores the MouseEvent for later polling.
 void readExternal(java.io.ObjectInput in)
           
private  java.awt.Point readPoint(java.io.ObjectInput in, java.awt.Point point)
           
 void setObserver(java.util.Observer observer)
          sets observer
 java.lang.String toString()
          returns a string representation of the mouse position
 void writeExternal(java.io.ObjectOutput out)
           
private  void writePoint(java.io.ObjectOutput out, java.awt.Point point)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mousePosition

private java.awt.Point mousePosition
position of the mouse


mouseClick

private java.awt.Point mouseClick
position of mouse click


leftClick

private java.awt.Point leftClick
position of left mouse click


middleClick

private java.awt.Point middleClick
position of middle mouse click


rightClick

private java.awt.Point rightClick
position of right mouse click


mouseDown

private boolean mouseDown
whether mouse is down or not


observer

private java.util.Observer observer
observer

Constructor Detail

Mouse

public Mouse()
Creates a new instance of Mouse

Method Detail

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

writePoint

private void writePoint(java.io.ObjectOutput out,
                        java.awt.Point point)
                 throws java.io.IOException
Throws:
java.io.IOException

readPoint

private java.awt.Point readPoint(java.io.ObjectInput in,
                                 java.awt.Point point)
                          throws java.io.IOException
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

toString

public java.lang.String toString()
returns a string representation of the mouse position

Overrides:
toString in class java.lang.Object

clear

public void clear()
clear all pending mouse events


clearClicks

public void clearClicks()
clears all mouse clicks


getMousePosition

public java.awt.Point getMousePosition()
gets the last position of the mouse. Subsequent calls to getMousePosition will return the same position until the mouse moves to a different location.

Returns:
the last position of the mouse

getClickPosition

public java.awt.Point getClickPosition()
determines the last position of a click and once called, clears that click

Returns:
the last clicked position, null if not clicked since last call

getLeftClickPosition

public java.awt.Point getLeftClickPosition()
determines the last position of a left click and once called, clears that click

Returns:
the last left clicked position, null if not clicked since last call

getMiddleClickPosition

public java.awt.Point getMiddleClickPosition()
determines the last position of a middle click and once called, clears that click

Returns:
the last middle clicked position, null if not clicked since last call

getRightClickPosition

public java.awt.Point getRightClickPosition()
determines the last position of a right click and once called, clears that click

Returns:
the last right clicked position, null if not clicked since last call

mousePressed

public boolean mousePressed()
Returns:
true if the mouse is currently down, false otherwise

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent mouseEvent)
stores the MouseEvent for later polling.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseClicked(java.awt.event.MouseEvent)

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent mouseEvent)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent mouseEvent)
stores the MouseEvent for later polling.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited

public void mouseExited(java.awt.event.MouseEvent mouseEvent)
stores the MouseEvent for later polling.

Specified by:
mouseExited in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent mouseEvent)
stores the MouseEvent for later polling.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
See Also:
MouseMotionListener.mouseMoved(java.awt.event.MouseEvent)

mousePressed

public void mousePressed(java.awt.event.MouseEvent mouseEvent)
stores the MouseEvent for later polling.

Specified by:
mousePressed in interface java.awt.event.MouseListener
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent mouseEvent)
stores the MouseEvent for later polling.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)

setObserver

public void setObserver(java.util.Observer observer)
sets observer