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
|
| Methods inherited from class VASSAL.build.module.map.PieceMover |
compare, getAttributeNames, getAttributeValueString, getRestoreCommand, isClick, markMoved, mouseClicked, mouseEntered, mouseExited, movedPiece, movePieces, select, setAttribute, setup, shouldMarkMoved |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
MineaturesPieceMover
public MineaturesPieceMover()
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)
- Overrides:
mousePressed in class PieceMover
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