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 Details

    • hitTest

      Object hitTest(GestureContext gc, Point p)
      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

      void pointerRubberbanding(GestureContext gc, Rectangle bounds)
      Pointer rubberband feedback (typically multi-select or region selection).
      Parameters:
      gc - gesture context (non-null)
      bounds - rubberband bounds (non-null)
    • pointerClick

      void pointerClick(GestureContext gc)
      Pointer click (single click).
      Parameters:
      gc - gesture context (non-null). gc.getTarget() may be null.
    • pointerDoubleClick

      void pointerDoubleClick(GestureContext gc)
      Pointer double-click.
      Parameters:
      gc - gesture context (non-null). gc.getTarget() may be null.
    • beginDragObject

      void beginDragObject(GestureContext gc)
      Begin dragging an object/selection.
      Parameters:
      gc - gesture context (non-null). gc.getTarget() is the drag target.
    • dragObjectBy

      void dragObjectBy(GestureContext gc, int dx, int dy)
      Drag the object/selection by a pixel delta.
      Parameters:
      gc - gesture context (non-null)
      dx - delta x since last update
      dy - delta y since last update
    • endDragObject

      void endDragObject(GestureContext gc)
      End dragging an object/selection.
      Parameters:
      gc - gesture context (non-null)
    • doNotDrag

      boolean doNotDrag(GestureContext gc)
      Optional veto before starting a drag.
      Parameters:
      gc - gesture context (non-null)
      Returns:
      true to veto drag start, false to allow
    • boxZoomRubberbanding

      void boxZoomRubberbanding(GestureContext gc, Rectangle bounds)
      Box-zoom rubberband completion (or continuous feedback depending on tool).
      Parameters:
      gc - gesture context (non-null)
      bounds - rubberband bounds (non-null)
    • panStartDrag

      void panStartDrag(GestureContext gc)
      Parameters:
      gc - gesture context (non-null)
    • panUpdateDrag

      void panUpdateDrag(GestureContext gc)
      Parameters:
      gc - gesture context (non-null)
    • panDoneDrag

      void panDoneDrag(GestureContext gc)
      Parameters:
      gc - gesture context (non-null)
    • magnifyStartMove

      void magnifyStartMove(GestureContext gc)
      Parameters:
      gc - gesture context (non-null)
    • magnifyUpdateMove

      void magnifyUpdateMove(GestureContext gc)
      Parameters:
      gc - gesture context (non-null)
    • magnifyDoneMove

      void magnifyDoneMove(GestureContext gc)
      Parameters:
      gc - gesture context (non-null)
    • recenter

      void recenter(GestureContext gc)
      Parameters:
      gc - gesture context (non-null)
    • zoomIn

      void zoomIn(GestureContext gc)
      Parameters:
      gc - context (non-null)
    • zoomOut

      void zoomOut(GestureContext gc)
      Parameters:
      gc - context (non-null)
    • undoZoom

      void undoZoom(GestureContext gc)
      Parameters:
      gc - context (non-null)
    • resetZoom

      void resetZoom(GestureContext gc)
      Parameters:
      gc - context (non-null)
    • styleEdit

      void styleEdit(GestureContext gc)
      Parameters:
      gc - context (non-null)
    • delete

      void delete(GestureContext gc)
      Parameters:
      gc - context (non-null)
    • info

      void info(GestureContext gc)
      Parameters:
      gc - context (non-null)
    • captureImage

      void captureImage(GestureContext gc)
      Parameters:
      gc - context (non-null)
    • print

      void print(GestureContext gc)
      Parameters:
      gc - context (non-null)
    • createConnection

      void createConnection(GestureContext gc, Point start, Point end)
      Create a connection between two points.
      Parameters:
      gc - gesture context (non-null)
      start - start point (non-null)
      end - end point (non-null)
    • approveConnectionPoint

      boolean approveConnectionPoint(GestureContext gc, Point p)
      Approve or reject a connection point.
      Parameters:
      gc - gesture context (non-null)
      p - point to approve/reject (non-null)
      Returns:
      true to approve
    • createRectangle

      void createRectangle(GestureContext gc, Rectangle bounds)
      Create a rectangle.
      Parameters:
      gc - gesture context (non-null)
      bounds - rectangle bounds (non-null)
    • createEllipse

      void createEllipse(GestureContext gc, Rectangle bounds)
      Create an ellipse.
      Parameters:
      gc - gesture context (non-null)
      bounds - ellipse bounds (non-null)
    • createRadArc

      void createRadArc(GestureContext gc, Point[] vertices)
      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

      void createPolygon(GestureContext gc, Point[] vertices)
      Create a polygon.
      Parameters:
      gc - gesture context (non-null)
      vertices - polygon vertices (non-null)
    • createPolyline

      void createPolyline(GestureContext gc, Point[] vertices)
      Create a polyline.
      Parameters:
      gc - gesture context (non-null)
      vertices - polyline vertices (non-null)
    • createLine

      void createLine(GestureContext gc, Point start, Point end)
      Create a line between two points.
      Parameters:
      gc - gesture context (non-null)
      start - start point
      end - end point
    • createTextItem

      void createTextItem(GestureContext gc, Point location)
      Create a text item at the given location.
      Parameters:
      gc - gesture context (non-null)
      location - text location (non-null)