Package org.mt4j.input.inputData

Examples of org.mt4j.input.inputData.InputCursor


      unUsedMotions.add(m);
      logger.debug(this.getName() + " has already enough motions for this gesture - adding to unused ID:" + m.getId());
    }else{ //no scale in progress yet
      if (unUsedMotions.size() == 1){
        logger.debug(this.getName() + " has already has 1 unused motion - we can try start gesture! used with ID:" + unUsedMotions.get(0).getId() + " and new motion ID:" + m.getId());
        InputCursor otherMotion = unUsedMotions.get(0);
       
        //See if we can obtain a lock on both motions
        if (this.canLock(otherMotion, m)){
          float newDistance = Vector3D.distance(
              new Vector3D(otherMotion.getCurrentEvent().getPosX(), otherMotion.getCurrentEvent().getPosY(),0),
              new Vector3D(m.getCurrentEvent().getPosX(), m.getCurrentEvent().getPosY(),0));
          if (newDistance < zoomDetectRadius) {
            this.oldDistance = newDistance;
            this.getLock(otherMotion, m);
            lockedMotions.add(otherMotion);
View Full Code Here


  @Override
  public void cursorUpdated(InputCursor m, MTFingerInputEvt positionEvent) {
    IMTComponent3D comp = positionEvent.getTargetComponent();
    if (lockedMotions.size() == 2 && lockedMotions.contains(m)){
      InputCursor firstMotion = lockedMotions.get(0);
      InputCursor secondMotion = lockedMotions.get(1);
      float fingerDistance = Vector3D.distance(
          new Vector3D(firstMotion.getCurrentEvent().getPosX(), firstMotion.getCurrentEvent().getPosY(), 0),
          new Vector3D(secondMotion.getCurrentEvent().getPosX(), secondMotion.getCurrentEvent().getPosY(), 0));
      float camZoomAmount = fingerDistance - oldDistance;
      oldDistance = fingerDistance;
      if (m.equals(firstMotion)){
        this.fireGestureEvent(new ZoomEvent(this, MTGestureEvent.GESTURE_UPDATED, comp, firstMotion, secondMotion, camZoomAmount, comp.getViewingCamera()));
      }else{
View Full Code Here

  public void cursorEnded(InputCursor m,  MTFingerInputEvt positionEvent) {
    IMTComponent3D comp = positionEvent.getTargetComponent();
    logger.debug(this.getName() + " INPUT_ENDED RECIEVED - MOTION: " + m.getId());
   
    if (lockedMotions.size() == 2 && lockedMotions.contains(m)){
      InputCursor leftOverMotion = (lockedMotions.get(0).equals(m))? lockedMotions.get(1) : lockedMotions.get(0);
     
      lockedMotions.remove(m);
      if (unUsedMotions.size() > 0){ //Check if there are other motions we could use for scaling if one was removed
        InputCursor futureMotion = unUsedMotions.get(0);
        if (this.canLock(futureMotion)){ //check if we have priority to lock another motion and use it
          float newDistance = Vector3D.distance(
              new Vector3D(leftOverMotion.getCurrentEvent().getPosX(), leftOverMotion.getCurrentEvent().getPosY(),0),
              new Vector3D(futureMotion.getCurrentEvent().getPosX(), futureMotion.getCurrentEvent().getPosY(),0));
          if (newDistance < zoomDetectRadius) {//Check if other motion is in distance
            this.oldDistance = newDistance;
            this.getLock(futureMotion);
            unUsedMotions.remove(futureMotion);
            lockedMotions.add(futureMotion);
            logger.debug(this.getName() + " we could lock another motion! (ID:" + futureMotion.getId() +")");
            logger.debug(this.getName() + " continue with different motions (ID: " + futureMotion.getId() + ")" + " " + "(ID: " + leftOverMotion.getId() + ")");
            //TODO fire start evt?
          }else{
            this.endGesture(m, leftOverMotion, comp);
          }
        }else{ //we dont have permission to use other motion  - End scale
View Full Code Here

      return;
    }
   
    if (unUsedMotions.contains(m)){ //should always be true here!?
      if (unUsedMotions.size() >= 2){ //we can try to resume the gesture
        InputCursor firstMotion = unUsedMotions.get(0);
        InputCursor secondMotion = unUsedMotions.get(1);

        //See if we can obtain a lock on both motions
        if (this.canLock(firstMotion, secondMotion)){
          float newDistance = Vector3D.distance(
              new Vector3D(firstMotion.getCurrentEvent().getPosX(), firstMotion.getCurrentEvent().getPosY(),0),
              new Vector3D(secondMotion.getCurrentEvent().getPosX(), secondMotion.getCurrentEvent().getPosY(),0));
          if (newDistance < zoomDetectRadius) {//Check if other motion is in distance
            this.oldDistance = newDistance;
            this.getLock(firstMotion, secondMotion);

            unUsedMotions.remove(firstMotion);
            unUsedMotions.remove(secondMotion);
            lockedMotions.add(firstMotion);
            lockedMotions.add(secondMotion);
            logger.debug(this.getName() + " we could lock motions: " + firstMotion.getId() +", " + secondMotion.getId());
            logger.debug(this.getName() + " continue with different motions (ID: " + firstMotion.getId() + ")" + " " + "(ID: " + secondMotion.getId() + ")");
            //TODO fire started evt?
          }else{
            logger.debug(this.getName() + " distance was too great between motions: " + firstMotion.getId() +", " + secondMotion.getId() + " distance: " + newDistance);
          }
        }else{
          logger.debug(this.getName() + " we could NOT lock motions: " + firstMotion.getId() +", " + secondMotion.getId());
        }
      }
    }else{
      logger.error(this.getName() + "hmmm - investigate why is motion not in unusedList?");
    }
View Full Code Here

   * @see muito.motion.MotionProviderListener#newMotionProvided(muito.motion.Motion)
   */
  public void newMotionProvided(Motion motion) {
    MotionEvent me = motion.getLastEvent();
   
    InputCursor m = new InputCursor();
    MTFingerInputEvt touchEvt = new MTFingerInputEvt(this, me.getXAbs(), me.getYAbs(), MTFingerInputEvt.INPUT_DETECTED, m);
//    m.addEvent(touchEvt);
   
    long motionID = motion.getId();
    ActiveCursorPool.getInstance().putActiveCursor(motionID, m);
View Full Code Here

  /* (non-Javadoc)
   * @see muito.motion.MotionProviderListener#providedMotionUpdated(muito.motion.Motion, muito.motion.MotionEvent)
   */
  public void providedMotionUpdated(Motion m, MotionEvent me) {
    InputCursor mo = ActiveCursorPool.getInstance().getActiveCursorByID(muitoIDToInputMotionID.get(m.getId()));
   
    MTFingerInputEvt te = new MTFingerInputEvt(this, me.getXAbs(), me.getYAbs(), MTFingerInputEvt.INPUT_UPDATED, mo);
//    m.addEvent(new MTFingerInputEvt2(this, e.getX(), e.getY(), MTFingerInputEvt.FINGER_UPDATE, m));
   
    //FIRE
View Full Code Here

  /* (non-Javadoc)
   * @see muito.motion.MotionProviderListener#providedMotionCompleted(muito.motion.Motion)
   */
  public void providedMotionCompleted(Motion m) {
    long motionID = muitoIDToInputMotionID.get(m.getId());
    InputCursor mo = ActiveCursorPool.getInstance().getActiveCursorByID(motionID);

    MTFingerInputEvt te;
    if (mo.getCurrentEvent() != null)
      te = new MTFingerInputEvt(this, mo.getCurrentEvent().getPosX(), mo.getCurrentEvent().getPosY(), MTFingerInputEvt.INPUT_ENDED, mo);
    else
      te = new MTFingerInputEvt(this, 0,0, MTFingerInputEvt.INPUT_ENDED, mo);
   
//    m.addEvent(te);
   
View Full Code Here

    logger.debug(this.getName() + " INPUT_ENDED RECIEVED - CURSOR: " + m.getId());

    if (lockedCursors.contains(m)){ //cursor was a actual gesture cursor
      lockedCursors.remove(m);
      if (unUsedCursors.size() > 0){ //check if there are other cursors on the component, we could use
        InputCursor otherCursor = unUsedCursors.get(0); //TODO cycle through all available unUsedCursors and try to lock one, maybe the first one is lock but another isnt!
        if (this.canLock(otherCursor)){ //Check if we have the priority to use this cursor
          this.getLock(otherCursor);
          unUsedCursors.remove(otherCursor);
          lockedCursors.add(otherCursor);
          //TODO fire started? maybe not.. do we have to?
View Full Code Here

    logger.debug(this.getName() + " INPUT_STARTED, Cursor: " + newCursor.getId());
   
    List<InputCursor> alreadyLockedCursors = getLockedCursors();
    if (alreadyLockedCursors.size() >= 2){ //this gesture with 2 fingers already in progress
      //TODO get the 2 cursors which are most far away from each other
      InputCursor firstCursor = alreadyLockedCursors.get(0);
      InputCursor secondCursor = alreadyLockedCursors.get(1);
      if (isCursorDistanceGreater(firstCursor, secondCursor, newCursor) && canLock(firstCursor, newCursor)){
        ScaleContext newContext = new ScaleContext(firstCursor, newCursor, comp);
        if (!newContext.isGestureAborted()){ //Check if we could start gesture (ie. if fingers on component)
          sc = newContext;
          //Lock new Second cursor
          this.getLock(firstCursor, newCursor);
          this.unLock(secondCursor);
          logger.debug(this.getName() + " we could lock cursors: " + firstCursor.getId() +", and more far away cursor " + newCursor.getId());
        }else{
          logger.debug(this.getName() + " we could NOT exchange new second cursor - cursor not on component: " + firstCursor.getId() +", " + secondCursor.getId());
        }
      }else{
        logger.debug(this.getName() + " has already enough cursors for this gesture and the new cursors distance to the first one ist greater (or we dont have the priority to lock it) - adding to unused ID:" + newCursor.getId());
      }
    }else{ //no gesture in progress yet
      List<InputCursor> availableCursors = getFreeComponentCursors();
      logger.debug(this.getName() + " Available cursors: " + availableCursors.size());
      if (availableCursors.size() >= 2){
        InputCursor otherCursor = getFarthestFreeComponentCursorTo(newCursor);
//        logger.debug(this.getName() + " already had 1 unused cursor - we can try start gesture! used Cursor ID:" + otherCursor.getId() + " and new cursor ID:" + newCursor.getId());
       
        if (this.canLock(otherCursor, newCursor)){ //TODO remove check, since alreday checked in getAvailableComponentCursors()?
          sc = new ScaleContext(otherCursor, newCursor, comp);
          if (!sc.isGestureAborted()){
View Full Code Here

  public void cursorEnded(InputCursor c, MTFingerInputEvt fEvt) {
    IMTComponent3D comp = fEvt.getTargetComponent();
   
    logger.debug(this.getName() + " INPUT_ENDED -> Active cursors: " + getCurrentComponentCursors().size() + " Available cursors: " + getFreeComponentCursors().size() " Locked cursors: " + getLockedCursors().size());
    if (getLockedCursors().contains(c)){
      InputCursor firstCursor = sc.getFirstFingerCursor();
      InputCursor secondCursor = sc.getSecondFingerCursor();
      if (firstCursor.equals(c) || secondCursor.equals(c)){ //The leaving cursor was used by the processor
        InputCursor leftOverCursor = firstCursor.equals(c) ? secondCursor : firstCursor;
        //TODO check if cursor is on component, else take next farthest cursor
        InputCursor futureCursor = getFarthestFreeCursorTo(leftOverCursor, getCurrentComponentCursorsArray());

        if (futureCursor != null){ //already checked in getFartherstAvailableCursor() if we can lock it
          ScaleContext newContext = new ScaleContext(futureCursor, leftOverCursor, comp);
          if (!newContext.isGestureAborted()){
            sc = newContext;
            this.getLock(leftOverCursor, futureCursor);
            logger.debug(this.getName() + " continue with different cursors (ID: " + futureCursor.getId() + ")" + " " + "(ID: " + leftOverCursor.getId() + ")");
          }else{ //couldnt start gesture - cursor's not on component
            this.endGesture(leftOverCursor, comp, firstCursor, secondCursor);
          }
        }else{ //we cant use another cursor  - End gesture
          this.endGesture(leftOverCursor, comp, firstCursor, secondCursor);
View Full Code Here

TOP

Related Classes of org.mt4j.input.inputData.InputCursor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.