Class PieceMover.DragHandlerNoImage
java.lang.Object
VASSAL.build.module.map.PieceMover.AbstractDragHandler
VASSAL.build.module.map.PieceMover.DragHandlerNoImage
- All Implemented Interfaces:
DragGestureListener
,DragSourceListener
,DragSourceMotionListener
,DropTargetListener
,EventListener
- Enclosing class:
PieceMover
Fallback drag-handler when DragImage not supported by JRE. Implements a
pseudo-cursor that follows the mouse cursor when user drags game pieces.
Supports map zoom by resizing cursor when it enters a drop target of
type Map.View.
- Version:
- 0.4.2
- Author:
- Jim Urbas
-
Nested Class Summary
Nested classes/interfaces inherited from class VASSAL.build.module.map.PieceMover.AbstractDragHandler
PieceMover.AbstractDragHandler.AbstractDragHandlerFactory
-
Field Summary
Modifier and TypeFieldDescriptionprotected Component
protected final Point
protected JLayeredPane
protected Component
Fields inherited from class VASSAL.build.module.map.PieceMover.AbstractDragHandler
boundingBox, boundingBoxComp, currentPieceOffsetX, currentPieceOffsetY, CURSOR_ALPHA, dragCursor, dragCursorZoom, dragPieceOffCenterZoom, dropTargetListeners, EXTRA_BORDER, lastDragLocation, pieceMovers
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
calculates the offset between cursor dragCursor positionsvoid
DRAG SOURCE LISTENER INTERFACEvoid
DROP TARGET INTERFACE EVENT uses UNSCALED, DROP-TARGET coordinate system dragEnter - switches current drawWin when mouse enters a new DropTargetvoid
DRAG GESTURE LISTENER INTERFACE EVENT uses SCALED, DRAG-SOURCE coordinate system.void
DRAG SOURCE MOTION LISTENER INTERFACE EVENT uses UNSCALED, SCREEN coordinate system Moves cursor after mouse.void
DROP TARGET INTERFACE EVENT uses UNSCALED, DROP-TARGET coordinate system drop() - Last event of the drop operation.protected double
protected double
protected int
protected void
makeDragCursor
(double zoom) Deprecated, for removal: This API element is subject to removal in a future version.protected void
makeDragCursor
(double zoom, double os_scale) Installs the cursor image into our dragCursor JLabel.protected void
moveDragCursor
(int dragX, int dragY) Moves the drag cursor on the current draw windowprotected void
Removes the drag cursor from the current draw windowvoid
setDrawWinToOwnerOf
(Component newDropWin) creates or moves cursor object to given window.Methods inherited from class VASSAL.build.module.map.PieceMover.AbstractDragHandler
addPieceMover, beginDragging, dragEnter, dragExit, dragExit, dragGestureRecognizedPrep, dragOver, dragOver, dropActionChanged, dropActionChanged, getListener, getTheDragHandler, makeDragImageCursorCommon, makeDragImageCursorCommon, makeDropTarget, removeDropTarget, resetDragHandler, resetRecursivePieceSlots, setTheDragHandler
-
Field Details
-
dragWin
-
dropWin
-
drawWin
-
drawOffset
-
-
Constructor Details
-
DragHandlerNoImage
public DragHandlerNoImage()
-
-
Method Details
-
dragGestureRecognized
Description copied from class:PieceMover.AbstractDragHandler
DRAG GESTURE LISTENER INTERFACE EVENT uses SCALED, DRAG-SOURCE coordinate system. ("component coordinates") PIECE uses SCALED, OWNER (arbitrary) coordinate system ("map coordinates") Fires after user begins moving the mouse several pixels over a map. This method will be overridden, but called as a super(), by the Drag Gesture extension that is used, which will either bePieceMover.DragHandler
if DragImage is supported by the JRE, orPieceMover.DragHandlerNoImage
if not. Either one will have calledPieceMover.AbstractDragHandler.dragGestureRecognizedPrep(java.awt.dnd.DragGestureEvent)
, immediately below, before it calls this method.- Specified by:
dragGestureRecognized
in interfaceDragGestureListener
- Overrides:
dragGestureRecognized
in classPieceMover.AbstractDragHandler
-
makeDragCursor
Deprecated, for removal: This API element is subject to removal in a future version.- Overrides:
makeDragCursor
in classPieceMover.AbstractDragHandler
-
makeDragCursor
protected void makeDragCursor(double zoom, double os_scale) 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
-
moveDragCursor
protected void moveDragCursor(int dragX, int dragY) Moves the drag cursor on the current draw window- Overrides:
moveDragCursor
in classPieceMover.AbstractDragHandler
- Parameters:
dragX
- x positiondragY
- y position
-
removeDragCursor
protected void removeDragCursor()Removes the drag cursor from the current draw window- Overrides:
removeDragCursor
in classPieceMover.AbstractDragHandler
-
calcDrawOffset
protected void calcDrawOffset()calculates the offset between cursor dragCursor positions- Overrides:
calcDrawOffset
in classPieceMover.AbstractDragHandler
-
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- Overrides:
setDrawWinToOwnerOf
in classPieceMover.AbstractDragHandler
- Parameters:
newDropWin
- window component to be our new draw window.
-
getOffsetMult
protected int getOffsetMult()- Specified by:
getOffsetMult
in classPieceMover.AbstractDragHandler
- Returns:
- platform-dependent offset multiplier
-
getDeviceScale
- Specified by:
getDeviceScale
in classPieceMover.AbstractDragHandler
- Parameters:
dge
- DG event- Returns:
- platform-dependent device scale
-
getDeviceScale
- Specified by:
getDeviceScale
in classPieceMover.AbstractDragHandler
-
dragDropEnd
Description copied from class:PieceMover.AbstractDragHandler
DRAG SOURCE LISTENER INTERFACE- Specified by:
dragDropEnd
in interfaceDragSourceListener
- Overrides:
dragDropEnd
in classPieceMover.AbstractDragHandler
- Parameters:
e
- DragSourceDropEvent
-
dragMouseMoved
Description copied from class:PieceMover.AbstractDragHandler
DRAG SOURCE MOTION LISTENER INTERFACE EVENT uses UNSCALED, SCREEN coordinate system Moves cursor after mouse. Used to check for real mouse movement. Warning: dragMouseMoved fires 8 times for each point on development system (Win2k)- Specified by:
dragMouseMoved
in interfaceDragSourceMotionListener
- Overrides:
dragMouseMoved
in classPieceMover.AbstractDragHandler
-
dragEnter
Description copied from class:PieceMover.AbstractDragHandler
DROP TARGET INTERFACE EVENT uses UNSCALED, DROP-TARGET coordinate system dragEnter - switches current drawWin when mouse enters a new DropTarget- Specified by:
dragEnter
in interfaceDropTargetListener
- Overrides:
dragEnter
in classPieceMover.AbstractDragHandler
-
drop
Description copied from class:PieceMover.AbstractDragHandler
DROP TARGET INTERFACE EVENT uses UNSCALED, DROP-TARGET coordinate system 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:
drop
in interfaceDropTargetListener
- Overrides:
drop
in classPieceMover.AbstractDragHandler
-