Examples of InputCursor


Examples of org.mt4j.input.inputData.InputCursor

      long sessionID = cursor.getSessionID();
//      logger.info("TUIO INPUT REMOVE FINGER - TUIO ID: " + sessionID);
      Long lCursorID = tuioIDToCursorID.get(sessionID);
      if (lCursorID != null){
        long cursorID = (long)lCursorID;
        InputCursor c = ActiveCursorPool.getInstance().getActiveCursorByID(cursorID);
        if (c != null){
          MTFingerInputEvt te = new MTFingerInputEvt(this, absoluteX, abosulteY, MTFingerInputEvt.INPUT_ENDED, c);
          tuioIDToCursorID.remove(sessionID);
          ActiveCursorPool.getInstance().removeCursor(cursorID);
          this.enqueueInputEvent(te);
View Full Code Here

Examples of org.mt4j.input.inputData.InputCursor

    float m_accel = tuioObject.getMotionAccel();
    float absoluteX =  tuioObject.getX() * windowWidth;
    float abosulteY =  tuioObject.getY() * windowHeight;
//    logger.info("Added TuioObj tuio object-> sessionID: " + session_id + " fiducialID: " + fiducial_id + " xpos:" + tuioObject.getX() + " ypos:" + tuioObject.getY() + " angle:" + angle + " x_speed:" + x_speed + " y_speed:" + y_speed + " r_speed:" + r_speed + " m_accel:" + m_accel + " r_accel:" + r_accel);
   
    InputCursor c = new InputCursor();
    MTFiducialInputEvt fiducialEvt = new MTFiducialInputEvt(this, absoluteX, abosulteY, MTFiducialInputEvt.INPUT_DETECTED, c, fiducial_id, angle, x_speed, y_speed, r_speed, m_accel, r_accel);
    long cursorID = c.getId(); //TODO do implicitly somehow
    ActiveCursorPool.getInstance().putActiveCursor(cursorID, c);
    tuioFiducialIDMap.put(session_id, cursorID);
    this.enqueueInputEvent(fiducialEvt);
  }
View Full Code Here

Examples of org.mt4j.input.inputData.InputCursor

    float absoluteX =  tuioObject.getX() * windowWidth;
    float abosulteY =  tuioObject.getY() * windowHeight;
   
    Long tuioID = (Long)tuioFiducialIDMap.get(session_id) ;
    if (tuioID != null ){
      InputCursor c = ActiveCursorPool.getInstance().getActiveCursorByID(tuioID);
      if (c != null){
        MTFiducialInputEvt fiducialEvt = new MTFiducialInputEvt(this, absoluteX, abosulteY, MTFiducialInputEvt.INPUT_UPDATED, c, fiducial_id, angle, x_speed, y_speed, r_speed, m_accel, r_accel);
        this.enqueueInputEvent(fiducialEvt);
      }
    }
View Full Code Here

Examples of org.mt4j.input.inputData.InputCursor

    int fiducial_id = tuioObject.getSymbolID();

    Long cursorIDL = tuioFiducialIDMap.get(session_id);
    if (cursorIDL != null){
      long cursorID = (long)cursorIDL;
      InputCursor c = ActiveCursorPool.getInstance().getActiveCursorByID(cursorID);
      if (c != null){
        MTFiducialInputEvt te;
        if (c.getCurrentEvent() != null)
          te = new MTFiducialInputEvt(this, c.getCurrentEvent().getPosX(), c.getCurrentEvent().getPosY(), MTFiducialInputEvt.INPUT_ENDED, c, fiducial_id);
        else
          te = new MTFiducialInputEvt(this, 0,0, MTFiducialInputEvt.INPUT_ENDED, c, fiducial_id);

        tuioFiducialIDMap.remove(session_id);
        ActiveCursorPool.getInstance().removeCursor(cursorID);
View Full Code Here

Examples of org.mt4j.input.inputData.InputCursor

   *
   * @param e the e
   */
  private void fingerDown(KeyEvent e){
    if (!spaceHasBeenPressed){
      InputCursor m = new InputCursor();
      MTFingerInputEvt touchEvt = new MTFingerInputEvt(this, locationX, locationY, MTFingerInputEvt.INPUT_DETECTED, m);
//      m.addEvent(touchEvt);
     
      lastUsedKeybID = m.getId();
      ActiveCursorPool.getInstance().putActiveCursor(lastUsedKeybID, m);
     
      //FIRE
      this.enqueueInputEvent(touchEvt);
     
    spaceHasBeenPressed = true;
    }else{
      InputCursor m = ActiveCursorPool.getInstance().getActiveCursorByID(lastUsedKeybID);
     
//      if (m.getLastEvent().getPositionX() != locationX || m.getLastEvent().getPositionY() != locationY){
      MTFingerInputEvt te = new MTFingerInputEvt(this, locationX, locationY, MTFingerInputEvt.INPUT_UPDATED, m);
//      m.addEvent(new MTFingerInputEvt2(this, e.getX(), e.getY(), MTFingerInputEvt.FINGER_UPDATE, m));
     
View Full Code Here

Examples of org.mt4j.input.inputData.InputCursor

  /**
   *
   * @param e the e
   */
  private void fingerUp(KeyEvent e) {
    InputCursor m = ActiveCursorPool.getInstance().getActiveCursorByID(lastUsedKeybID);
    MTFingerInputEvt te = new MTFingerInputEvt(this, locationX, locationY, MTFingerInputEvt.INPUT_ENDED, m);
//    m.addEvent(te);
   
    this.enqueueInputEvent(te);
   
View Full Code Here

Examples of org.mt4j.input.inputData.InputCursor

     
      AbstractCursorInputEvt newEvt = null;
      switch (posEvt.getId())
      {
      case AbstractCursorInputEvt.INPUT_DETECTED:{
        InputCursor newCursor = new InputCursor();
        try {
          newEvt = (AbstractCursorInputEvt) posEvt.clone();
          newEvt.setPositionX(newX);
          newEvt.setPositionY(newY);
//          newCursor.addEvent(newEvt);
          newEvt.setCursor(newCursor);
          newEvt.preFire();
          //Note: We dont set a target for the event! this can be
          //handled newly in the wondowed scenes InputRetargeter processor
        } catch (CloneNotSupportedException e) {
          e.printStackTrace();
        }
        this.oldCursorToNewCursor.put(posEvt.getCursor(), newCursor);
        //TODO checken ob cursor bereits events enth�lt - �berhaupt m�glich?..
        //ELSE -> CLONE AND ADD ALL OLD EVENTS TO THE NEW CURSOR!
      }break;
      case AbstractCursorInputEvt.INPUT_UPDATED:{
        InputCursor newCursor = this.oldCursorToNewCursor.get(posEvt.getCursor());
        if (newCursor != null){
          try {
            newEvt = (AbstractCursorInputEvt) posEvt.clone();
            newEvt.setPositionX(newX);
            newEvt.setPositionY(newY);
//            newCursor.addEvent(newEvt);
            newEvt.setCursor(newCursor);
            newEvt.preFire();
          } catch (CloneNotSupportedException e) {
            e.printStackTrace();
          }
        }else{
          System.err.println("Couldnt find new cursor!");
        }
      }break;
      case AbstractCursorInputEvt.INPUT_ENDED:{
        InputCursor newCursor = this.oldCursorToNewCursor.remove(posEvt.getCursor());
        if (newCursor != null){
          try {
            newEvt = (AbstractCursorInputEvt) posEvt.clone();
            newEvt.setPositionX(newX);
            newEvt.setPositionY(newY);
View Full Code Here

Examples of org.mt4j.input.inputData.InputCursor

    logger.debug(this.getName() + " INPUT_STARTED, Cursor: " + newCursor.getId());
   
    List<InputCursor> alreadyLockedCursors = getLockedCursors();
    if (alreadyLockedCursors.size() >= 2){ //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)){
        RotationContext newContext = new RotationContext(firstCursor, newCursor, comp);
        if (!newContext.isGestureAborted()){ //Check if we could start gesture (ie. if fingers on component)
          rc = 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()?
          rc = new RotationContext(otherCursor, newCursor, comp);
          if (!rc.isGestureAborted()){
View Full Code Here

Examples of org.mt4j.input.inputData.InputCursor

    logger.debug(this.getName() + " INPUT_ENDED RECIEVED - CURSOR: " + c.getId());
   
    logger.debug("Rotate ended -> Active cursors: " + getCurrentComponentCursors().size() + " Available cursors: " + getFreeComponentCursors().size() " Locked cursors: " + getLockedCursors().size());
   
    if (getLockedCursors().contains(c)){
      InputCursor firstCursor = rc.getFirstCursor();
      InputCursor secondCursor = rc.getSecondCursor();
      if (firstCursor.equals(c) || secondCursor.equals(c)){ //The leaving cursor was used by the processor
        InputCursor leftOverCursor = firstCursor.equals(c) ? secondCursor : firstCursor;
        InputCursor futureCursor = getFarthestFreeCursorTo(leftOverCursor, getCurrentComponentCursorsArray());

        if (futureCursor != null){ //already checked in getFartherstAvailableCursor() if we can lock it
          RotationContext newContext = new RotationContext(futureCursor, leftOverCursor, comp);
          if (!newContext.isGestureAborted()){
            rc = 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

Examples of org.mt4j.input.inputData.InputCursor

    //-> actually we always lock 2 cursors at once so should never be only 1 locked, but just for safety..
    this.unLockAllCursors();

    List<InputCursor> availableCursors = getFreeComponentCursors();
    if (availableCursors.size() >= 2){ //we can try to resume the gesture
      InputCursor firstCursor = availableCursors.get(0);
      InputCursor secondCursor = getFarthestFreeComponentCursorTo(firstCursor);

      //See if we can obtain a lock on both cursors
      IMTComponent3D comp = firstCursor.getFirstEvent().getTargetComponent();
      RotationContext newContext = new RotationContext(firstCursor, secondCursor, comp);
      if (!newContext.isGestureAborted()){ //Check if we could start gesture (ie. if fingers on component)
        rc = newContext;
        this.getLock(firstCursor, secondCursor);
        logger.debug(this.getName() + " we could lock cursors: " + firstCursor.getId() +", " + secondCursor.getId());
      }else{
        rc = null;
        logger.debug(this.getName() + " we could NOT resume gesture - cursors not on component: " + firstCursor.getId() +", " + secondCursor.getId());
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.