jfreerails.client.view
Class StationPlacementCursor

java.lang.Object
  extended by javax.swing.event.MouseInputAdapter
      extended by jfreerails.client.view.StationPlacementCursor
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener

public class StationPlacementCursor
extends javax.swing.event.MouseInputAdapter

This class implements a cursor which can be used to place a station on the map. Mode of operation:

  1. User selects a station to place, which sets the current cursor to the station placement cursor.
  2. User highlights desired build location with the mouse, boundary of the station radius is highlighted. If the station cannot be built, the boundary highlights in red.
  3. User places station with the left mouse button.
  4. User may cancel placement by using the right mouse button
  5. Cursor fires the actionPerformed causing the station to be built.
When the StationBuildAction is no longer enabled, the owner reverts to the regular cursor type. TODO scroll the area when the mouse hovers at the edge of the map.

Author:
rob

Field Summary
private  java.beans.PropertyChangeListener buildActionListener
           
private  boolean buildEnabled
           
private  MapViewJComponent mapView
           
private  float scale
           
private  StationBuildModel stationBuildModel
           
private  StationRadiusRenderer stationRadiusRenderer
           
 
Constructor Summary
private StationPlacementCursor(ActionRoot actionRoot, StationRadiusRenderer srr, MapViewJComponent mapView)
           
 
Method Summary
private  void init()
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
static void wireUp(ActionRoot actionRoot, StationRadiusRenderer srr, MapViewJComponent mapView)
           
 
Methods inherited from class javax.swing.event.MouseInputAdapter
mouseDragged, mousePressed, mouseReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buildActionListener

private final java.beans.PropertyChangeListener buildActionListener

buildEnabled

private boolean buildEnabled

mapView

private final MapViewJComponent mapView

scale

private final float scale

stationBuildModel

private final StationBuildModel stationBuildModel

stationRadiusRenderer

private final StationRadiusRenderer stationRadiusRenderer
Constructor Detail

StationPlacementCursor

private StationPlacementCursor(ActionRoot actionRoot,
                               StationRadiusRenderer srr,
                               MapViewJComponent mapView)
Method Detail

wireUp

public static void wireUp(ActionRoot actionRoot,
                          StationRadiusRenderer srr,
                          MapViewJComponent mapView)

init

private void init()

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class javax.swing.event.MouseInputAdapter

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener
Overrides:
mouseEntered in class javax.swing.event.MouseInputAdapter

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener
Overrides:
mouseExited in class javax.swing.event.MouseInputAdapter

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class javax.swing.event.MouseInputAdapter