Java 类com.google.gwt.dom.client.Touch 实例源码

项目:empiria.player    文件:TouchToImageEvent.java   
@Override
public Point apply(Touch touch) {
    return new Point(touch.getClientX(), touch.getClientY());
}
项目:empiria.player    文件:AbstractConnectionView.java   
@Override
public void onTouchEvent(TouchEvent event) {
    NativeEvent nativeEvent = event.getNativeEvent();

    JsArray<Touch> touches = nativeEvent.getTouches();
    boolean isMouseClick = isMouseClick(touches); // method is also called
    // when MouseEvents
    // occur
    boolean isOneFingerTouch = isOneFingerTouch(touches);

    switch (event.getType()) {
        case TOUCH_START:
            if (isMouseClick || isOneFingerTouch) {
                onTouchStart(nativeEvent);
            } else {
                onTouchCancel(nativeEvent);
            }
            break;
        case TOUCH_CANCEL:
        case TOUCH_END:
            onTouchEnd(nativeEvent);
            break;
        case TOUCH_MOVE:
            if (isMouseClick || isOneFingerTouch) {
                onTouchMove(nativeEvent);
            } else {
                onTouchCancel(nativeEvent);
            }
            break;
        default:
            break;
    }

}
项目:firefly    文件:SplitLayoutPanelFirefly.java   
@Override
        protected int getEventPosition(Event ev) {
            JsArray<Touch> touches = ev.getTouches();
            int retval;
            if (touches != null && touches.length() > 0) {
                Touch t = touches.get(0);
                retval = t.getPageX();
//            retval= t.getClientX() - getAbsoluteLeft();
//            GwtUtil.showDebugMsg("retval="+retval+ ", cx="+t.getClientX()+ ", al=" +getAbsoluteLeft());

            } else {
                retval = ev.getClientX() + Window.getScrollLeft();
            }
            return retval;
        }
项目:fullmetalgalaxy    文件:WgtBoardBase.java   
@Override
public void onTouchEnd(TouchEndEvent p_event)
{
  if (!m_hasTouchMoved) {
    p_event.preventDefault();
    Touch touch = p_event.getChangedTouches().get(0);
    Element current = getElement();
    Element parent = current.getParentElement();
    int x = touch.getPageX() - current.getOffsetLeft() - parent.getOffsetLeft();
    int y = touch.getPageY() - current.getOffsetTop() - parent.getOffsetTop();
    onUp(UserAction.Touch, x, y);
  }
}
项目:fullmetalgalaxy    文件:WgtScroll.java   
private Touch getTouch(JsArray<Touch> touches, int identifier)
{
  if (touches != null && !isZoomed()) {
    if (identifier == -1) {
      if (touches.length() > 0) {
        return touches.get(0);
      }
    } else if (touches.length() == 1) {
      Touch touch = touches.get(0);
      if (touch.getIdentifier() == identifier) {
        return touch;
      }
    }
  }
  return null;
}
项目:SilenceEngine    文件:GwtInputDevice.java   
private void postTouchEvents(JsArray<Touch> touches, boolean isDown)
{
    int i, j;

    // Browsers report only the available touches in a list. So update all the touches in the list accurately.
    // We ignore the touches past finger 9 (only ten fingers are read).
    for (i = 0, j = com.shc.silenceengine.input.Touch.FINGER_0;
         i < touches.length() && j <= com.shc.silenceengine.input.Touch.FINGER_9; i++, j++)
    {
        Touch touch = touches.get(i);
        postTouchEvent(j, isDown, touch.getClientX(), touch.getClientY());
    }

    // For all the remain fingers, set the finger down state to false. Otherwise they are reported as down
    // continuously. This will fix that issue.
    while (j <= com.shc.silenceengine.input.Touch.FINGER_9)
        postTouchEvent(j++, false, 0, 0);
}
项目:geomajas-project-client-gwt    文件:AbstractGraphicsController.java   
@Override
public Coordinate getLocation(HumanInputEvent<?> event, RenderSpace renderSpace) {
    switch (renderSpace) {
        case WORLD:
            Coordinate screen = getLocation(event, RenderSpace.SCREEN);
            return mapWidget.getMapModel().getMapView().getWorldViewTransformer().viewToWorld(screen);
        case SCREEN:
        default:
            if (event instanceof MouseEvent<?>) {
                Element element = mapWidget.getDOM();
                double offsetX = ((MouseEvent<?>) event).getRelativeX(element);
                double offsetY = ((MouseEvent<?>) event).getRelativeY(element);
                return new Coordinate(offsetX, offsetY);
            } else if (event instanceof TouchEvent<?>) {
                Touch touch = ((TouchEvent<?>) event).getTouches().get(0);
                return new Coordinate(touch.getClientX(), touch.getClientY());
            }
            return new Coordinate(event.getNativeEvent().getClientX(), event.getNativeEvent().getClientY());
    }
}
项目:touchkit    文件:VSwitch.java   
public void onTouchStart(TouchStartEvent event) {
    if (isEnabled()) {
        Touch touch = event.getTouches().get(0).cast();
        handleMouseDown(touch.getPageX(), touch.getPageY());
        event.stopPropagation();
    }
}
项目:empiria.player    文件:AbstractConnectionView.java   
private boolean isMouseClick(JsArray<Touch> touches) {
    return (touches == null) && pointerEventsCoordinates.isEmpty();
}
项目:empiria.player    文件:PositionHelper.java   
public int getYPositionRelativeToTarget(NativeEvent event, Element target) {
    Touch touch = getTouch(event);
    float positionY = 0;// hack dont change to int
    if (touch == null) {
        positionY = getRelativeY(event, target);
    } else {
        positionY = touch.getRelativeY(target);
    }
    return (int) positionY;
}
项目:empiria.player    文件:PositionHelper.java   
/**
 * zwraca relatywna pozycje X zdarzenia do elementu target
 *
 * @param event
 * @param target
 * @return
 */
public int getXPositionRelativeToTarget(NativeEvent event, Element target) {
    Touch touch = getTouch(event);
    float positionX = 0; // hack dont change to int
    if (touch == null) {
        positionX = getRelativeX(event, target);
    } else {
        positionX = touch.getRelativeX(target);
    }
    return (int) positionX;
}
项目:empiria.player    文件:PositionHelper.java   
private Touch getTouch(NativeEvent event) {
    JsArray<Touch> touches = event.getChangedTouches();
    Touch touch = null;
    if (touches != null && touches.length() == 1) {
        touch = touches.get(0);
    }
    return touch;
}
项目:circuitjs1    文件:Scrollbar.java   
public void onTouchMove(TouchMoveEvent e) {
//      GWT.log("touchmove");
        e.preventDefault();
        Touch t = e.getTouches().get(0);
        doMouseMove(t.getRelativeX(getElement()));
    }
项目:circuitjs1    文件:Scrollbar.java   
public void onTouchStart(TouchStartEvent event) {
//      GWT.log("touchstart");
        event.preventDefault();
        dragging=false;
        Touch t = event.getTouches().get(0);
        doMouseDown(t.getRelativeX(getElement()), false);
    }
项目:firefly    文件:SplitLayoutPanelFirefly.java   
@Override
        protected int getEventPosition(Event ev) {
            JsArray<Touch> touches = ev.getTouches();
            int retval;
            if (touches != null && touches.length() > 0) {
                Touch t = touches.get(0);
                retval = t.getPageY();
//          retval= t.getClientY() - getAbsoluteTop();
//          GwtUtil.showDebugMsg("retval="+retval+ ", cx="+t.getClientY()+ ", al=" +getAbsoluteTop());
            } else {
                retval = ev.getClientY() + Window.getScrollTop();
            }
            return retval;
        }
项目:firefly    文件:PopupPane.java   
private int getAbsoluteX(HumanInputEvent ev) {
    if (ev instanceof MouseEvent) {
        return  ((MouseEvent)ev).getClientX()+Window.getScrollLeft();
    }
    if (ev instanceof TouchEvent) {
        JsArray<Touch> tAry= ((TouchEvent)ev).getTargetTouches();
        return  tAry.get(0).getClientX()+Window.getScrollLeft();
    }
    return 0;
}
项目:firefly    文件:PopupPane.java   
private int getAbsoluteY(HumanInputEvent ev) {
    if (ev instanceof MouseEvent) {
        return  ((MouseEvent)ev).getClientY()+ Window.getScrollTop();
    }
    if (ev instanceof TouchEvent) {
        JsArray<Touch> tAry= ((TouchEvent)ev).getTargetTouches();
        return tAry.get(0).getClientY() + Window.getScrollTop();
    }
    return 0;
}
项目:firefly    文件:PVMouse.java   
public void onTouchMove(TouchMoveEvent ev) {
//        if (ev.getTouches().length()>1) return;
        Touch t= ev.getTargetTouches().get(0);
        if (DEBUG) {
            GwtUtil.showDebugMsg("move, touches:" + ev.getTargetTouches().length() +
                                         " -  c: " +t.getClientX()+","+t.getClientY() +
                                         " -  p: " +t.getPageX()+","+t.getPageY() +
                                         " -  s: " +t.getScreenX()+","+t.getScreenY() +
                                         " -  r: " +t.getRelativeX(_mouseMoveArea.getElement())+","+t.getRelativeY(_mouseMoveArea.getElement())+
                                         " - pos: " +_mouseMoveArea.getAbsoluteLeft()+","+_mouseMoveArea.getAbsoluteTop()+"," +
                                         " - scroll: " +_mouseMoveArea.getElement().getScrollLeft()+","+
                                         _mouseMoveArea.getElement().getScrollTop()+"," +
                                         " - absScroll: " +_mouseMoveArea.getElement().getOwnerDocument().getScrollLeft()+","+
                                         _mouseMoveArea.getElement().getOwnerDocument().getScrollTop());
        }
        ScreenPt spt= makeScreenPt(ev);
        boolean enabledOthers= true;
        if (_exclusiveMouse.size()>0) {
//              MouseInfo mi= _exclusiveMouse.peek();
            WebPlotView.MouseInfo mi;

            int len= _exclusiveMouse.size();
            boolean enabledExclusive= true;
            for(int i= 1; ((len-i)>=0 && enabledExclusive); i++) {
                mi= _exclusiveMouse.get(len-i);
                if (mi.isEnabled()) mi.getHandler().onTouchMove(_pv, spt, ev);
                enabledExclusive= mi.getEnableAllExclusive();
                enabledOthers= mi.getEnableAllPersistent();
            }


        }
        if (enabledOthers) {
            for(WebPlotView.MouseInfo info : _persistentMouse) {
                if (info.isEnabled()) info.getHandler().onTouchMove(_pv, spt, ev);
            }
        }
        ev.preventDefault();
    }
项目:firefly    文件:PVMouse.java   
private ScreenPt makeScreenPt(TouchEvent ev) {
    Touch t= (Touch)ev.getTouches().get(0);
    return new ScreenPt(_pv.getScrollX()+t.getClientX() - _mouseMoveArea.getAbsoluteLeft(),
                        _pv.getScrollY()+t.getClientY()- _mouseMoveArea.getAbsoluteTop());
}
项目:djvu-html5    文件:PanListener.java   
@Override
public void onTouchStart(TouchStartEvent event) {
    if (touchId != null || isMouseDown)
        return;
    Touch touch = event.getTouches().get(0);
    touchId = touch.getIdentifier();
    x = touch.getClientX();
    y = touch.getClientY();
    event.preventDefault();
}
项目:djvu-html5    文件:PanListener.java   
@Override
public void onTouchEnd(TouchEndEvent event) {
    if (touchId == null)
        return;
    JsArray<Touch> touches = event.getTouches();
    for (int i = 0; i < touches.length(); i++) {
        Touch touch = touches.get(i);
        if (touch.getIdentifier() == touchId)
            return;
    }
    touchId = null;
    event.preventDefault();
}
项目:djvu-html5    文件:PanListener.java   
@Override
public void onTouchMove(TouchMoveEvent event) {
    if (touchId == null)
        return;
    JsArray<Touch> touches = event.getTouches();
    for (int i = 0; i < touches.length(); i++) {
        Touch touch = touches.get(i);
        if (touch.getIdentifier() != touchId)
            continue;
        pan(touch.getClientX() - x, touch.getClientY() - y);
        x = touch.getClientX();
        y = touch.getClientY();
        event.preventDefault();
    }
}
项目:fullmetalgalaxy    文件:WgtScroll.java   
@Override
public void onTouchStart(TouchStartEvent p_event)
{
  Touch touch = getTouch(p_event.getChangedTouches(), -1);
  if (touch != null) {
    m_currentTouchEventId = touch.getIdentifier();
    onDown(Element.as(touch.getTarget()), touch.getClientX(), touch.getClientY());
  }
}
项目:fullmetalgalaxy    文件:WgtScroll.java   
@Override
public void onTouchMove(TouchMoveEvent p_event)
{
  Touch touch = getTouch(p_event.getChangedTouches(), m_currentTouchEventId);
  if (touch != null) {
    if (p_event.getTouches().length() < 2) {
      // A single finger touch shouldn't be propagated upwards.
      // This prevents iOS 'bounce-scroll' to happen
      p_event.preventDefault();
    }
    onMove(Element.as(touch.getTarget()), touch.getClientX(), touch.getClientY());
  }
}
项目:fullmetalgalaxy    文件:WgtScroll.java   
@Override
public void onTouchEnd(TouchEndEvent p_event)
{
  Touch touch = getTouch(p_event.getChangedTouches(), m_currentTouchEventId);
  if (touch != null) {
    m_currentTouchEventId = -1;
    onUp(Element.as(touch.getTarget()));
  }
}
项目:fullmetalgalaxy    文件:WgtScroll.java   
@Override
public void onTouchCancel(TouchCancelEvent p_event)
{
  Touch touch = getTouch(p_event.getChangedTouches(), m_currentTouchEventId);
  if (touch != null) {
    m_currentTouchEventId = -1;
    onOut(Element.as(touch.getTarget()));
  }
}
项目:gwthtml5apps    文件:TransparentIt.java   
private int[] touchToPoint(JsArray<Touch> touchs){

    //JsArray<Touch> touchs=event.getTouches();
    if(touchs.length()>0){
        Touch touch=touchs.get(0);
        int x=touch.getRelativeX(canvas.getElement());
        int y=touch.getRelativeY(canvas.getElement());
        return new int[]{x,y};
    }

    return null;
}
项目:GraphemeColourSynaesthesiaApp    文件:ColourPickerCanvasView.java   
private void setColour(TouchEvent event, Canvas targetCanvas, VerticalPanel targetPanel) {
    if (event.getTouches().length() > 0) {
        final JsArray<Touch> touches = event.getTargetTouches();
        if (touches.length() > 0) {
            Touch touch = touches.get(0);
            setColour(touch.getRelativeX(targetCanvas.getElement()), touch.getRelativeY(targetCanvas.getElement()), targetCanvas, targetPanel);
        }
    }
}
项目:GraphemeColourSynaesthesiaApp    文件:ColourPickerCanvasView.java   
private void setHue(TouchEvent event, Canvas targetCanvas) {
    if (event.getTouches().length() > 0) {
        final JsArray<Touch> touches = event.getTargetTouches();
        if (touches.length() > 0) {
            Touch touch = touches.get(0);
            setHue(touch.getRelativeX(targetCanvas.getElement()), touch.getRelativeY(targetCanvas.getElement()), targetCanvas);
        }
    }
}
项目:swarm    文件:Mouse.java   
@Override
public void onTouchStart(TouchStartEvent event)
{
    if( m_isMouseDown )  return;

    Touch touch = event.getTouches().get(0);

    onMouseOrTouchDown(event, touch.getRelativeX(m_container.getElement()), touch.getRelativeY(m_container.getElement()), true);
}
项目:swarm    文件:Mouse.java   
@Override
public void onTouchMove(TouchMoveEvent event)
{
    s_logger.log(Level.INFO, "move");

    Touch touch = event.getTouches().get(0);

    this.setMousePoint(touch.getRelativeX(m_container.getElement()), touch.getRelativeY(m_container.getElement()), m_mouseEvent.getPoint());
    m_mouseEvent.set(E_MouseEventType.MOUSE_MOVE, 0, Element.as(event.getNativeEvent().getEventTarget()), true);

    dispatchEvent(m_mouseEvent);
}
项目:touchkit    文件:VSwitch.java   
public void onTouchMove(TouchMoveEvent event) {
    if (isEnabled()) {
        Touch touch = event.getTouches().get(0).cast();
        handleMouseMove(touch.getPageX(), touch.getPageY());
        if (dragging) {
            event.preventDefault();
        }
    }
}
项目:empiria.player    文件:TouchToImageEvent.java   
private List<Point> getPoints(TouchEvent<? extends EventHandler> touchEvent) {
    JsArray<Touch> touches = touchEvent.getTouches();
    JsArrayIterable<Touch> iterableTouches = JsArrayIterable.create(touches);

    return FluentIterable.from(iterableTouches).transform(touchToPointTransforemer).toList();
}
项目:empiria.player    文件:AbstractConnectionView.java   
private boolean isOneFingerTouch(JsArray<Touch> touches) {
    return touchEventChecker.isOnlyOneFinger(touches) || pointerEventsCoordinates.isOnePointer();
}
项目:empiria.player    文件:StickieDragHandlersManager.java   
private Point<Integer> getTouchPoint(JsArray<Touch> touches) {
    Touch touch = touches.get(0);
    Point<Integer> point = new Point<Integer>(touch.getScreenX(), touch.getScreenY());
    return point;
}
项目:rxcanvas-gwt    文件:RxCanvas.java   
private double[] canvasPosition(Canvas canvas, Touch t) {
    return new double[] { t.getRelativeX(canvas.getElement()), t.getRelativeY(canvas.getElement()) };
}
项目:firefly    文件:PVMouse.java   
public void onTouchStart(TouchStartEvent ev) {
//        if (ev.getTouches().length()>1) return;
        boolean exclusive= _exclusiveMouse.size()>0;
        Touch t= ev.getTargetTouches().get(0);
        if (DEBUG) {
            GwtUtil.showDebugMsg("start, touches:" + ev.getTargetTouches().length() +
                                         " -  c: " +t.getClientX()+","+t.getClientY() +
                                         " -  p: " +t.getPageX()+","+t.getPageY() +
                                         " -  s: " +t.getScreenX()+","+t.getScreenY() +
                                         " -  r: " +t.getRelativeX(_mouseMoveArea.getElement())+","+t.getRelativeY(_mouseMoveArea.getElement())+
                                         " - pos: " +_mouseMoveArea.getAbsoluteLeft()+","+_mouseMoveArea.getAbsoluteTop()+"," +
                                         " - scroll: " +_mouseMoveArea.getElement().getScrollLeft()+","+
                                         _mouseMoveArea.getElement().getScrollTop()+"," +
                                         " - absScroll: " +_mouseMoveArea.getElement().getOwnerDocument().getScrollLeft()+","+
                                         _mouseMoveArea.getElement().getOwnerDocument().getScrollTop());
        }
        ScreenPt spt= makeScreenPt(ev);
        if (!exclusive) addPreventEvent();
        _pv.enableFocus();
        if (!exclusive) {
            DOM.releaseCapture(_mouseMoveArea.getElement());
            DOM.setCapture(_mouseMoveArea.getElement());
        }
        boolean enabledOthers= true;
        if (exclusive) {
            WebPlotView.MouseInfo mi;
            int len= _exclusiveMouse.size();
            boolean enabledExclusive= true;
            for(int i= 1; ((len-i)>=0 && enabledExclusive); i++) {
                mi= _exclusiveMouse.get(len-i);
                if (mi.isEnabled()) mi.getHandler().onTouchStart(_pv, spt, ev);
                enabledExclusive= mi.getEnableAllExclusive();
                enabledOthers= mi.getEnableAllPersistent();
            }
        }
        if (enabledOthers) {
            for(WebPlotView.MouseInfo info : _persistentMouse) {
                if (info.isEnabled()) info.getHandler().onTouchStart(_pv, spt, ev);
            }
        }
        _mouseDown= true;
        _pv.disableTextSelect(true);
        ev.preventDefault();
    }
项目:libgdxcn    文件:GwtInput.java   
protected int getRelativeX (Touch touch, CanvasElement target) {
    float xScaleRatio = target.getWidth() * 1f / target.getClientWidth(); // Correct for canvas CSS scaling
    return Math.round(xScaleRatio * touch.getRelativeX(target));
}
项目:libgdxcn    文件:GwtInput.java   
protected int getRelativeY (Touch touch, CanvasElement target) {
    float yScaleRatio = target.getHeight() * 1f / target.getClientHeight(); // Correct for canvas CSS scaling
    return Math.round(yScaleRatio * touch.getRelativeY(target));
}
项目:geomajas-project-client-gwt2    文件:TouchNavigationController.java   
private Coordinate getWorldLocation(Touch touch, RenderSpace world) {
    Element element = mapPresenter.asWidget().getElement();
    Coordinate c = new Coordinate(touch.getRelativeX(element), touch.getRelativeY(element));
    return mapPresenter.getViewPort().getTransformationService()
            .transform(c, RenderSpace.SCREEN, RenderSpace.WORLD);
}