VASSAL.build.module.map
Class PieceMover

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

public class PieceMover
extends AbstractBuildable
implements java.awt.event.MouseListener, Drawable, java.awt.event.MouseMotionListener, GameComponent, PieceFinder, Sort.Comparator

This is a MouseListener that moves pieces on a Map window


Field Summary
static java.lang.String AUTO_REPORT
          The Preferences key for autoreporting moves.
protected  boolean checkDragContents
           
protected  java.awt.Point dragBegin
           
protected  Map map
           
protected  java.awt.Rectangle outline
           
protected  java.awt.Color outlineColor
           
protected  java.awt.Point outlineOffset
           
protected  int thickness
           
 
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents
 
Fields inherited from interface VASSAL.counters.PieceFinder
MOVABLE, PIECE_IN_STACK, STACK_ONLY
 
Constructor Summary
PieceMover()
           
 
Method Summary
 void addTo(Buildable b)
          Adds this component to its parent.
 int compare(java.lang.Object o1, java.lang.Object o2)
          Implement Comparator to sort the contents of the darg bufeer before completing the drag.
 void draw(java.awt.Graphics g, Map map)
           
 java.lang.String[] getAttributeNames()
           
 java.lang.String getAttributeValueString(java.lang.String key)
          Return a String representation of the attribute with the given name.
 Command getRestoreCommand()
          When saving a game, each GameComponent should return a Command that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null
 boolean isClick(java.awt.Point pt)
          Return true if this point is "close enough" to the point at which the user pressed the mouse to be considered a mouse click (such that no moves are done)
protected  boolean isMultipleSelectionEvent(java.awt.event.MouseEvent e)
           
 Command markMoved(GamePiece p, boolean hasMoved)
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(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)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
protected  Command movedPiece(GamePiece p, java.awt.Point loc)
          Invoked after a piece has been moved
 Command movePieces(Map m, java.awt.Point p)
           
 GamePiece select(Map map, GamePiece piece, java.awt.Point pt)
          Implements PieceFinder to determine which piece to stack with when completing a drag
 void setAttribute(java.lang.String key, java.lang.Object value)
          Sets an attribute value for this component.
protected  void setOutline(GamePiece p)
           
 void setup(boolean gameStarting)
          Notify the GameComponent that a game has started/ended
protected  boolean 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

AUTO_REPORT

public static final java.lang.String AUTO_REPORT
The Preferences key for autoreporting moves.

See Also:
Constant Field Values

map

protected Map map

dragBegin

protected java.awt.Point dragBegin

outlineColor

protected java.awt.Color outlineColor

thickness

protected int thickness

outline

protected java.awt.Rectangle outline

outlineOffset

protected java.awt.Point outlineOffset

checkDragContents

protected boolean checkDragContents
Constructor Detail

PieceMover

public PieceMover()
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.

Specified by:
addTo in interface Buildable

setup

public void setup(boolean gameStarting)
Description copied from interface: GameComponent
Notify the GameComponent that a game has started/ended

Specified by:
setup in interface GameComponent
Parameters:
gameStarting - if true, a game is starting. If false, then a game is ending

getRestoreCommand

public Command getRestoreCommand()
Description copied from interface: GameComponent
When saving a game, each GameComponent should return a Command that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null

Specified by:
getRestoreCommand in interface GameComponent

getAttributeNames

public java.lang.String[] getAttributeNames()
Specified by:
getAttributeNames in class AbstractBuildable
Returns:
a list of all attribute names for this component

getAttributeValueString

public java.lang.String getAttributeValueString(java.lang.String key)
Description copied from class: AbstractBuildable
Return a String representation of the attribute with the given name. When initializing a module, this String value will be passed to AbstractBuildable.setAttribute(java.lang.String, java.lang.Object).

Specified by:
getAttributeValueString in class AbstractBuildable
Parameters:
key - the name of the attribute. Will be one of those listed in AbstractBuildable.getAttributeNames()

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value)
Description copied from class: AbstractBuildable
Sets an attribute value for this component. The key parameter will be one of those listed in AbstractBuildable.getAttributeNames(). If the value parameter is a String, it will be the value returned by AbstractBuildable.getAttributeValueString(java.lang.String) for the same key. If the implementing class extends AbstractConfigurable, then value will be an instance of the corresponding Class listed in AbstractConfigurable.getAttributeTypes()

Specified by:
setAttribute in class AbstractBuildable
Parameters:
key - the name of the attribute. Will be one of those listed in AbstractBuildable.getAttributeNames()

isMultipleSelectionEvent

protected boolean isMultipleSelectionEvent(java.awt.event.MouseEvent e)

draw

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

movedPiece

protected Command movedPiece(GamePiece p,
                             java.awt.Point loc)
Invoked after a piece has been moved


markMoved

public Command markMoved(GamePiece p,
                         boolean hasMoved)

shouldMarkMoved

protected boolean shouldMarkMoved()

movePieces

public Command movePieces(Map m,
                          java.awt.Point p)

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

setOutline

protected void setOutline(GamePiece p)

isClick

public boolean isClick(java.awt.Point pt)
Return true if this point is "close enough" to the point at which the user pressed the mouse to be considered a mouse click (such that no moves are done)


mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseDragged

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

mouseMoved

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

select

public GamePiece select(Map map,
                        GamePiece piece,
                        java.awt.Point pt)
Implements PieceFinder to determine which piece to stack with when completing a drag

Specified by:
select in interface PieceFinder

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Implement Comparator to sort the contents of the darg bufeer before completing the drag. This sorts the contents to be in the same order as the piece were in their original parent stack.

Specified by:
compare in interface Sort.Comparator