Package VASSAL.build.module.map
Class PieceMover.AbstractDragHandler
java.lang.Object
VASSAL.build.module.map.PieceMover.AbstractDragHandler
- All Implemented Interfaces:
DragGestureListener,DragSourceListener,DragSourceMotionListener,DropTargetListener,EventListener
- Direct Known Subclasses:
PieceMover.DragHandler,PieceMover.DragHandlerNoImage
- Enclosing class:
- PieceMover
public abstract static class PieceMover.AbstractDragHandler extends Object implements DragGestureListener, DragSourceListener, DragSourceMotionListener, DropTargetListener
Common functionality for DragHandler for cases with and without
drag image support.
NOTE: DragSource.isDragImageSupported() returns false for j2sdk1.4.2_02 on Windows 2000
- Author:
- Pieter Geerkens
-
Field Summary
Fields Modifier and Type Field Description protected JLabeldragCursorprotected doubledragCursorZoomprotected doubledragPieceOffCenterZoomprotected PointlastDragLocation -
Constructor Summary
Constructors Constructor Description AbstractDragHandler() -
Method Summary
Modifier and Type Method Description protected voidbeginDragging(DragGestureEvent dge)voiddragDropEnd(DragSourceDropEvent e)voiddragEnter(DragSourceDragEvent e)voiddragEnter(DropTargetDragEvent e)switches current drawWin when mouse enters a new DropTargetvoiddragExit(DragSourceEvent e)voiddragExit(DropTargetEvent e)ineffectual.voiddragGestureRecognized(DragGestureEvent dge)Fires after user begins moving the mouse several pixels over a map.protected PointdragGestureRecognizedPrep(DragGestureEvent dge)abstract voiddragMouseMoved(DragSourceDragEvent e)Moves cursor after mousevoiddragOver(DragSourceDragEvent e)voiddragOver(DropTargetDragEvent e)ineffectual.voiddrop(DropTargetDropEvent e)Last event of the drop operation.voiddropActionChanged(DragSourceDragEvent e)voiddropActionChanged(DropTargetDragEvent e)ineffectual.protected abstract doublegetDeviceScale(DragGestureEvent dge)protected DropTargetListenergetListener(DropTargetEvent e)protected abstract intgetOffsetMult()static PieceMover.AbstractDragHandlergetTheDragHandler()returns the singleton DragHandler instanceprotected voidmakeDragCursor(double zoom)Installs the cursor image into our dragCursor JLabel.static DropTargetmakeDropTarget(Component theComponent, int dndContants, DropTargetListener dropTargetListener)Creates a new DropTarget and hooks us into the beginning of a DropTargetListener chain.protected voidmoveDragCursor(int dragX, int dragY)Moves the drag cursor on the current draw windowprotected voidremoveDragCursor()Removes the drag cursor from the current draw windowstatic voidremoveDropTarget(Component theComponent)voidsetDrawWinToOwnerOf(Component newDropWin)creates or moves cursor object to given window.static voidsetTheDragHandler(PieceMover.AbstractDragHandler myHandler)
-
Field Details
-
dragCursor
-
dragPieceOffCenterZoom
protected double dragPieceOffCenterZoom -
dragCursorZoom
protected double dragCursorZoom -
lastDragLocation
-
-
Constructor Details
-
AbstractDragHandler
public AbstractDragHandler()
-
-
Method Details
-
getTheDragHandler
returns the singleton DragHandler instance -
setTheDragHandler
-
getOffsetMult
protected abstract int getOffsetMult() -
getDeviceScale
-
makeDropTarget
public static DropTarget makeDropTarget(Component theComponent, int dndContants, DropTargetListener dropTargetListener)Creates a new DropTarget and hooks us into the beginning of a DropTargetListener chain. DropTarget events are not multicast; there can be only one "true" listener. -
removeDropTarget
-
getListener
-
moveDragCursor
protected void moveDragCursor(int dragX, int dragY)Moves the drag cursor on the current draw window -
removeDragCursor
protected void removeDragCursor()Removes the drag cursor from the current draw window -
setDrawWinToOwnerOf
creates or moves cursor object to given window. Called when drag operation begins in a window or the cursor is dragged over a new drop-target window -
makeDragCursor
protected void makeDragCursor(double zoom)Installs the cursor image into our dragCursor JLabel. Sets current zoom. Should be called at beginning of drag and whenever zoom changes. INPUT: DragBuffer.getBuffer OUTPUT: dragCursorZoom cursorOffCenterX cursorOffCenterY boundingBox- Parameters:
zoom- DragBuffer.getBuffer
-
dragGestureRecognized
Fires after user begins moving the mouse several pixels over a map.- Specified by:
dragGestureRecognizedin interfaceDragGestureListener
-
dragGestureRecognizedPrep
-
beginDragging
-
dragDropEnd
- Specified by:
dragDropEndin interfaceDragSourceListener
-
dragEnter
- Specified by:
dragEnterin interfaceDragSourceListener
-
dragExit
- Specified by:
dragExitin interfaceDragSourceListener
-
dragOver
- Specified by:
dragOverin interfaceDragSourceListener
-
dropActionChanged
- Specified by:
dropActionChangedin interfaceDragSourceListener
-
dragMouseMoved
Moves cursor after mouse- Specified by:
dragMouseMovedin interfaceDragSourceMotionListener
-
dragEnter
switches current drawWin when mouse enters a new DropTarget- Specified by:
dragEnterin interfaceDropTargetListener
-
drop
Last event of the drop operation. We adjust the drop point for off-center drag, remove the cursor, and pass the event along listener chain.- Specified by:
dropin interfaceDropTargetListener
-
dragExit
ineffectual. Passes event along listener chain- Specified by:
dragExitin interfaceDropTargetListener
-
dragOver
ineffectual. Passes event along listener chain- Specified by:
dragOverin interfaceDropTargetListener
-
dropActionChanged
ineffectual. Passes event along listener chain- Specified by:
dropActionChangedin interfaceDropTargetListener
-