|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--VASSAL.build.AbstractBuildable
|
+--VASSAL.build.module.map.PieceMover
This is a MouseListener that moves pieces onto a Map window
| Inner Class Summary | |
static class |
PieceMover.DragHandler
Implements a psudo-cursor that follows the mouse cursor when user drags gamepieces. |
| Field Summary | |
static java.lang.String |
AUTO_REPORT
The Preferences key for autoreporting moves. |
protected java.awt.Point |
dragBegin
|
protected PieceFinder |
dragTargetSelector
|
protected PieceFinder |
dropTargetSelector
|
static java.lang.String |
ICON_NAME
|
protected Map |
map
|
protected javax.swing.JButton |
markUnmovedButton
|
protected static java.lang.String |
OFFMAP
|
protected PieceVisitorDispatcher |
selectionProcessor
|
| Fields inherited from class VASSAL.build.AbstractBuildable |
buildComponents, validator |
| Constructor Summary | |
PieceMover()
|
|
| Method Summary | |
void |
addTo(Buildable b)
Adds this component to its parent. |
protected boolean |
canHandleEvent(java.awt.event.MouseEvent e)
|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
Implement Comparator to sort the contents of the drag buffer before completing the drag. |
protected PieceFinder |
createDragTargetSelector()
Returns the PieceFinder instance that will select a GamePiece
for processing when the user clicks on the map. |
protected PieceFinder |
createDropTargetSelector()
When the user completes a drag-drop operation, the pieces being dragged will either be combined with an existing piece on the map or else placed on the map without stack. |
protected MovementReporter |
createMovementReporter(Command c)
|
protected PieceVisitorDispatcher |
createSelectionProcessor()
When the user clicks on the map, a piece from the map is selected by the dragTargetSelector. |
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 |
protected void |
initButton()
|
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 |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(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)
|
protected Command |
movedPiece(GamePiece p,
java.awt.Point loc)
Invoked after a piece has been moved |
Command |
movePieces(Map map,
java.awt.Point p)
moves pieces in DragBuffer to point p by generating a Command for each element in Dragbuffer |
protected void |
performDrop(java.awt.Point p)
|
protected void |
selectMovablePieces(java.awt.event.MouseEvent e)
Place the clicked-on piece into the DragBuffer |
protected void |
selectMovablePieces(java.awt.Point point)
Deprecated. use #selectMovablePieces(MouseEvent) |
void |
setAttribute(java.lang.String key,
java.lang.Object value)
Sets an attribute value for this component. |
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, validate |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
equals |
| Field Detail |
public static final java.lang.String AUTO_REPORT
protected static final java.lang.String OFFMAP
protected Map map
protected java.awt.Point dragBegin
protected javax.swing.JButton markUnmovedButton
public static final java.lang.String ICON_NAME
protected PieceFinder dragTargetSelector
protected PieceFinder dropTargetSelector
protected PieceVisitorDispatcher selectionProcessor
| Constructor Detail |
public PieceMover()
| Method Detail |
public void addTo(Buildable b)
Buildableprotected MovementReporter createMovementReporter(Command c)
protected PieceFinder createDropTargetSelector()
PieceFinder instance that determines which
GamePiece (if any) to combine the being-dragged pieces with.protected PieceVisitorDispatcher createSelectionProcessor()
PieceVisitorDispatcher instance returned by this method.
The default implementation does the following:
If a Deck, add the top piece to the drag buffer
If a stack, add it to the drag buffer
Otherwise, add the piece and any other multi-selected pieces to the drag buffercreateDragTargetSelector()protected PieceFinder createDragTargetSelector()
PieceFinder instance that will select a GamePiece
for processing when the user clicks on the map.
The default implementation is to return the first piece
whose shape contains the point clicked on.public void setup(boolean gameStarting)
GameComponentsetup in interface GameComponentVASSAL.build.module.GameComponentgameStarting - if true, a game is starting. If false, then a game is endingpublic Command getRestoreCommand()
GameComponentCommand that, when executed, restores the GameComponent to its
state when the game was saved
If this component has no persistent state, return nullgetRestoreCommand in interface GameComponentprotected void initButton()
public java.lang.String[] getAttributeNames()
getAttributeNames in class AbstractBuildableVASSAL.build.AbstractBuildablepublic java.lang.String getAttributeValueString(java.lang.String key)
AbstractBuildableAbstractBuildable.setAttribute(java.lang.String, java.lang.Object).getAttributeValueString in class AbstractBuildableVASSAL.build.AbstractBuildablekey - the name of the attribute. Will be one of those
listed in AbstractBuildable.getAttributeNames()
public void setAttribute(java.lang.String key,
java.lang.Object value)
AbstractBuildablekey
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()setAttribute in class AbstractBuildableVASSAL.build.AbstractBuildablekey - the name of the attribute. Will be one of those
listed in AbstractBuildable.getAttributeNames()protected boolean isMultipleSelectionEvent(java.awt.event.MouseEvent e)
protected Command movedPiece(GamePiece p,
java.awt.Point loc)
public Command markMoved(GamePiece p,
boolean hasMoved)
protected boolean shouldMarkMoved()
public Command movePieces(Map map,
java.awt.Point p)
map - Mapp - Point mouse releasedpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenere - protected void selectMovablePieces(java.awt.event.MouseEvent e)
DragBufferprotected void selectMovablePieces(java.awt.Point point)
protected boolean canHandleEvent(java.awt.event.MouseEvent e)
public boolean isClick(java.awt.Point pt)
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenerprotected void performDrop(java.awt.Point p)
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenerpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenerpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListener
public int compare(java.lang.Object o1,
java.lang.Object o2)
compare in interface java.util.Comparator
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||