JHotDraw 7.1

org.jhotdraw.draw
Interface Tool

All Superinterfaces:
java.util.EventListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
All Known Implementing Classes:
AbstractTool, BezierTool, BidirectionalConnectionTool, ConnectionTool, CreationTool, DelegationSelectionTool, DragTracker, HandleTracker, ImageTool, PathTool, PathTool, SelectAreaTracker, SelectionTool, TextAreaTool, TextTool

public interface Tool
extends java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener

A tool defines a mode of the drawing view. All input events targeted to the drawing view are forwarded to its current tool.

Tools inform listeners when they are done with an interaction by calling the ToolListener's toolDone() method. The Tools are created once and reused. They are initialized/deinitialized with activate()/deactivate().

Tools are used for user interaction. Unlike figures, a tool works with the user interface coordinates of the DrawingView. The user interface coordinates are expressed in integer pixels.

A Tool forwards UndoableEdit events to the Drawing object onto which it is performing changes.

Version:
1.0 2003-12-01 Derived from JHotDraw 5.4b1.
Author:
Werner Randelshofer

Method Summary
 void activate(DrawingEditor editor)
          Activates the tool for the given editor.
 void addToolListener(ToolListener l)
          Adds a listener for this tool.
 void deactivate(DrawingEditor editor)
          Deactivates the tool.
 void draw(java.awt.Graphics2D g)
          Draws the tool.
 void editCopy()
          Copies the selection into the clipboard.
 void editCut()
          Cuts the selection into the clipboard.
 void editDelete()
          Deletes the selection.
 void editDuplicate()
          Duplicates the selection.
 void editPaste()
          Pastes the contents of the clipboard.
 void removeToolListener(ToolListener l)
          Removes a listener for this tool.
 
Methods inherited from interface java.awt.event.MouseListener
mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased
 
Methods inherited from interface java.awt.event.MouseMotionListener
mouseDragged, mouseMoved
 
Methods inherited from interface java.awt.event.KeyListener
keyPressed, keyReleased, keyTyped
 

Method Detail

activate

void activate(DrawingEditor editor)
Activates the tool for the given editor. This method is called whenever the user switches to this tool.


deactivate

void deactivate(DrawingEditor editor)
Deactivates the tool. This method is called whenever the user switches to another tool.


addToolListener

void addToolListener(ToolListener l)
Adds a listener for this tool.


removeToolListener

void removeToolListener(ToolListener l)
Removes a listener for this tool.


draw

void draw(java.awt.Graphics2D g)
Draws the tool.


editDelete

void editDelete()
Deletes the selection. Depending on the tool, this could be selected figures, selected points or selected text.


editCut

void editCut()
Cuts the selection into the clipboard. Depending on the tool, this could be selected figures, selected points or selected text.


editCopy

void editCopy()
Copies the selection into the clipboard. Depending on the tool, this could be selected figures, selected points or selected text.


editDuplicate

void editDuplicate()
Duplicates the selection. Depending on the tool, this could be selected figures, selected points or selected text.


editPaste

void editPaste()
Pastes the contents of the clipboard. Depending on the tool, this could be selected figures, selected points or selected text.


Copyright 1996-2007 (c) JHotDraw.org.
Some rights reserved.