|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.umd.cs.jazz.event.ZFilteredEventHandler | +--edu.umd.cs.jazz.event.ZDragSequenceEventHandler
ZDragSequenceEventHandler is designed to support drag sequence interactions normally consisting of filtered mouse pressed, filtered mouse dragged, and filtered mouse released events. This class doesn't do anything useful on its own but it helps to support drag sequences in the event handlers that subclass it.
ZDragSequenceEventHandler works by setting up three template methods;
protected void startDrag(ZMouseEvent e)
protected void drag(ZMouseEvent e)
protected void dragInScreenCoords(ZMouseEvent e, Dimension2D aScreenDelta)
protected void endDrag(ZMouseEvent e)
Event handlers that use drag sequences in their interactions should override these template methods and invoke the appropriate behavior from within those methods.
Using this class to implement your drag sequences increases flexibility in a number of ways. Since this class removes the coupling between filtered mouse down events and startDrag
it's fairly easy for someone to subclass your event handler and map the drag sequence to a different set of filtered mouse events instead of the standard filtered mouse pressed, filtered mouse dragged, filtered mouse released sequence.
This class also supports the notion of a minimum drag start distance. That is the distance that the mouse must be dragged before the drag sequence will start.
Nested Class Summary |
Nested classes inherited from class edu.umd.cs.jazz.event.ZFilteredEventHandler |
ZFilteredEventHandler.ZFilteredEventDispatcher |
Field Summary |
Fields inherited from class edu.umd.cs.jazz.event.ZFilteredEventHandler |
fFilteredEventDispatcher, fMouseFilter |
Constructor Summary | |
ZDragSequenceEventHandler(ZSceneGraphObject aFilteredMouseEventSource) Constructs a new ZDragSequenceEventHandler. |
|
ZDragSequenceEventHandler(ZSceneGraphObject aFilteredMouseEventSource, ZCanvas aFilteredKeyEventSouce) Constructs a new ZDragSequenceEventHandler. |
Method Summary | |
protected void |
drag(ZMouseEvent e) This method is called during a drag sequence. |
protected void |
dragInScreenCoords(ZMouseEvent e, java.awt.geom.Dimension2D aScreenDelta) This method is called by drag during at a drag sequence. |
protected void |
endDrag(ZMouseEvent e) This method is called at the end of a drag sequence. |
protected void |
filteredMouseDragged(ZMouseEvent e) Maps filtered mouse dragged onto the drag method if a drag sequence is in progress. |
protected void |
filteredMousePressed(ZMouseEvent e) Maps filtered mouse pressed onto the startDrag method if a drag interaction should be started as determined by shouldStartDragInteraction . |
protected void |
filteredMouseReleased(ZMouseEvent e) Maps filtered mouse released onto the endDrag method if a drag sequence was in progress when the mouse was released. |
java.awt.geom.Dimension2D |
getCurrentScreenDelta() Returns the current distance that the mouse has moved between the current and previous filtered mouse events in screen coords. |
java.awt.geom.Point2D |
getCurrentScreenPoint() Returns the screen point of the current filtered mouse event. |
java.awt.geom.Point2D |
getDragStartScreenPoint() Return the point in screen coords where the drag sequence started. |
double |
getMinDragStartDistance() Return the distance in screen coords that the mouse needs to move before a drag sequence will be started. |
java.awt.geom.Point2D |
getMousePressedScreenPoint() Return the point in screen coords where the mouse was pressed. |
java.awt.geom.Point2D |
getPreviousScreenPoint() Returns the screen location of the previous filtered mouse event. |
boolean |
isDragging() Returns true if the event handler is currently dragging. |
protected void |
setIsDragging(boolean aBoolean) Set to true if the event handler is currently dragging. |
void |
setMinDragStartDistance(double aDouble) Set the distance (in screen coords) that the mouse needs to move before a drag sequence is started. |
protected boolean |
shouldStartDragInteraction(ZMouseEvent e) Invoked to determine if a drag interaction should be started. |
protected void |
startDrag(ZMouseEvent e) This method is called when a drag sequence is started. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ZDragSequenceEventHandler(ZSceneGraphObject aFilteredMouseEventSource)
aFilteredMouseEventSource
- the source for filtered ZMouseEvents and ZMouseMotionEvents. See the ZFilteredEventHandler class comment to customize this behavior.public ZDragSequenceEventHandler(ZSceneGraphObject aFilteredMouseEventSource, ZCanvas aFilteredKeyEventSouce)
aFilteredMouseEventSource
- the source for filtered ZMouseEvents and ZMouseMotionEvents. See the ZFilteredEventHandler class comment to customize this behavior.aFilteredKeyEventSouce
- the source for filtered KeyEvents. See the ZFilteredEventHandler class comment to customize this behavior.Method Detail |
protected void filteredMousePressed(ZMouseEvent e)
startDrag
method if a drag interaction should be started as determined by shouldStartDragInteraction
.
filteredMousePressed
in class ZFilteredEventHandler
e
- the filtered mouse pressed event.protected void filteredMouseDragged(ZMouseEvent e)
drag
method if a drag sequence is in progress. Or maps it onto the startDrag
method if a drag sequence is not in progress but should be started as determined by shouldStartDragInteraction
.
filteredMouseDragged
in class ZFilteredEventHandler
e
- the filtered mouse dragged event.protected void filteredMouseReleased(ZMouseEvent e)
endDrag
method if a drag sequence was in progress when the mouse was released. If a drag sequence was not in progress endDrag
will not be called.
filteredMouseReleased
in class ZFilteredEventHandler
e
- the filtered mouse released event.protected void startDrag(ZMouseEvent e)
super.startDrag
since this method sets up the drag sequence state. This method sets the current drawing surface to interacting mode.
e
- the event starting the drag sequence.protected void drag(ZMouseEvent e)
dragInScreenCoords
with this information. It also updates the current screen delta, and last screen point values.
e
- the event causing the drag.protected void dragInScreenCoords(ZMouseEvent e, java.awt.geom.Dimension2D aScreenDelta)
drag
during at a drag sequence. It can be more useful to override this method then drag
since the screen delta is provided for you. The screen delta parameter in this method is the same object as the one returned by getScreenDelta
. So if you modify this object (such as transform from one coord system to another) the object returned from getScreenDelta
will also be modified. But for most event handlers its still ok to modify it since the screen delta object is refreshed on each new event.
e
- the event causing the drag.aScreenDelta
- the change in mouse position between the current and last filtered mouse events.protected void endDrag(ZMouseEvent e)
e
- the event causing the end of the drag sequence.protected boolean shouldStartDragInteraction(ZMouseEvent e)
getMinDragStartDistance
from the getMousePressedScreenPoint
.
e
- the event containing the current filtered mouse position.public boolean isDragging()
protected void setIsDragging(boolean aBoolean)
aBoolean
- true if the event handler is dragging..public double getMinDragStartDistance()
public void setMinDragStartDistance(double aDouble)
public java.awt.geom.Point2D getMousePressedScreenPoint()
public java.awt.geom.Point2D getDragStartScreenPoint()
public java.awt.geom.Point2D getPreviousScreenPoint()
public java.awt.geom.Point2D getCurrentScreenPoint()
public java.awt.geom.Dimension2D getCurrentScreenDelta()
drag
so it is normally safe to modify it if you event handler only accesses it once per event.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |