public interface Handle
extends java.awt.event.KeyListener
Figure
by direct
manipulation.
A handle is owned by a figure and associated to a DrawingView
.
Handle
knows its owning figure and its associated drawing view.
Handles are drawn using the view coordinates of the associated
DrawingView
. Handle
uses methods of the drawing view to
translate the view coordinates into drawing coordinates, which is the
coordinate system used by the owning figure.
Mouse and keyboard events of the user occur on a drawing view, and are
preprocessed by the DragTracker
of a
SelectionTool
. DragTracker
invokes
"track" methods on the handle, such as trackStart
,
trackStep
and trackEnd
.
Handle forwards UndoableEdit
events to the drawing object onto
which it is performing changes.
Framework
The following interfaces define the contracts of a framework for structured
drawing editors:
Contract: Drawing
, Figure
, DrawingView
,
DrawingEditor
, Handle
and Tool
.
Observer
State changes of handles can be observed by other objects. Specifically
DrawingView
observes area invalidations and remove requests of
handles.
Subject: Handle
;
Observer: HandleListener
;
Event: HandleEvent
;
Concrete Observer: DrawingView
.
Chain of responsibility
Mouse and keyboard events of the user occur on the drawing view, and are
preprocessed by the DragTracker
of a SelectionTool
. In
turn DragTracker
invokes "track" methods on a Handle
which in
turn changes an aspect of a figure.
Client: SelectionTool
;
Handler: DragTracker
, Handle
.
Modifier and Type | Method and Description |
---|---|
void |
addHandleListener(HandleListener l)
Adds a listener for this handle.
|
boolean |
contains(java.awt.Point p)
Tests if a point is contained in the handle.
|
java.util.Collection<Handle> |
createSecondaryHandles()
Creates secondary handles.
|
void |
dispose()
Disposes the resources aquired by the handler.
|
void |
draw(java.awt.Graphics2D g)
Draws this handle.
|
java.awt.Rectangle |
getBounds()
Returns the bounding box of the handle.
|
java.awt.Cursor |
getCursor()
Returns a cursor for the handle.
|
java.awt.Rectangle |
getDrawingArea()
Returns the drawing area of the handle.
|
Figure |
getOwner()
Returns the owner of this handle.
|
java.lang.String |
getToolTipText(java.awt.Point p)
Returns a tooltip for the specified location.
|
void |
invalidate()
Invalidates the handle.
|
boolean |
isCombinableWith(Handle handle)
Returns true, if this handle is combinable with the specified handle.
|
void |
removeHandleListener(HandleListener l)
Removes a listener for this handle.
|
void |
setView(DrawingView view)
Sets the view of the handle.
|
void |
trackDoubleClick(java.awt.Point p,
int modifiersEx)
Tracks a double click.
|
void |
trackEnd(java.awt.Point anchor,
java.awt.Point lead,
int modifiersEx)
Tracks the end of the interaction.
|
void |
trackStart(java.awt.Point anchor,
int modifiersEx)
Tracks the start of the interaction.
|
void |
trackStep(java.awt.Point anchor,
java.awt.Point lead,
int modifiersEx)
Tracks a step of the interaction.
|
void |
viewTransformChanged()
This method is invoked by the drawing view, when its transform
has changed.
|
Figure getOwner()
void setView(DrawingView view)
void addHandleListener(HandleListener l)
void removeHandleListener(HandleListener l)
java.awt.Rectangle getBounds()
java.awt.Rectangle getDrawingArea()
boolean contains(java.awt.Point p)
void draw(java.awt.Graphics2D g)
void invalidate()
void dispose()
java.awt.Cursor getCursor()
boolean isCombinableWith(Handle handle)
void trackStart(java.awt.Point anchor, int modifiersEx)
anchor
- the position where the interaction startedvoid trackStep(java.awt.Point anchor, java.awt.Point lead, int modifiersEx)
anchor
- the position where the interaction startedlead
- the current positionvoid trackEnd(java.awt.Point anchor, java.awt.Point lead, int modifiersEx)
anchor
- the position where the interaction startedlead
- the current positionvoid trackDoubleClick(java.awt.Point p, int modifiersEx)
void viewTransformChanged()
java.util.Collection<Handle> createSecondaryHandles()
java.lang.String getToolTipText(java.awt.Point p)