Class DefaultToolHandler

java.lang.Object
edu.cnu.mdi.graphics.toolbar.DefaultToolHandler
All Implemented Interfaces:
IToolHandler
Direct Known Subclasses:
PlotToolHandler

public class DefaultToolHandler extends Object implements IToolHandler
Default tool handler that performs no actions except for panning, printing, and capturing images. It is intended as a base class for custom tool handlers. It can be used like an Adapter.
Author:
heddle
  • Constructor Details

    • DefaultToolHandler

      public DefaultToolHandler()
  • Method Details

    • createRectangle

      public void createRectangle(GestureContext gc, Rectangle bounds)
      Description copied from interface: IToolHandler
      Create a rectangle.
      Specified by:
      createRectangle in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
      bounds - rectangle bounds (non-null)
    • createEllipse

      public void createEllipse(GestureContext gc, Rectangle bounds)
      Description copied from interface: IToolHandler
      Create an ellipse.
      Specified by:
      createEllipse in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
      bounds - ellipse bounds (non-null)
    • createRadArc

      public void createRadArc(GestureContext gc, Point[] vertices)
      Description copied from interface: IToolHandler
      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
      Specified by:
      createRadArc in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
      vertices - gesture vertices (non-null)
    • createTextItem

      public void createTextItem(GestureContext gc, Point location)
      Description copied from interface: IToolHandler
      Create a text item at the given location.
      Specified by:
      createTextItem in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
      location - text location (non-null)
    • hitTest

      public Object hitTest(GestureContext gc, Point p)
      Description copied from interface: IToolHandler
      Hit test at a point on the canvas.
      Specified by:
      hitTest in interface IToolHandler
      Parameters:
      gc - gesture context providing toolbar/canvas (non-null)
      p - point to test in canvas coordinates (non-null)
      Returns:
      hit object or null
    • pointerRubberbanding

      public void pointerRubberbanding(GestureContext gc, Rectangle bounds)
      Description copied from interface: IToolHandler
      Pointer rubberband feedback (typically multi-select or region selection).
      Specified by:
      pointerRubberbanding in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
      bounds - rubberband bounds (non-null)
    • pointerClick

      public void pointerClick(GestureContext gc)
      Description copied from interface: IToolHandler
      Pointer click (single click).
      Specified by:
      pointerClick in interface IToolHandler
      Parameters:
      gc - gesture context (non-null). gc.getTarget() may be null.
    • pointerDoubleClick

      public void pointerDoubleClick(GestureContext gc)
      Description copied from interface: IToolHandler
      Pointer double-click.
      Specified by:
      pointerDoubleClick in interface IToolHandler
      Parameters:
      gc - gesture context (non-null). gc.getTarget() may be null.
    • beginDragObject

      public void beginDragObject(GestureContext gc)
      Description copied from interface: IToolHandler
      Begin dragging an object/selection.
      Specified by:
      beginDragObject in interface IToolHandler
      Parameters:
      gc - gesture context (non-null). gc.getTarget() is the drag target.
    • dragObjectBy

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

      public void endDragObject(GestureContext gc)
      Description copied from interface: IToolHandler
      End dragging an object/selection.
      Specified by:
      endDragObject in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
    • doNotDrag

      public boolean doNotDrag(GestureContext gc)
      Description copied from interface: IToolHandler
      Optional veto before starting a drag.
      Specified by:
      doNotDrag in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
      Returns:
      true to veto drag start, false to allow
    • panStartDrag

      public void panStartDrag(GestureContext gc)
      Specified by:
      panStartDrag in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
    • panUpdateDrag

      public void panUpdateDrag(GestureContext gc)
      Specified by:
      panUpdateDrag in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
    • panDoneDrag

      public void panDoneDrag(GestureContext gc)
      Specified by:
      panDoneDrag in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
    • magnifyStartMove

      public void magnifyStartMove(GestureContext gc)
      Specified by:
      magnifyStartMove in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
    • magnifyUpdateMove

      public void magnifyUpdateMove(GestureContext gc)
      Specified by:
      magnifyUpdateMove in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
    • magnifyDoneMove

      public void magnifyDoneMove(GestureContext gc)
      Specified by:
      magnifyDoneMove in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
    • recenter

      public void recenter(GestureContext gc)
      Specified by:
      recenter in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
    • zoomIn

      public void zoomIn(GestureContext gc)
      Specified by:
      zoomIn in interface IToolHandler
      Parameters:
      gc - context (non-null)
    • zoomOut

      public void zoomOut(GestureContext gc)
      Specified by:
      zoomOut in interface IToolHandler
      Parameters:
      gc - context (non-null)
    • undoZoom

      public void undoZoom(GestureContext gc)
      Specified by:
      undoZoom in interface IToolHandler
      Parameters:
      gc - context (non-null)
    • resetZoom

      public void resetZoom(GestureContext gc)
      Specified by:
      resetZoom in interface IToolHandler
      Parameters:
      gc - context (non-null)
    • styleEdit

      public void styleEdit(GestureContext gc)
      Specified by:
      styleEdit in interface IToolHandler
      Parameters:
      gc - context (non-null)
    • delete

      public void delete(GestureContext gc)
      Specified by:
      delete in interface IToolHandler
      Parameters:
      gc - context (non-null)
    • captureImage

      public void captureImage(GestureContext gc)
      Specified by:
      captureImage in interface IToolHandler
      Parameters:
      gc - context (non-null)
    • print

      public void print(GestureContext gc)
      Specified by:
      print in interface IToolHandler
      Parameters:
      gc - context (non-null)
    • createConnection

      public void createConnection(GestureContext gc, Point start, Point end)
      Description copied from interface: IToolHandler
      Create a connection between two points.
      Specified by:
      createConnection in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
      start - start point (non-null)
      end - end point (non-null)
    • approveConnectionPoint

      public boolean approveConnectionPoint(GestureContext gc, Point p)
      Description copied from interface: IToolHandler
      Approve or reject a connection point.
      Specified by:
      approveConnectionPoint in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
      p - point to approve/reject (non-null)
      Returns:
      true to approve
    • boxZoomRubberbanding

      public void boxZoomRubberbanding(GestureContext gc, Rectangle bounds)
      Description copied from interface: IToolHandler
      Box-zoom rubberband completion (or continuous feedback depending on tool).
      Specified by:
      boxZoomRubberbanding in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
      bounds - rubberband bounds (non-null)
    • createPolygon

      public void createPolygon(GestureContext gc, Point[] vertices)
      Description copied from interface: IToolHandler
      Create a polygon.
      Specified by:
      createPolygon in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
      vertices - polygon vertices (non-null)
    • createPolyline

      public void createPolyline(GestureContext gc, Point[] vertices)
      Description copied from interface: IToolHandler
      Create a polyline.
      Specified by:
      createPolyline in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
      vertices - polyline vertices (non-null)
    • createLine

      public void createLine(GestureContext gc, Point start, Point end)
      Description copied from interface: IToolHandler
      Create a line between two points.
      Specified by:
      createLine in interface IToolHandler
      Parameters:
      gc - gesture context (non-null)
      start - start point
      end - end point
    • info

      public void info(GestureContext gc)
      Specified by:
      info in interface IToolHandler
      Parameters:
      gc - context (non-null)