private void multiTouchController(){
  if (DEBUG)   Log.i("MultiTouch","Got here 6 - " + mMode + " "+ mCurrPt.getNumTouchPoints()+ " "+ mCurrPt.isDown()+ mCurrPt.isMultiTouch());
switch (mMode) {
case MODE_NOTHING:
    if (DEBUG)     Log.i("MultiTouch","MODE_NOTHING");
  if (mCurrPt.isDown()) {
    selectedObject=objectCanvas.getDraggableObjectAtPoint(mCurrPt);
    if (selectedObject != null) {
      if (objectCanvas.pointInObjectGrabArea(mCurrPt,selectedObject)) {
        mMode=MODE_ST_GRAB;
        objectCanvas.selectObject(selectedObject,mCurrPt);
        anchorAtThisPositionAndScale();
        mSettleStartTime=mSettleEndTime=mCurrPt.getEventTime();
      }
 else {
        mMode=MODE_DRAG;
        objectCanvas.selectObject(selectedObject,mCurrPt);
        anchorAtThisPositionAndScale();
        mSettleStartTime=mSettleEndTime=mCurrPt.getEventTime();
      }
    }
  }
break;
case MODE_ST_GRAB:
if (DEBUG) Log.i("MultiTouch","MODE_ST_GRAB");
if (!mCurrPt.isDown()) {
mMode=MODE_NOTHING;
objectCanvas.selectObject((selectedObject=null),mCurrPt);
mDragOccurred=false;
}
 else {
performDragOrPinch();
}
break;
case MODE_DRAG:
if (DEBUG) Log.i("MultiTouch","MODE_DRAG");
if (!mCurrPt.isDown()) {
mMode=MODE_NOTHING;
objectCanvas.selectObject((selectedObject=null),mCurrPt);
mDragOccurred=false;
}
 else if (mCurrPt.isMultiTouch()) {
mMode=MODE_PINCH;
anchorAtThisPositionAndScale();
mSettleStartTime=mCurrPt.getEventTime();
mSettleEndTime=mSettleStartTime + EVENT_SETTLE_TIME_INTERVAL;
}
 else {
if (mCurrPt.getEventTime() < mSettleEndTime) {
anchorAtThisPositionAndScale();
}
 else {
performDragOrPinch();
}
}
break;
case MODE_PINCH:
if (DEBUG) Log.i("MultiTouch","MODE_PINCH");
if (!mCurrPt.isMultiTouch() || !mCurrPt.isDown()) {
if (!mCurrPt.isDown()) {
mMode=MODE_NOTHING;
objectCanvas.selectObject((selectedObject=null),mCurrPt);
}
 else {
mMode=MODE_DRAG;
anchorAtThisPositionAndScale();
mSettleStartTime=mCurrPt.getEventTime();
mSettleEndTime=mSettleStartTime + EVENT_SETTLE_TIME_INTERVAL;
}
}
 else {
if (Math.abs(mCurrPt.getX() - mPrevPt.getX()) > MAX_MULTITOUCH_POS_JUMP_SIZE || Math.abs(mCurrPt.getY() - mPrevPt.getY()) > MAX_MULTITOUCH_POS_JUMP_SIZE || Math.abs(mCurrPt.getMultiTouchWidth() - mPrevPt.getMultiTouchWidth()) * .5f > MAX_MULTITOUCH_DIM_JUMP_SIZE || Math.abs(mCurrPt.getMultiTouchHeight() - mPrevPt.getMultiTouchHeight()) * .5f > MAX_MULTITOUCH_DIM_JUMP_SIZE) {
anchorAtThisPositionAndScale();
mSettleStartTime=mCurrPt.getEventTime();
mSettleEndTime=mSettleStartTime + EVENT_SETTLE_TIME_INTERVAL;
}
 else if (mCurrPt.eventTime < mSettleEndTime) {
anchorAtThisPositionAndScale();
}
 else {
performDragOrPinch();
}
}
break;
}
if (DEBUG) Log.i("MultiTouch","Got here 7 - " + mMode + " "+ mCurrPt.getNumTouchPoints()+ " "+ mCurrPt.isDown()+ mCurrPt.isMultiTouch());
}

private void multiTouchController ( ) { if ( DEBUG ) Log . i ( "MultiTouch" , "Got here 6 - " + mMode + " " + mCurrPt . getNumTouchPoints ( ) + " " + mCurrPt . isDown ( ) + mCurrPt . isMultiTouch ( ) ) ; switch ( mMode ) { case MODE_NOTHING : if ( DEBUG ) Log . i ( "MultiTouch" , "MODE_NOTHING" ) ; if ( mCurrPt . isDown ( ) ) { selectedObject = objectCanvas . getDraggableObjectAtPoint ( mCurrPt ) ; if ( selectedObject != null ) { if ( objectCanvas . pointInObjectGrabArea ( mCurrPt , selectedObject ) ) { mMode = MODE_ST_GRAB ; objectCanvas . selectObject ( selectedObject , mCurrPt ) ; anchorAtThisPositionAndScale ( ) ; mSettleStartTime = mSettleEndTime = mCurrPt . getEventTime ( ) ; } else { mMode = MODE_DRAG ; objectCanvas . selectObject ( selectedObject , mCurrPt ) ; anchorAtThisPositionAndScale ( ) ; mSettleStartTime = mSettleEndTime = mCurrPt . getEventTime ( ) ; } } } break ; case MODE_ST_GRAB : if ( DEBUG ) Log . i ( "MultiTouch" , "MODE_ST_GRAB" ) ; if ( ! mCurrPt . isDown ( ) ) { mMode = MODE_NOTHING ; objectCanvas . selectObject ( ( selectedObject = null ) , mCurrPt ) ; mDragOccurred = false ; } else { performDragOrPinch ( ) ; } break ; case MODE_DRAG : if ( DEBUG ) Log . i ( "MultiTouch" , "MODE_DRAG" ) ; if ( ! mCurrPt . isDown ( ) ) { mMode = MODE_NOTHING ; objectCanvas . selectObject ( ( selectedObject = null ) , mCurrPt ) ; mDragOccurred = false ; } else if ( mCurrPt . isMultiTouch ( ) ) { mMode = MODE_PINCH ; anchorAtThisPositionAndScale ( ) ; mSettleStartTime = mCurrPt . getEventTime ( ) ; mSettleEndTime = mSettleStartTime + EVENT_SETTLE_TIME_INTERVAL ; } else { if ( mCurrPt . getEventTime ( ) < mSettleEndTime ) { anchorAtThisPositionAndScale ( ) ; } else { performDragOrPinch ( ) ; } } break ; case MODE_PINCH : if ( DEBUG ) Log . i ( "MultiTouch" , "MODE_PINCH" ) ; if ( ! mCurrPt . isMultiTouch ( ) || ! mCurrPt . isDown ( ) ) { if ( ! mCurrPt . isDown ( ) ) { mMode = MODE_NOTHING ; objectCanvas . selectObject ( ( selectedObject = null ) , mCurrPt ) ; } else { mMode = MODE_DRAG ; anchorAtThisPositionAndScale ( ) ; mSettleStartTime = mCurrPt . getEventTime ( ) ; mSettleEndTime = mSettleStartTime + EVENT_SETTLE_TIME_INTERVAL ; } } else { if ( Math . abs ( mCurrPt . getX ( ) - mPrevPt . getX ( ) ) > MAX_MULTITOUCH_POS_JUMP_SIZE || Math . abs ( mCurrPt . getY ( ) - mPrevPt . getY ( ) ) > MAX_MULTITOUCH_POS_JUMP_SIZE || Math . abs ( mCurrPt . getMultiTouchWidth ( ) - mPrevPt . getMultiTouchWidth ( ) ) * .5f > MAX_MULTITOUCH_DIM_JUMP_SIZE || Math . abs ( mCurrPt . getMultiTouchHeight ( ) - mPrevPt . getMultiTouchHeight ( ) ) * .5f > MAX_MULTITOUCH_DIM_JUMP_SIZE ) { anchorAtThisPositionAndScale ( ) ; mSettleStartTime = mCurrPt . getEventTime ( ) ; mSettleEndTime = mSettleStartTime + EVENT_SETTLE_TIME_INTERVAL ; } else if ( mCurrPt . eventTime < mSettleEndTime ) { anchorAtThisPositionAndScale ( ) ; } else { performDragOrPinch ( ) ; } } break ; } if ( DEBUG ) Log . i ( "MultiTouch" , "Got here 7 - " + mMode + " " + mCurrPt . getNumTouchPoints ( ) + " " + mCurrPt . isDown ( ) + mCurrPt . isMultiTouch ( ) ) ; }
state - based controller for tracking switches between no - touch , single - touch and multi - touch situations . includes logic for cleaning up the event stream , as events around touch up / down are noisy at least on early synaptics sensors .
