org.jhotdraw.contrib.dnd
Class DragNDropTool

java.lang.Object
  extended by org.jhotdraw.standard.AbstractTool
      extended by org.jhotdraw.contrib.dnd.DragNDropTool
All Implemented Interfaces:
Tool

public class DragNDropTool
extends AbstractTool

This is a tool which handles drag and drop between Components in JHotDraw and drags from JHotDraw. It also indirectly handles management of Drops from extra-JVM sources. Drag and Drop is about information moving, not images or objects. Its about moving a JHD rectangle to another application and that application understanding both its shape, color, attributes, and everything about it. not how it looks. There can be only 1 such tool in an application. A view can be registered with only a single DropSource as far as I know (maybe not).

Version:
<$CURRENT_VERSION$>
Author:
C.L.Gilbert

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jhotdraw.standard.AbstractTool
AbstractTool.EventDispatcher
 
Constructor Summary
DragNDropTool(DrawingEditor editor)
           
 
Method Summary
 void activate()
          Turn on drag by adding a DragGestureRegognizer to all Views which are based on Components.
 void deactivate()
          Deactivates the tool.
 void mouseDown(java.awt.event.MouseEvent e, int x, int y)
          Handles mouse down events and starts the corresponding tracker.
 void mouseDrag(java.awt.event.MouseEvent e, int x, int y)
          Handles mouse drag events.
 void mouseMove(java.awt.event.MouseEvent evt, int x, int y)
          Handles mouse moves (if the mouse button is up).
 void mouseUp(java.awt.event.MouseEvent e, int x, int y)
          Handles mouse up events.
static void setCursor(int x, int y, DrawingView view)
          Sets the type of cursor based on what is under the coordinates in the active view.
 
Methods inherited from class org.jhotdraw.standard.AbstractTool
addToolListener, drawing, editor, getActiveDrawing, getActiveView, getUndoActivity, isActive, isEnabled, isUsable, keyDown, removeToolListener, setEnabled, setUndoActivity, setUsable, view
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DragNDropTool

public DragNDropTool(DrawingEditor editor)
Method Detail

activate

public void activate()
Turn on drag by adding a DragGestureRegognizer to all Views which are based on Components.

Specified by:
activate in interface Tool
Overrides:
activate in class AbstractTool

deactivate

public void deactivate()
Description copied from class: AbstractTool
Deactivates the tool. This method is called whenever the user switches to another tool. Use this method to do some clean-up when the tool is switched. Subclassers should always call super.deactivate. An inactive tool should never be deactivated

Specified by:
deactivate in interface Tool
Overrides:
deactivate in class AbstractTool

setCursor

public static void setCursor(int x,
                             int y,
                             DrawingView view)
Sets the type of cursor based on what is under the coordinates in the active view.


mouseMove

public void mouseMove(java.awt.event.MouseEvent evt,
                      int x,
                      int y)
Handles mouse moves (if the mouse button is up). Switches the cursors depending on whats under them. Don't use x, y use getX and getY so get the real unlimited position Part of the Tool interface.

Specified by:
mouseMove in interface Tool
Overrides:
mouseMove in class AbstractTool

mouseUp

public void mouseUp(java.awt.event.MouseEvent e,
                    int x,
                    int y)
Handles mouse up events. The events are forwarded to the current tracker. Part of the Tool interface.

Specified by:
mouseUp in interface Tool
Overrides:
mouseUp in class AbstractTool

mouseDown

public void mouseDown(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Handles mouse down events and starts the corresponding tracker. Part of the Tool interface.

Specified by:
mouseDown in interface Tool
Overrides:
mouseDown in class AbstractTool

mouseDrag

public void mouseDrag(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Handles mouse drag events. The events are forwarded to the current tracker. Part of the Tool interface.

Specified by:
mouseDrag in interface Tool
Overrides:
mouseDrag in class AbstractTool