Package com.google.gwt.dom.client

Examples of com.google.gwt.dom.client.Touch


      event.preventDefault();
      if (MGWT.getFormFactor().isDesktop()) {
        DOM.setCapture(getElement());
      }

      Touch touch = event.getTouches().get(0);
      x_start = touch.getClientX();
      moved = false;
      if (value) {
        x_min = appearance.css().CONTAINER_MIN_ON();
        x_max = appearance.css().CONTAINER_MAX_ON();
        offset = appearance.css().CONTAINER_OFFSET_ON();
View Full Code Here


    if (e.getType().equals("touchstart")) {
      this.justTouched = true;
      JsArray<Touch> touches = e.getChangedTouches();
      for (int i = 0, j = touches.length(); i < j; i++) {
        Touch touch = touches.get(i);
        int touchId = touch.getIdentifier();
        touched[touchId] = true;
        touchX[touchId] = touch.getRelativeX(canvas);
        touchY[touchId] = touch.getRelativeY(canvas);
        deltaX[touchId] = 0;
        deltaY[touchId] = 0;
        if (processor != null) {
          processor.touchDown(touchX[touchId], touchY[touchId], touchId, Buttons.LEFT);
        }       
      }
      this.currentEventTimeStamp = TimeUtils.nanoTime();
      e.preventDefault();
    }
    if (e.getType().equals("touchmove")) {
      JsArray<Touch> touches = e.getChangedTouches();
      for (int i = 0, j = touches.length(); i < j; i++) {
        Touch touch = touches.get(i);
        int touchId = touch.getIdentifier();
        deltaX[touchId] = touch.getRelativeX(canvas) - touchX[touchId];
        deltaY[touchId] = touch.getRelativeY(canvas) - touchY[touchId];
        touchX[touchId] = touch.getRelativeX(canvas);
        touchY[touchId] = touch.getRelativeY(canvas);
        if (processor != null) {
          processor.touchDragged(touchX[touchId], touchY[touchId], touchId);
        }
      }
      this.currentEventTimeStamp = TimeUtils.nanoTime();
      e.preventDefault();
    }
    if (e.getType().equals("touchcancel")) {
      JsArray<Touch> touches = e.getChangedTouches();
      for (int i = 0, j = touches.length(); i < j; i++) {
        Touch touch = touches.get(i);
        int touchId = touch.getIdentifier();
        touched[touchId] = false;
        deltaX[touchId] = touch.getRelativeX(canvas) - touchX[touchId];
        deltaY[touchId] = touch.getRelativeY(canvas) - touchY[touchId];       
        touchX[touchId] = touch.getRelativeX(canvas);
        touchY[touchId] = touch.getRelativeY(canvas);
        if (processor != null) {
          processor.touchUp(touchX[touchId], touchY[touchId], touchId, Buttons.LEFT);
        }         
      }
      this.currentEventTimeStamp = TimeUtils.nanoTime();
      e.preventDefault();
    }
    if (e.getType().equals("touchend")) {     
      JsArray<Touch> touches = e.getChangedTouches();
      for (int i = 0, j = touches.length(); i < j; i++) {
        Touch touch = touches.get(i);
        int touchId = touch.getIdentifier();
        touched[touchId] = false;
        deltaX[touchId] = touch.getRelativeX(canvas) - touchX[touchId];
        deltaY[touchId] = touch.getRelativeY(canvas) - touchY[touchId];       
        touchX[touchId] = touch.getRelativeX(canvas);
        touchY[touchId] = touch.getRelativeY(canvas);
        if (processor != null) {
          processor.touchUp(touchX[touchId], touchY[touchId], touchId, Buttons.LEFT);
        }         
      }
      this.currentEventTimeStamp = TimeUtils.nanoTime();
View Full Code Here

    if (e.getType().equals("touchstart")) {
      this.justTouched = true;
      JsArray<Touch> touches = e.getChangedTouches();
      for (int i = 0, j = touches.length(); i < j; i++) {
        Touch touch = touches.get(i);
        int touchId = touch.getIdentifier();
        touched[touchId] = true;
        touchX[touchId] = touch.getRelativeX(canvas);
        touchY[touchId] = touch.getRelativeY(canvas);
        deltaX[touchId] = 0;
        deltaY[touchId] = 0;
        if (processor != null) {
          processor.touchDown(touchX[touchId], touchY[touchId], touchId, Buttons.LEFT);
        }       
      }
      this.currentEventTimeStamp = TimeUtils.nanoTime();
      e.preventDefault();
    }
    if (e.getType().equals("touchmove")) {
      JsArray<Touch> touches = e.getChangedTouches();
      for (int i = 0, j = touches.length(); i < j; i++) {
        Touch touch = touches.get(i);
        int touchId = touch.getIdentifier();
        deltaX[touchId] = touch.getRelativeX(canvas) - touchX[touchId];
        deltaY[touchId] = touch.getRelativeY(canvas) - touchY[touchId];
        touchX[touchId] = touch.getRelativeX(canvas);
        touchY[touchId] = touch.getRelativeY(canvas);
        if (processor != null) {
          processor.touchDragged(touchX[touchId], touchY[touchId], touchId);
        }
      }
      this.currentEventTimeStamp = TimeUtils.nanoTime();
      e.preventDefault();
    }
    if (e.getType().equals("touchcancel")) {
      JsArray<Touch> touches = e.getChangedTouches();
      for (int i = 0, j = touches.length(); i < j; i++) {
        Touch touch = touches.get(i);
        int touchId = touch.getIdentifier();
        touched[touchId] = false;
        deltaX[touchId] = touch.getRelativeX(canvas) - touchX[touchId];
        deltaY[touchId] = touch.getRelativeY(canvas) - touchY[touchId];       
        touchX[touchId] = touch.getRelativeX(canvas);
        touchY[touchId] = touch.getRelativeY(canvas);
        if (processor != null) {
          processor.touchUp(touchX[touchId], touchY[touchId], touchId, Buttons.LEFT);
        }         
      }
      this.currentEventTimeStamp = TimeUtils.nanoTime();
      e.preventDefault();
    }
    if (e.getType().equals("touchend")) {     
      JsArray<Touch> touches = e.getChangedTouches();
      for (int i = 0, j = touches.length(); i < j; i++) {
        Touch touch = touches.get(i);
        int touchId = touch.getIdentifier();
        touched[touchId] = false;
        deltaX[touchId] = touch.getRelativeX(canvas) - touchX[touchId];
        deltaY[touchId] = touch.getRelativeY(canvas) - touchY[touchId];       
        touchX[touchId] = touch.getRelativeX(canvas);
        touchY[touchId] = touch.getRelativeY(canvas);
        if (processor != null) {
          processor.touchUp(touchX[touchId], touchY[touchId], touchId, Buttons.LEFT);
        }         
      }
      this.currentEventTimeStamp = TimeUtils.nanoTime();
View Full Code Here

      case READY:
        touchStart1 = event.getTouches().get(0);
        state = State.ONE_FINGER;
        break;
      case ONE_FINGER:
        Touch touchStart2 = event.getTouches().get(1);
        distance = (int) Math.sqrt(Math.pow(touchStart1.getPageX() - touchStart2.getPageX(), 2) + Math.pow(touchStart1.getPageY() - touchStart1.getPageY(), 2));
        state = State.TWO_FINGER;
        break;

      default:
        state = State.INVALID;
View Full Code Here

  @Override
  public void onTouchMove(TouchMoveEvent event) {
    switch (state) {
      case TWO_FINGER:

        Touch touch1 = event.getTouches().get(0);
        Touch touch2 = event.getTouches().get(1);

        int left = offsetProvider.getLeft();
        int top = offsetProvider.getTop();

        int x1 = touch1.getPageX() - left;
        int y1 = touch1.getPageY() - top;
        int x2 = touch2.getPageX() - left;
        int y2 = touch2.getPageY() - top;

        double newDistance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
        int x = (x1 + x2) / 2;
        int y = (y1 + y2) / 2;
View Full Code Here

  }

  @Override
  public void onTouchMove(TouchMoveEvent event) {
    Touch touch = event.getTouches().get(0);

    switch (state) {
      case INVALID:

        break;
      case READY:
        // WTF?
        state = State.INVALID;
        break;
      case FINDER_DOWN:

        // log(" X: " + touch.getPageX() + " old: " + touchStart.getPageX() + " test: " + x);

        if (Math.abs(touch.getPageX() - x) >= threshold) {
          state = State.FOUND_DIRECTION;

          direction = touch.getPageX() - x > 0 ? Direction.LEFT_TO_RIGHT : Direction.RIGHT_TO_LEFT;

          SwipeStartEvent swipeStartEvent =
                  new SwipeStartEvent(new TouchPoint(touch), touch.getPageX() - x, direction);

          source.fireEvent(swipeStartEvent);

        } else {
          if (Math.abs(touch.getPageY() - y) >= threshold) {
            state = State.FOUND_DIRECTION;

            direction = touch.getPageY() - y > 0 ? Direction.TOP_TO_BOTTOM : Direction.BOTTOM_TO_TOP;

            SwipeStartEvent swipeStartEvent =
                    new SwipeStartEvent(new TouchPoint(touch), touch.getPageY() - y, direction);

            source.fireEvent(swipeStartEvent);

          }

        }
        break;

      case FOUND_DIRECTION:

        switch (direction) {
          case TOP_TO_BOTTOM:
          case BOTTOM_TO_TOP:
            lastDistance = Math.abs(touch.getPageY() - y);
            source.fireEvent(
                    new SwipeMoveEvent(new TouchPoint(touch), lastDistance > minDistance,
                            lastDistance, direction));
            break;

          case LEFT_TO_RIGHT:
          case RIGHT_TO_LEFT:
            lastDistance = Math.abs(touch.getPageX() - x);
            source.fireEvent(
                    new SwipeMoveEvent(new TouchPoint(touch), lastDistance > minDistance,
                            lastDistance, direction));

            break;
View Full Code Here

    case FINGERS_DOWN:
    case FINGERS_UP:
      // compare positions
      JsArray<Touch> currentTouches = event.getTouches();
      for (int i = 0; i < currentTouches.length(); i++) {
        Touch currentTouch = currentTouches.get(i);
        for (TouchPoint startTouch : startPositions) {
          if (currentTouch.getIdentifier() == startTouch.getId()) {
            if (Math.abs(currentTouch.getPageX() - startTouch.getX()) > DEFAULT_MAX_DISTANCE
                    || Math.abs(currentTouch.getPageY() - startTouch.getY()) > DEFAULT_MAX_DISTANCE) {
              state = State.INVALID;
              break;
            }
          }
          if (state == State.INVALID) {
View Full Code Here

                        }

                        break;
                    case Event.ONTOUCHSTART:
                        touchStart = event;
                        Touch touch = event.getChangedTouches().get(0);
                        // save position to fields, touches in events are same
                        // isntance during the operation.
                        touchStartX = touch.getClientX();
                        touchStartY = touch.getClientY();
                        /*
                         * Prevent simulated mouse events.
                         */
                        touchStart.preventDefault();
                        if (dragmode != 0 || actionKeys != null) {
View Full Code Here

                }
                /*
                 * TODO calculate based on real distance instead of separate
                 * axis checks
                 */
                Touch touch = event.getChangedTouches().get(0);
                if (Math.abs(touch.getClientX() - touchStartX) > TouchScrollDelegate.SIGNIFICANT_MOVE_THRESHOLD) {
                    return true;
                }
                if (Math.abs(touch.getClientY() - touchStartY) > TouchScrollDelegate.SIGNIFICANT_MOVE_THRESHOLD) {
                    return true;
                }
                return false;
            }
View Full Code Here

     *            The touch event
     */
    private void touchMove(TouchEvent<?> event) {
        event.preventDefault();
        if (event.getTouches().length() > 1) {
            Touch t1 = event.getTouches().get(0);
            Touch t2 = event.getTouches().get(1);
            int fingerDistance = Math.abs(t1.getClientX() - t2.getClientX());

            if (t1.getClientX() < t2.getClientX()) {
                /*
                 * t1 is left finger, t2 is right finger
                 */
                lastMouseX = t1.getClientX() + fingerDistance / 2;
            } else {
                /*
                 * t2 is left finger, t1 is right finger
                 */
                lastMouseX = t2.getClientX() + fingerDistance / 2;
            }

            if (lastTouchFingerDistance > 0) {
                if (fingerDistance > lastTouchFingerDistance) {
                    zoomOut(lastMouseX,
View Full Code Here

TOP

Related Classes of com.google.gwt.dom.client.Touch

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.