org.metalev.multitouch.controller
Interface MultiTouchController.MultiTouchObjectCanvas<T>

All Known Implementing Classes:
MapView
Enclosing class:
MultiTouchController<T>

public static interface MultiTouchController.MultiTouchObjectCanvas<T>


Method Summary
 T getDraggableObjectAtPoint(MultiTouchController.PointInfo touchPoint)
          See if there is a draggable object at the current point.
 void getPositionAndScale(T obj, MultiTouchController.PositionAndScale objPosAndScaleOut)
          Get the screen coords of the dragged object's origin, and scale multiplier to convert screen coords to obj coords.
 void selectObject(T obj, MultiTouchController.PointInfo touchPoint)
          Select an object at the given point.
 boolean setPositionAndScale(T obj, MultiTouchController.PositionAndScale newObjPosAndScale, MultiTouchController.PointInfo touchPoint)
          Callback to update the position and scale (in object coords) of the currently-dragged object.
 

Method Detail

getDraggableObjectAtPoint

T getDraggableObjectAtPoint(MultiTouchController.PointInfo touchPoint)
See if there is a draggable object at the current point. Returns the object at the point, or null if nothing to drag. To start a multitouch drag/stretch operation, this routine must return some non-null reference to an object. This object is passed into the other methods in this interface when they are called.

Parameters:
touchPoint - The point being tested (in object coordinates). Return the topmost object under this point, or if dragging/stretching the whole canvas, just return a reference to the canvas.
Returns:
a reference to the object under the point being tested, or null to cancel the drag operation. If dragging/stretching the whole canvas (e.g. in a photo viewer), always return non-null, otherwise the stretch operation won't work.

getPositionAndScale

void getPositionAndScale(T obj,
                         MultiTouchController.PositionAndScale objPosAndScaleOut)
Get the screen coords of the dragged object's origin, and scale multiplier to convert screen coords to obj coords. The job of this routine is to call the .set() method on the passed PositionAndScale object to record the initial position and scale of the object (in object coordinates) before any dragging/stretching takes place.

Parameters:
obj - The object being dragged/stretched.
objPosAndScaleOut - Output parameter: You need to call objPosAndScaleOut.set() to record the current position and scale of obj.

setPositionAndScale

boolean setPositionAndScale(T obj,
                            MultiTouchController.PositionAndScale newObjPosAndScale,
                            MultiTouchController.PointInfo touchPoint)
Callback to update the position and scale (in object coords) of the currently-dragged object.

Parameters:
obj - The object being dragged/stretched.
newObjPosAndScale - The new position and scale of the object, in object coordinates. Use this to move/resize the object before returning.
touchPoint - Info about the current touch point, including multitouch information and utilities to calculate and cache multitouch pinch diameter etc. (Note: touchPoint is volatile, if you want to keep any fields of touchPoint, you must copy them before the method body exits.)
Returns:
true if setting the position and scale of the object was successful, or false if the position or scale parameters are out of range for this object.

selectObject

void selectObject(T obj,
                  MultiTouchController.PointInfo touchPoint)
Select an object at the given point. Can be used to bring the object to top etc. Only called when first touchpoint goes down, not when multitouch is initiated. Also called with null on touch-up.

Parameters:
obj - The object being selected by single-touch, or null on touch-up.
touchPoint - The current touch point.


Copyright © 2012. All Rights Reserved.