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 PieceMover.AbstractDragHandler
PieceMover.AbstractDragHandler.AbstractDragHandlerFactoryModifier and TypeClassDescriptionstatic classPicks the correct drag handler based on our OS, DragSource, and preferences. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Componentprotected final Pointprotected JLayeredPaneprotected ComponentFields inherited from class PieceMover.AbstractDragHandler
boundingBox, boundingBoxComp, currentPieceOffsetX, currentPieceOffsetY, CURSOR_ALPHA, dragCursor, dragCursorZoom, dragPieceOffCenterZoom, dropTargetListeners, EXTRA_BORDER, lastDragLocation, pieceMoversModifier and TypeFieldDescriptionprotected Rectangleprotected Rectangleprotected intprotected intprotected static final intprotected JLabelprotected doubleprotected doubleprotected Map<Component, DropTargetListener> protected static final intprotected Pointprotected static List<PieceMover> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcalculates the offset between cursor dragCursor positionsvoidDRAG SOURCE LISTENER INTERFACEvoidDROP TARGET INTERFACE EVENT uses UNSCALED, DROP-TARGET coordinate system dragEnter - switches current drawWin when mouse enters a new DropTargetvoidDRAG GESTURE LISTENER INTERFACE EVENT uses SCALED, DRAG-SOURCE coordinate system.voidDRAG SOURCE MOTION LISTENER INTERFACE EVENT uses UNSCALED, SCREEN coordinate system Moves cursor after mouse.voidDROP TARGET INTERFACE EVENT uses UNSCALED, DROP-TARGET coordinate system drop() - Last event of the drop operation.protected doubleprotected doubleprotected intprotected voidmakeDragCursor(double zoom) Deprecated, for removal: This API element is subject to removal in a future version.protected voidmakeDragCursor(double zoom, double os_scale) Installs the cursor image into our dragCursor JLabel.protected voidmoveDragCursor(int dragX, int dragY) Moves the drag cursor on the current draw windowprotected voidRemoves the drag cursor from the current draw windowvoidsetDrawWinToOwnerOf(Component newDropWin) creates or moves cursor object to given window.Methods inherited from class PieceMover.AbstractDragHandler
addPieceMover, beginDragging, dragEnter, dragExit, dragExit, dragGestureRecognizedPrep, dragOver, dragOver, dropActionChanged, dropActionChanged, getListener, getTheDragHandler, makeDragImageCursorCommon, makeDragImageCursorCommon, makeDropTarget, removeDropTarget, resetDragHandler, resetRecursivePieceSlots, setTheDragHandlerModifier and TypeMethodDescriptionstatic voidRegisters a PieceMoverprotected voidThe the Drag Gesture Recognizer that we're officially beginning a drag.voidvoidvoidPasses event along listener chainprotected PointSets things up at the beginning of a drag-and-drop operation:
- Screen out any immovable pieces
- Account for any offsets on in the window
- Sets dragWin to our source windowvoidvoidPasses event along listener chainvoidvoidPasses event along listener chainprotected DropTargetListenerreturns the singleton DragHandler instanceprotected BufferedImagemakeDragImageCursorCommon(double zoom, boolean doOffset, Component target, boolean setSize) Deprecated, for removal: This API element is subject to removal in a future version.protected BufferedImagemakeDragImageCursorCommon(double mapzoom, double os_scale, boolean doOffset, Component target) static DropTargetmakeDropTarget(Component theComponent, int dndContants, DropTargetListener dropTargetListener) Creates a new DropTarget and hooks us into the beginning of a DropTargetListener chain.static voidremoveDropTarget(Component theComponent) Removes a dropTarget componentstatic voidReset our drag handler, e.g. if our preferences change.static voidFinds all the piece slots in a module and resets their drop targets to use a new DragHandlerstatic voidsetTheDragHandler(PieceMover.AbstractDragHandler myHandler)
-
Field Details
-
dragWin
-
dropWin
-
drawWin
-
drawOffset
-
-
Constructor Details
-
DragHandlerNoImage
public DragHandlerNoImage()
-
-
Method Details
-
dragGestureRecognized
Description copied from class:PieceMover.AbstractDragHandlerDRAG 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.DragHandlerif DragImage is supported by the JRE, orPieceMover.DragHandlerNoImageif not. Either one will have calledPieceMover.AbstractDragHandler.dragGestureRecognizedPrep(java.awt.dnd.DragGestureEvent), immediately below, before it calls this method.- Specified by:
dragGestureRecognizedin interfaceDragGestureListener- Overrides:
dragGestureRecognizedin classPieceMover.AbstractDragHandler
-
makeDragCursor
Deprecated, for removal: This API element is subject to removal in a future version.- Overrides:
makeDragCursorin 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:
moveDragCursorin classPieceMover.AbstractDragHandler- Parameters:
dragX- x positiondragY- y position
-
removeDragCursor
protected void removeDragCursor()Removes the drag cursor from the current draw window- Overrides:
removeDragCursorin classPieceMover.AbstractDragHandler
-
calcDrawOffset
protected void calcDrawOffset()calculates the offset between cursor dragCursor positions- Overrides:
calcDrawOffsetin 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:
setDrawWinToOwnerOfin classPieceMover.AbstractDragHandler- Parameters:
newDropWin- window component to be our new draw window.
-
getOffsetMult
protected int getOffsetMult()- Specified by:
getOffsetMultin classPieceMover.AbstractDragHandler- Returns:
- platform-dependent offset multiplier
-
getDeviceScale
- Specified by:
getDeviceScalein classPieceMover.AbstractDragHandler- Parameters:
dge- DG event- Returns:
- platform-dependent device scale
-
getDeviceScale
- Specified by:
getDeviceScalein classPieceMover.AbstractDragHandler
-
dragDropEnd
Description copied from class:PieceMover.AbstractDragHandlerDRAG SOURCE LISTENER INTERFACE- Specified by:
dragDropEndin interfaceDragSourceListener- Overrides:
dragDropEndin classPieceMover.AbstractDragHandler- Parameters:
e- DragSourceDropEvent
-
dragMouseMoved
Description copied from class:PieceMover.AbstractDragHandlerDRAG 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:
dragMouseMovedin interfaceDragSourceMotionListener- Overrides:
dragMouseMovedin classPieceMover.AbstractDragHandler
-
dragEnter
Description copied from class:PieceMover.AbstractDragHandlerDROP TARGET INTERFACE EVENT uses UNSCALED, DROP-TARGET coordinate system dragEnter - switches current drawWin when mouse enters a new DropTarget- Specified by:
dragEnterin interfaceDropTargetListener- Overrides:
dragEnterin classPieceMover.AbstractDragHandler
-
drop
Description copied from class:PieceMover.AbstractDragHandlerDROP 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:
dropin interfaceDropTargetListener- Overrides:
dropin classPieceMover.AbstractDragHandler
-