JHotDraw 6.0b1

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).


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.
protected  Tool createAreaTracker()
          Factory method to create an area tracker.
protected  Tool createDragTracker(DrawingEditor editor, Figure f)
          Factory method to create a Drag tracker.
protected  Tool createHandleTracker(Handle handle)
          Factory method to create a Handle tracker.
 void deactivate()
          Deactivates the tool.
protected  boolean isDragOn()
           
 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.
protected  void setDragOn(boolean isNewDragOn)
           
protected  void viewCreated(DrawingView view)
          Sent when a new view is created
protected  void viewDestroying(DrawingView view)
          Send when an existing view is about to be destroyed.
 
Methods inherited from class org.jhotdraw.standard.AbstractTool
addToolListener, checkUsable, createEventDispatcher, createViewChangeListener, drawing, editor, getActiveDrawing, getActiveView, getAnchorX, getAnchorY, getEventDispatcher, getUndoActivity, isActive, isEnabled, isUsable, keyDown, removeToolListener, setAnchorX, setAnchorY, setEditor, setEnabled, setUndoActivity, setUsable, setView, view, viewSelectionChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DragNDropTool

public DragNDropTool(DrawingEditor editor)
Method Detail

viewCreated

protected void viewCreated(DrawingView view)
Sent when a new view is created

Overrides:
viewCreated in class AbstractTool

viewDestroying

protected void viewDestroying(DrawingView view)
Send when an existing view is about to be destroyed.

Overrides:
viewDestroying in class AbstractTool

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

createAreaTracker

protected Tool createAreaTracker()
Factory method to create an area tracker. It is used to select an area.


createDragTracker

protected Tool createDragTracker(DrawingEditor editor,
                                 Figure f)
Factory method to create a Drag tracker. It is used to drag a figure.


createHandleTracker

protected Tool createHandleTracker(Handle handle)
Factory method to create a Handle tracker. It is used to track a handle.


isDragOn

protected boolean isDragOn()

setDragOn

protected void setDragOn(boolean isNewDragOn)

JHotDraw 6.0b1