Class APointerButton

All Implemented Interfaces:
IRubberbanded, MouseListener, MouseMotionListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, SwingConstants

public abstract class APointerButton extends JToggleButton implements MouseMotionListener, MouseListener, IRubberbanded
Toggle button that drives the "pointer" (selection/move/rubberband) tool for a canvas, disambiguating a mouse press into an object drag or a rubberband gesture based on where the press landed and how far the mouse moves before the drag threshold is crossed.

State machine

An internal Mode tracks the gesture in progress:

Extension points

Subclasses configure hit-testing and drag behavior by overriding hitTest(java.awt.Point), doNotDrag(java.lang.Object, java.awt.event.MouseEvent), clickObject(java.lang.Object, java.awt.event.MouseEvent), doubleClickObject(java.lang.Object, java.awt.event.MouseEvent), beginDragObject(java.lang.Object, java.awt.Point, java.awt.event.MouseEvent), dragObjectBy(java.lang.Object, int, int, java.awt.event.MouseEvent), endDragObject(java.lang.Object, java.awt.event.MouseEvent), and must implement rubberbanding(java.awt.Rectangle, java.awt.Point[]) to react to a completed rubberband gesture.

See Also:
  • Field Details

    • canvas

      protected Component canvas
    • toolBar

      protected AToolBar toolBar
    • policy

      protected ARubberband.Policy policy
    • rubberband

      protected ARubberband rubberband
    • dragThresholdPx

      protected int dragThresholdPx
      Drag threshold (px) to promote press into a drag gesture.
  • Constructor Details

    • APointerButton

      protected APointerButton(Component canvas, AToolBar toolBar, ARubberband.Policy policy, int minSizePx)
      Create a pointer button that supports rubberbanding.
      Parameters:
      canvas - the component on which gestures occur
      toolBar - the toolbar that owns this tool
      policy - the rubberbanding policy for this tool
      minSizePx - minimum size (in pixels) for a valid rubberband gesture
  • Method Details