Package edu.cnu.mdi.graphics.toolbar
Interface IToolHandler
- All Known Implementing Classes:
BaseToolHandler,DefaultToolHandler,MapToolHandler,PlotToolHandler
public interface IToolHandler
Callback interface for toolbar tools.
This interface is intentionally "gesture-first": wherever a tool is driven by
a pointer gesture (press/drag/release, rubberbanding, hover move), the callback
receives a GestureContext. This keeps signatures uniform and makes it
easy to extend tools without proliferating parameter combinations.
Hit testing
The handler provides hit-testing so applications can map canvas points to domain objects (items, nodes, handles, etc.).
One-shot actions
Even one-shot actions (zoom in/out, print, delete...) receive a GestureContext
so handlers always have access to toolbar, canvas, and a representative point.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanApprove or reject a connection point.voidBegin dragging an object/selection.voidboxZoomRubberbanding(GestureContext gc, Rectangle bounds) Box-zoom rubberband completion (or continuous feedback depending on tool).voidvoidcreateConnection(GestureContext gc, Point start, Point end) Create a connection between two points.voidcreateEllipse(GestureContext gc, Rectangle bounds) Create an ellipse.voidcreateLine(GestureContext gc, Point start, Point end) Create a line between two points.voidcreatePolygon(GestureContext gc, Point[] vertices) Create a polygon.voidcreatePolyline(GestureContext gc, Point[] vertices) Create a polyline.voidcreateRadArc(GestureContext gc, Point[] vertices) Create a radial arc.voidcreateRectangle(GestureContext gc, Rectangle bounds) Create a rectangle.voidcreateTextItem(GestureContext gc, Point location) Create a text item at the given location.voiddelete(GestureContext gc) booleanOptional veto before starting a drag.voiddragObjectBy(GestureContext gc, int dx, int dy) Drag the object/selection by a pixel delta.voidEnd dragging an object/selection.hitTest(GestureContext gc, Point p) Hit test at a point on the canvas.voidinfo(GestureContext gc) voidvoidvoidvoidvoidvoidvoidPointer click (single click).voidPointer double-click.voidpointerRubberbanding(GestureContext gc, Rectangle bounds) Pointer rubberband feedback (typically multi-select or region selection).voidprint(GestureContext gc) voidvoidvoidvoidvoidzoomIn(GestureContext gc) void
-
Method Details
-
hitTest
Hit test at a point on the canvas.- Parameters:
gc- gesture context providing toolbar/canvas (non-null)p- point to test in canvas coordinates (non-null)- Returns:
- hit object or null
-
pointerRubberbanding
Pointer rubberband feedback (typically multi-select or region selection).- Parameters:
gc- gesture context (non-null)bounds- rubberband bounds (non-null)
-
pointerClick
Pointer click (single click).- Parameters:
gc- gesture context (non-null).gc.getTarget()may be null.
-
pointerDoubleClick
Pointer double-click.- Parameters:
gc- gesture context (non-null).gc.getTarget()may be null.
-
beginDragObject
Begin dragging an object/selection.- Parameters:
gc- gesture context (non-null).gc.getTarget()is the drag target.
-
dragObjectBy
Drag the object/selection by a pixel delta.- Parameters:
gc- gesture context (non-null)dx- delta x since last updatedy- delta y since last update
-
endDragObject
End dragging an object/selection.- Parameters:
gc- gesture context (non-null)
-
doNotDrag
Optional veto before starting a drag.- Parameters:
gc- gesture context (non-null)- Returns:
- true to veto drag start, false to allow
-
boxZoomRubberbanding
Box-zoom rubberband completion (or continuous feedback depending on tool).- Parameters:
gc- gesture context (non-null)bounds- rubberband bounds (non-null)
-
panStartDrag
- Parameters:
gc- gesture context (non-null)
-
panUpdateDrag
- Parameters:
gc- gesture context (non-null)
-
panDoneDrag
- Parameters:
gc- gesture context (non-null)
-
magnifyStartMove
- Parameters:
gc- gesture context (non-null)
-
magnifyUpdateMove
- Parameters:
gc- gesture context (non-null)
-
magnifyDoneMove
- Parameters:
gc- gesture context (non-null)
-
recenter
- Parameters:
gc- gesture context (non-null)
-
zoomIn
- Parameters:
gc- context (non-null)
-
zoomOut
- Parameters:
gc- context (non-null)
-
undoZoom
- Parameters:
gc- context (non-null)
-
resetZoom
- Parameters:
gc- context (non-null)
-
styleEdit
- Parameters:
gc- context (non-null)
-
delete
- Parameters:
gc- context (non-null)
-
info
- Parameters:
gc- context (non-null)
-
captureImage
- Parameters:
gc- context (non-null)
-
print
- Parameters:
gc- context (non-null)
-
createConnection
Create a connection between two points.- Parameters:
gc- gesture context (non-null)start- start point (non-null)end- end point (non-null)
-
approveConnectionPoint
Approve or reject a connection point.- Parameters:
gc- gesture context (non-null)p- point to approve/reject (non-null)- Returns:
- true to approve
-
createRectangle
Create a rectangle.- Parameters:
gc- gesture context (non-null)bounds- rectangle bounds (non-null)
-
createEllipse
Create an ellipse.- Parameters:
gc- gesture context (non-null)bounds- ellipse bounds (non-null)
-
createRadArc
Create a radial arc.The expected interpretation of vertices is tool-defined; for a typical radial arc gesture:
- vertices[0] = center
- vertices[1] = radius leg endpoint
- vertices[2] = angle-defining point
- Parameters:
gc- gesture context (non-null)vertices- gesture vertices (non-null)
-
createPolygon
Create a polygon.- Parameters:
gc- gesture context (non-null)vertices- polygon vertices (non-null)
-
createPolyline
Create a polyline.- Parameters:
gc- gesture context (non-null)vertices- polyline vertices (non-null)
-
createLine
Create a line between two points.- Parameters:
gc- gesture context (non-null)start- start pointend- end point
-
createTextItem
Create a text item at the given location.- Parameters:
gc- gesture context (non-null)location- text location (non-null)
-