JHotDraw 7.4.1

org.jhotdraw.draw.handle
Interface Handle

All Superinterfaces:
java.util.EventListener, java.awt.event.KeyListener
All Known Implementing Classes:
AbstractConnectionHandle, AbstractHandle, AbstractRotateHandle, BezierControlPointHandle, BezierNodeHandle, BezierOutlineHandle, BezierScaleHandle, BoundsOutlineHandle, CloseHandle, ConnectionEndHandle, ConnectionStartHandle, ConnectorHandle, ConvexHullOutlineHandle, DragHandle, FontSizeHandle, LinkHandle, LocatorHandle, MoveHandle, NullHandle, ODGPathOutlineHandle, ODGRectRadiusHandle, OrientationHandle, RotateHandle, RoundRectangleRadiusHandle, SVGPathOutlineHandle, SVGRectRadiusHandle, TextOverflowHandle

public interface Handle
extends java.awt.event.KeyListener

A handle is used to change one aspect of a 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.


Design Patterns

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.


Version:
$Id: Handle.java 604 2010-01-09 12:00:29Z rawcoder $
Author:
Werner Randelshofer

Method Summary
 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.
 
Methods inherited from interface java.awt.event.KeyListener
keyPressed, keyReleased, keyTyped
 

Method Detail

getOwner

Figure getOwner()
Returns the owner of this handle.


setView

void setView(DrawingView view)
Sets the view of the handle.


addHandleListener

void addHandleListener(HandleListener l)
Adds a listener for this handle.


removeHandleListener

void removeHandleListener(HandleListener l)
Removes a listener for this handle.


getBounds

java.awt.Rectangle getBounds()
Returns the bounding box of the handle. Note: The bounding box must be returned in the coordinate system of the DrawingView.


getDrawingArea

java.awt.Rectangle getDrawingArea()
Returns the drawing area of the handle. Note: The drawing area must be returned in the coordinate system of the DrawingView.


contains

boolean contains(java.awt.Point p)
Tests if a point is contained in the handle.


draw

void draw(java.awt.Graphics2D g)
Draws this handle. Note: The handle is drawn with the coordinate system of the DrawingView.


invalidate

void invalidate()
Invalidates the handle. This method informs its listeners that its current display box is invalid and should be refreshed.


dispose

void dispose()
Disposes the resources aquired by the handler.


getCursor

java.awt.Cursor getCursor()
Returns a cursor for the handle.


isCombinableWith

boolean isCombinableWith(Handle handle)
Returns true, if this handle is combinable with the specified handle. This method is used to determine, if multiple handles need to be tracked, when more than one figure is selected.


trackStart

void trackStart(java.awt.Point anchor,
                int modifiersEx)
Tracks the start of the interaction. The default implementation does nothing.

Parameters:
anchor - the position where the interaction started

trackStep

void trackStep(java.awt.Point anchor,
               java.awt.Point lead,
               int modifiersEx)
Tracks a step of the interaction.

Parameters:
anchor - the position where the interaction started
lead - the current position

trackEnd

void trackEnd(java.awt.Point anchor,
              java.awt.Point lead,
              int modifiersEx)
Tracks the end of the interaction.

Parameters:
anchor - the position where the interaction started
lead - the current position

trackDoubleClick

void trackDoubleClick(java.awt.Point p,
                      int modifiersEx)
Tracks a double click.


viewTransformChanged

void viewTransformChanged()
This method is invoked by the drawing view, when its transform has changed. This means, that DrawingView.viewToDrawing and DrawingView.drawingToView will return different values than they did before.


createSecondaryHandles

java.util.Collection<Handle> createSecondaryHandles()
Creates secondary handles.


getToolTipText

java.lang.String getToolTipText(java.awt.Point p)
Returns a tooltip for the specified location.


Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.