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.KeyListenerA handle is used to change one aspect of aFigureby direct manipulation.A handle is owned by a figure and associated to a
DrawingView.Handleknows its owning figure and its associated drawing view.Handles are drawn using the view coordinates of the associated
DrawingView.Handleuses 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
DragTrackerof aSelectionTool.DragTrackerinvokes "track" methods on the handle, such astrackStart,trackStepandtrackEnd.Handle forwards
UndoableEditevents to the drawing object onto which it is performing changes.
Design PatternsFramework
The following interfaces define the contracts of a framework for structured drawing editors:
Contract:Drawing,Figure,DrawingView,DrawingEditor,HandleandTool.Observer
State changes of handles can be observed by other objects. SpecificallyDrawingViewobserves 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 theDragTrackerof aSelectionTool. In turnDragTrackerinvokes "track" methods on aHandlewhich in turn changes an aspect of a figure.
Client:SelectionTool; Handler:DragTracker,Handle.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description voidaddHandleListener(HandleListener l)Adds a listener for this handle.booleancontains(java.awt.Point p)Tests if a point is contained in the handle.java.util.Collection<Handle>createSecondaryHandles()Creates secondary handles.voiddispose()Disposes the resources aquired by the handler.voiddraw(java.awt.Graphics2D g)Draws this handle.java.awt.RectanglegetBounds()Returns the bounding box of the handle.java.awt.CursorgetCursor()Returns a cursor for the handle.java.awt.RectanglegetDrawingArea()Returns the drawing area of the handle.FiguregetOwner()Returns the owner of this handle.java.lang.StringgetToolTipText(java.awt.Point p)Returns a tooltip for the specified location.voidinvalidate()Invalidates the handle.booleanisCombinableWith(Handle handle)Returns true, if this handle is combinable with the specified handle.voidremoveHandleListener(HandleListener l)Removes a listener for this handle.voidsetView(DrawingView view)Sets the view of the handle.voidtrackDoubleClick(java.awt.Point p, int modifiersEx)Tracks a double click.voidtrackEnd(java.awt.Point anchor, java.awt.Point lead, int modifiersEx)Tracks the end of the interaction.voidtrackStart(java.awt.Point anchor, int modifiersEx)Tracks the start of the interaction.voidtrackStep(java.awt.Point anchor, java.awt.Point lead, int modifiersEx)Tracks a step of the interaction.voidviewTransformChanged()This method is invoked by the drawing view, when its transform has changed.
-
-
-
Method Detail
-
getOwner
Figure getOwner()
Returns the owner of this handle.
-
setView
void setView(@Nullable 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 startedlead- 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 startedlead- 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
@Nullable java.util.Collection<Handle> createSecondaryHandles()
Creates secondary handles.
-
getToolTipText
@Nullable java.lang.String getToolTipText(java.awt.Point p)
Returns a tooltip for the specified location.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG