VASSAL.build.module.map
Class MineaturesPieceMover

java.lang.Object
  |
  +--VASSAL.build.AbstractBuildable
        |
        +--VASSAL.build.module.map.PieceMover
              |
              +--VASSAL.build.module.map.MineaturesPieceMover
All Implemented Interfaces:
Buildable, Drawable, java.util.EventListener, GameComponent, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, PieceFinder, Sort.Comparator

public class MineaturesPieceMover
extends PieceMover
implements java.awt.event.MouseMotionListener, Drawable

Moves pieces on a map with an interface appropriate for mineatures-type games. Only one piece may be moved at a time, with a transparent outline of the piece being dragged and a line connecting it to its original location. An maximum distance for moving pieces may be specified.


Field Summary
protected  java.awt.Point anchor
          The piece's original location in component coordinates
protected  java.awt.Point arrow
          The piece's final destination, in component coordinates
protected  GamePiece dragging
           
protected  java.awt.Color lineColor
           
protected  Transparent trans
           
 
Fields inherited from class VASSAL.build.module.map.PieceMover
AUTO_REPORT, dragBegin, map
 
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents
 
Fields inherited from interface VASSAL.counters.PieceFinder
MOVABLE, PIECE_IN_STACK, STACK_ONLY
 
Constructor Summary
MineaturesPieceMover()
           
 
Method Summary
 void addTo(Buildable b)
          Adds this component to its parent.
protected  void clear()
           
 void draw(java.awt.Graphics g, Map map)
           
protected  java.awt.Point getDragDestination(java.awt.Point src, java.awt.Point dest)
          A Mouse release event will be translated to this location (in map coordinates).
protected  int getMaxDragDistance(GamePiece piece)
          The maximum distance that a piece may be dragged, in map-coordinate pixels
protected  boolean isMultipleSelectionEvent(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
          This listener is used for faking drag-and-drop on Java 1.1 systems
 void mouseReleased(java.awt.event.MouseEvent e)
           
 
Methods inherited from class VASSAL.build.module.map.PieceMover
canHandleEvent, compare, getAttributeNames, getAttributeValueString, getRestoreCommand, isClick, markMoved, mouseClicked, mouseEntered, mouseExited, movedPiece, movePieces, performDrop, select, selectMovablePieces, setAttribute, setup, shouldMarkMoved
 
Methods inherited from class VASSAL.build.AbstractBuildable
add, build, getBuildComponents, getBuildElement, getComponents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dragging

protected GamePiece dragging

trans

protected Transparent trans

anchor

protected java.awt.Point anchor
The piece's original location in component coordinates

arrow

protected java.awt.Point arrow
The piece's final destination, in component coordinates

lineColor

protected java.awt.Color lineColor
Constructor Detail

MineaturesPieceMover

public MineaturesPieceMover()
Method Detail

addTo

public void addTo(Buildable b)
Description copied from interface: Buildable
Adds this component to its parent. In order to make Buildable objects extensible, the child is reponsible for adding itself to the parent. That way, Buildable subcomponents can be defined in an extension package without needing to modify the containing class.
Overrides:
addTo in class PieceMover

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Description copied from class: PieceMover
This listener is used for faking drag-and-drop on Java 1.1 systems
Overrides:
mousePressed in class PieceMover
Following copied from class: VASSAL.build.module.map.PieceMover
Parameters:
e -  

isMultipleSelectionEvent

protected boolean isMultipleSelectionEvent(java.awt.event.MouseEvent e)
Overrides:
isMultipleSelectionEvent in class PieceMover

clear

protected void clear()

draw

public void draw(java.awt.Graphics g,
                 Map map)
Specified by:
draw in interface Drawable

getDragDestination

protected java.awt.Point getDragDestination(java.awt.Point src,
                                            java.awt.Point dest)
A Mouse release event will be translated to this location (in map coordinates). This allows restrictions, such as distance limitations, to be put on where a piece may move.
Returns:
null if the move is invalid

mouseDragged

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

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Overrides:
mouseReleased in class PieceMover

getMaxDragDistance

protected int getMaxDragDistance(GamePiece piece)
The maximum distance that a piece may be dragged, in map-coordinate pixels
Parameters:
piece -  
Returns:
 

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener