Package swingtree

Class ComponentDragEventDelegate<C extends JComponent>

Type Parameters:
C - The type of JComponent that this ComponentDragEventDelegate is delegating to.

public final class ComponentDragEventDelegate<C extends JComponent> extends ComponentMouseEventDelegate<C>
A JComponent and MouseEvent delegate providing useful context information to various Action listeners used by UIForAnySwing.onMouseDrag(Action) like for example the ComponentMouseEventDelegate.mouseX() and ComponentMouseEventDelegate.mouseY() of the event as well as more drag specific information like dragEvents() and dragPositions().
  • Method Details

    • dragEvents

      public sprouts.Tuple<MouseEvent> dragEvents()
      Provides a Tuple (immutable list) of all MouseEvents of a continuous mouse drag performed on the component. When a drag ends, the tuple is empty.
      Returns:
      A tuple of all MouseEvents of a continuous mouse drag performed on the component.
    • dragPositions

      public sprouts.Tuple<Position> dragPositions()
      SwingTree keeps track of the most recent mouse drag events of a continuous drag. This method returns a Tuple (immutable list) of all mouse Positions of a continuous mouse drag performed on the component.
      Note that these points are scaled to "developer pixel" instead of the actual "UI scaled component space" of the underlying Swing component.
      Use UI.scale(int) to convert these points back to the actual "UI scaled component space". Also note that this method returns an unmodifiable list consisting of immutable Position objects instead of mutable Point objects, to protect the client from side effects.
      Returns:
      A tuple (immutable list) of all mouse Positions of a continuous mouse drag performed on the component. The points of this list represent the mouse movement track since the start of a continuous drag.
    • deltaXSinceStart

      public float deltaXSinceStart()
      Provides the x-axis movement delta of the mouse since the start of a continuous drag without DPI scaling. So the value is in "developer pixel" not in UI scaled component space. This means that when you need to interface with the underlying Swing API then you may want to consider upscaling it again using UI.scale(float).
      Returns:
      The x-axis movement delta of the mouse since the start of a continuous drag. This value is in "developer pixel" not in UI scaled component space.
    • deltaYSinceStart

      public float deltaYSinceStart()
      Provides the y-axis movement delta of the mouse since the start of a continuous drag without DPI scaling. So the value is in "developer pixel" not in UI scaled component space. This means that when you need to interface with the underlying Swing API then you may want to consider upscaling it again using UI.scale(float).
      Returns:
      The y-axis movement delta of the mouse since the start of a continuous drag. This value is in "developer pixel" not in UI scaled component space.