Package org.mt4j.input.inputData

Examples of org.mt4j.input.inputData.InputCursor


   * Pre.
   */
  public void pre(){
    if (lockedCursors.size() == 1){
      IMTComponent3D comp = lockedCursors.get(0).getTarget();
      InputCursor c = lockedCursors.get(0);
      long nowTime = System.currentTimeMillis();
      long elapsedTime = nowTime - this.tapStartTime;
      Vector3D screenPos = c.getPosition();
      float normalized = (float)elapsedTime / (float)this.holdTime;
     
      if (elapsedTime >= holdTime){
        normalized = 1;
        logger.debug("TIME PASSED!");
View Full Code Here


      long nowTime = System.currentTimeMillis();
      long elapsedTime = nowTime - this.tapStartTime;
      float normalized = (float)elapsedTime / (float)this.holdTime;
     
      if (unUsedCursors.size() > 0){       //check if there are other cursors on the component, we could use
        InputCursor otherCursor = unUsedCursors.get(0);
        if (this.canLock(otherCursor)
            &&
          Vector3D.distance2D(buttonDownScreenPos, otherCursor.getPosition()) <= this.maxFingerUpDist)
        {   //Check if we have the priority to use this other cursor and if cursor is in range
          this.getLock(otherCursor);
          unUsedCursors.remove(otherCursor);
          lockedCursors.add(otherCursor);
          buttonDownScreenPos = otherCursor.getPosition();
        }else{
          //Other cursor has higher prior -> end this gesture
          this.fireGestureEvent(new TapAndHoldEvent(this, MTGestureEvent.GESTURE_ENDED, c.getTarget(), c, false,  c.getPosition(), this.holdTime, elapsedTime, normalized));
          try {
            applet.unregisterPre(this);
View Full Code Here

  @Override
  public void preProcess(MTInputEvent inputEvent) {
    super.preProcess(inputEvent);
   
    MTFingerInputEvt posEvt = (MTFingerInputEvt)inputEvent;
    InputCursor c = posEvt.getCursor();
    switch (posEvt.getId()) {
    case MTFingerInputEvt.INPUT_DETECTED:
      activeCursors.add(c);
      activeCursorsWithEndedOnes.add(c);
      c.registerForLocking(this);
      break;
    case MTFingerInputEvt.INPUT_UPDATED:
      break;
    case MTFingerInputEvt.INPUT_ENDED:
      activeCursors.remove(c);
      c.unregisterForLocking(this);
      break;
    default:
      break;
    }
  }
View Full Code Here

  @Override
  protected void processInputEvtImpl(MTInputEvent inputEvent) {
//    AbstractCursorInputEvt posEvt = (AbstractCursorInputEvt)inputEvent;
    MTFingerInputEvt posEvt = (MTFingerInputEvt)inputEvent;
    InputCursor c = posEvt.getCursor();
    switch (posEvt.getId()) {
    case MTFingerInputEvt.INPUT_DETECTED:
//      activeCursors.add(c);
//      c.registerGeneralInterest(this);
      cursorStarted(c, posEvt);
View Full Code Here

   * @param excludedFromSearch the excluded from search
   * @return the farthest free cursor to
   */
  public InputCursor getFarthestFreeCursorTo(InputCursor cursor, InputCursor... excludedFromSearch){
    float currDist = Float.MIN_VALUE;
    InputCursor fartherstCursor = null;
   
    Vector3D cursorPos = cursor.getPosition();
    for (InputCursor currentCursor : this.getCurrentComponentCursors()) {
      if (currentCursor.equals(cursor) || !currentCursor.canLock(this) || currentCursor.isLockedBy(this))
        continue;
View Full Code Here

   * @return true, if successful
   */
  protected boolean canLock(InputCursor... cursors){
    int locked = 0;
    for (int i = 0; i < cursors.length; i++) {
      InputCursor m = cursors[i];
      if (m.canLock(this)){
        locked++;
      }
    }
    return locked == cursors.length;
  }
View Full Code Here

   * @return true, if all specified cursors could get locked
   */
  protected boolean getLock(InputCursor... cursors){
    int locked = 0;
    for (int i = 0; i < cursors.length; i++) {
      InputCursor m = cursors[i];
      if (m.getLock(this)){
        locked++;
      }
    }
    return locked == cursors.length;
  }
View Full Code Here

   *
   * @param cursors the cursors
   */
  protected void unLock(InputCursor... cursors){
    for (int i = 0; i < cursors.length; i++) {
      InputCursor inputCursor = cursors[i];
      inputCursor.unlock(this);
    }
  }
View Full Code Here

   
    this.getCanvas().addInputListener(new IMTInputEventListener() {
      public boolean processInputEvent(MTInputEvent inEvt){
        if(inEvt instanceof AbstractCursorInputEvt){
          final AbstractCursorInputEvt posEvt = (AbstractCursorInputEvt)inEvt;
          final InputCursor m = posEvt.getCursor();
//          System.out.println("PrevPos: " + prevPos);
//          System.out.println("Pos: " + pos);

          if (posEvt.getId() != AbstractCursorInputEvt.INPUT_ENDED){
            registerPreDrawAction(new IPreDrawAction() {
View Full Code Here

   
    if (lockedCursors.contains(m)){ //cursor was a actual drag cursor
      lockedCursors.remove(m);
     
      if (unUsedCursors.size() > 0){ //check if there are other cursors on the component, we could use for drag
        InputCursor otherCursor = unUsedCursors.get(0); //TODO cycle through all available unUsedCursors and try to claim one, maybe the first one is claimed 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);
          ac = new MyArcBall(otherCursor);
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.