netwar.gui
Class MouseParser

java.lang.Object
  |
  +--netwar.gui.MouseParser
All Implemented Interfaces:
java.util.EventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

public class MouseParser
extends java.lang.Object
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

This is the MouseListener and MouseMotionListener for HexViewer. This enables the point and click interface for the game. The game currently recognizes the following click inputs:
Alt + click = Center the HexViewer on the location of the click.
Ctrl + left click = Zoom in, preserving the center of the view.
Ctrl + right click = Zoom out, preserving the center of the view.
Shift + click = Add or remove a selectable GameObject to/from the set of selected objects.
Right click = Unselect all GameObjects.
Left Click (no objects selected) = Select a selectable GameObject.
Left Click (on a GameObject, with at least one selected) = Set this GameObject as the goal of the selected GameObjects.
Left Click (on an unoccupied Hex, with at least one object selected) = Set this Hex as the gola of the selected GameObjects.

A selectable object is one which is owned by the local player, and is not dead. Each GameObject may define its own behaviors when a goal is set. Typically, a Unit (mobile GameObject) will move to a goal hex, or pursue/attack a goal GameObject.

Author:
Group N2 - Project Netwar, Daniel Grund

Field Summary
static int maxZoom
          The maximum zoom level.
static int minZoom
          The minimum zoom level.
static float zoomFactor
          The factor for zooming.
 
Constructor Summary
MouseParser()
           
 
Method Summary
 void drawHigh()
          Causes the upper portion of the selection box to be drawn on each selected GameObject.
 void drawLow()
          Causes the lower portion of the selection box to be drawn on each selected GameObject.
static int getZoomLevel()
          Accessor for Zoom Level.
 void mouseClicked(java.awt.event.MouseEvent e)
          Required by MouseListener, but not currently used.
 void mouseDragged(java.awt.event.MouseEvent e)
          Required by MouseMotionListener, but not currently used.
 void mouseEntered(java.awt.event.MouseEvent e)
          Required by MouseListener, but not currently used.
 void mouseExited(java.awt.event.MouseEvent e)
          Required by MouseListener, but not currently used.
 void mouseMoved(java.awt.event.MouseEvent e)
          Required by MouseMotionListener, but not currently used.
 void mousePressed(java.awt.event.MouseEvent e)
          Required by MouseListener, but not currently used.
 void mouseReleased(java.awt.event.MouseEvent e)
          Catches and interprets a mouse click.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minZoom

public static final int minZoom
The minimum zoom level. If the zoom level is at this level, everything will be shrunk to the minimum size. The default zoom level is 0.

maxZoom

public static final int maxZoom
The maximum zoom level. If the zoom level is at this level, everything will be expanded to the maximum size. The default zoom level is 0.

zoomFactor

public static final float zoomFactor
The factor for zooming. When zooming in, each zoom level multiplies the sizes by this much. When zooming out, each zoom level divides the sizes by this much.
Constructor Detail

MouseParser

public MouseParser()
Method Detail

getZoomLevel

public static int getZoomLevel()
Accessor for Zoom Level.
Returns:
The current zoom level.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Required by MouseListener, but not currently used. Note that mouseClicked is never triggered if the mouse moves even a pixel between being pressed and being released. That is why mouseReleased is used instead.
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Catches and interprets a mouse click. See the class discription for how this is interpretted.
Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - The MouseEvent containing all the relevant click data.

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Required by MouseListener, but not currently used.
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Required by MouseListener, but not currently used.
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Required by MouseListener, but not currently used.
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Required by MouseMotionListener, but not currently used.
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Required by MouseMotionListener, but not currently used. This is planned to be used for click-and-drag multiple Unit selection. However, that feature is not yet implemented.
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

drawLow

public void drawLow()
Causes the lower portion of the selection box to be drawn on each selected GameObject.

drawHigh

public void drawHigh()
Causes the upper portion of the selection box to be drawn on each selected GameObject.