DixShtix

com.dixshtix.awt
Interface DragCapable

All Known Implementing Classes:
ShapeDraggablePanel

public interface DragCapable

Interface for Components which implement Graphics2D-aware dragging.

Copyright: Copyright (c) Richard C. Penner II

Company:

Version:
1.0
Author:
Richard C. Penner II

Method Summary
 void dragNotify(Draggable d, java.awt.geom.Point2D oldPos, java.awt.geom.Point2D newPos)
          Message sent upon the completion of a drag gesture.
 Draggable findDraggable(int x, int y)
          Given the coordinates of a mouse click, return the corresponding draggable widget.
 java.awt.geom.Point2D pinPoint(Draggable d, java.awt.geom.Point2D original, int delta_x, int delta_y)
          Given the original position of the current draggable, and the requested offset, compute the constrained current position.
 

Method Detail

findDraggable

public Draggable findDraggable(int x,
                               int y)
Given the coordinates of a mouse click, return the corresponding draggable widget.
Parameters:
x - The x-coordinate of the mouse down event.
y - The y-coordinate of the mouse down event.
Returns:
A matching Draggable or null if no shape matches.

pinPoint

public java.awt.geom.Point2D pinPoint(Draggable d,
                                      java.awt.geom.Point2D original,
                                      int delta_x,
                                      int delta_y)
Given the original position of the current draggable, and the requested offset, compute the constrained current position.
Parameters:
d - The Draggable shape which is being dragged.
original - The original position of the shape.
delta_x - The horizontal offset of the ongoing drag.
delta_y - The vertical offset of the ongoing drag.
Returns:
The logical position of the currently dragged shape which might be thought of as the constrained sum of the original and offset.

dragNotify

public void dragNotify(Draggable d,
                       java.awt.geom.Point2D oldPos,
                       java.awt.geom.Point2D newPos)
Message sent upon the completion of a drag gesture. The exact processing of this message is highly application-dependent.
Parameters:
d - The Draggable shape which has been dragged.
oldPos - The location of the draggable at the beginning of the drag gesture.
newPos - The location, returned by pinPoint(com.dixshtix.awt.Draggable, java.awt.geom.Point2D, int, int), of the draggable at the end of the drag gesture.

DixShtix