public class SelectionTool extends AbstractTool implements Tool
Modifier and Type | Field and Description |
---|---|
protected Tool |
cachedNullTool
helper null tool to avoid creating and destroying objects all the time
|
protected Figure |
draggedFigure
the figure that is being dragged.
|
protected Tool |
fChild
Sub tool to delegate to.
|
(package private) RubberBandSelectionStrategy |
selectionStrategy
the rubber band selection strategy to use.
|
editor, fAnchorX, fAnchorY
Constructor and Description |
---|
SelectionTool(DrawingEditor editor)
create the selection tool
|
SelectionTool(DrawingEditor editor,
RubberBandSelectionStrategy selectionStrategy)
define a selection tool where the SelectAreaTracker takes a special
RubberBandSelection strategy.
|
Modifier and Type | Method and Description |
---|---|
protected Tool |
createAreaTracker()
Factory method to create an Area Tracker.
|
protected Tool |
createDragTracker(Figure f)
Factory method to create a Drag tracker.
|
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 in the drawing view (while mouse button is down).
|
void |
mouseMove(java.awt.event.MouseEvent e,
int x,
int y)
Handles mouse moves (while the mouse button is up).
|
void |
mouseUp(java.awt.event.MouseEvent e,
int x,
int y)
Handles mouse up in the drawing view.
|
editor, keyDown
protected Tool fChild
protected Tool cachedNullTool
protected Figure draggedFigure
RubberBandSelectionStrategy selectionStrategy
public SelectionTool(DrawingEditor editor)
editor
- the editor the tool is associated withpublic SelectionTool(DrawingEditor editor, RubberBandSelectionStrategy selectionStrategy)
editor
- the editor to be associated withselectionStrategy
- the rubberband selection strategy to usepublic void mouseDown(java.awt.event.MouseEvent e, int x, int y)
mouseDown
in interface Tool
mouseDown
in class AbstractTool
e
- the mouse event itselfx
- x coordinatey
- y coordinatepublic void mouseDrag(java.awt.event.MouseEvent e, int x, int y)
Tool
mouseDrag
in interface Tool
mouseDrag
in class AbstractTool
e
- the original mouse event from AWTx
- the x coordinate of the mouse cursory
- the y coordinate of the mouse cursorpublic void mouseMove(java.awt.event.MouseEvent e, int x, int y)
Tool
mouseMove
in interface Tool
mouseMove
in class AbstractTool
e
- the original mouse event from AWTx
- the x coordinate of the mouse cursory
- the y coordinate of the mouse cursorpublic void mouseUp(java.awt.event.MouseEvent e, int x, int y)
Tool
mouseUp
in interface Tool
mouseUp
in class AbstractTool
e
- the original mouse event from AWTx
- the x coordinate of the mouse cursory
- the y coordinate of the mouse cursorprotected Tool createDragTracker(Figure f)
f
- the figure to dragprotected Tool createAreaTracker()
From the book: Flexible, Reliable Software, © CRC Press 2010. Author: Henrik B. Christensen, Aarhus University, Denmark