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

项目: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());
    }
}
项目:geomajas-project-client-gwt2    文件:TouchNavigationController.java   
public void onMapTouchMove(TouchEvent<?> event) {
    if (event.getTouches().length() == 2 && zooming) {
        Coordinate p1 = getWorldLocation(event.getTouches().get(0), RenderSpace.WORLD);
        Coordinate p2 = getWorldLocation(event.getTouches().get(1), RenderSpace.WORLD);
        double scale = MathService.distance(p1, p2) / startDist;
        Coordinate newCenter = getCenter(p1, p2);
        double dx = startCenter.getX() - newCenter.getX();
        double dy = startCenter.getY() - newCenter.getY();
        double resolution = mapPresenter.getViewPort().getResolution() / scale;
        Coordinate position = calculatePosition(scale, startCenter);
        View view = new View(new Coordinate(position.getX() + dx, position.getY() + dy), resolution);
        view.setInteractive(true);
        mapPresenter.getViewPort().applyView(view);
    } else {
        onDrag(event);
    }
    event.preventDefault();
    event.stopPropagation();
}
项目: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;
}
项目:umlet    文件:EventHandlingUtils.java   
private static Point getPoint(EventHandlingTarget drawPanelCanvas, HumanInputEvent<?> event) {
    Element e = drawPanelCanvas.getElement();
    if (event instanceof MouseEvent<?>) {
        return new Point(((MouseEvent<?>) event).getRelativeX(e), ((MouseEvent<?>) event).getRelativeY(e));
    }
    else if (event instanceof TouchEndEvent) {
        return new Point(((TouchEvent<?>) event).getChangedTouches().get(0).getRelativeX(e), ((TouchEvent<?>) event).getChangedTouches().get(0).getRelativeY(e));
    }
    else if (event instanceof TouchEvent<?>) {
        return new Point(((TouchEvent<?>) event).getTouches().get(0).getRelativeX(e), ((TouchEvent<?>) event).getTouches().get(0).getRelativeY(e));
    }
    else {
        throw new RuntimeException("Unknown Event Type: " + event);
    }
}
项目:umlet    文件:EventHandlingUtils.java   
private static Point getPointAbsolute(HumanInputEvent<?> event) {
    if (event instanceof MouseEvent<?>) {
        return new Point(((MouseEvent<?>) event).getClientX(), ((MouseEvent<?>) event).getClientY());
    }
    else if (event instanceof TouchEndEvent) {
        return new Point(((TouchEvent<?>) event).getChangedTouches().get(0).getPageX(), ((TouchEvent<?>) event).getChangedTouches().get(0).getPageY());
    }
    else if (event instanceof TouchEvent<?>) {
        return new Point(((TouchEvent<?>) event).getTouches().get(0).getPageX(), ((TouchEvent<?>) event).getTouches().get(0).getPageY());
    }
    else {
        throw new RuntimeException("Unknown Event Type: " + event);
    }
}
项目: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);
        }
    }
}
项目:geomajas-project-client-gwt2    文件:TouchNavigationController.java   
public void onMapTouchStart(TouchEvent<?> event) {
    if (event.getTouches().length() == 2) {
        Coordinate p1 = getWorldLocation(event.getTouches().get(0), RenderSpace.WORLD);
        Coordinate p2 = getWorldLocation(event.getTouches().get(1), RenderSpace.WORLD);
        startCenter = getCenter(p1, p2);
        startDist = MathService.distance(p1, p2);
        stopPanning(null);
        this.zooming = true;
    } else {
        onDown(event);
    }
    event.preventDefault();
    event.stopPropagation();
}
项目:geomajas-project-client-gwt2    文件:TouchNavigationController.java   
public void onMapTouchEnd(TouchEvent<?> event) {
    if (zooming) {
        if (event.getTouches().length() == 0) {
            zooming = false;
        }
        mapPresenter.getViewPort().stopInteraction();
    } else {
        onUp(event);
    }
    event.preventDefault();
    event.stopPropagation();
}
项目:geomajas-project-client-gwt2    文件:AbstractController.java   
/**
 * Forward as mouse down and stop the event.
 * @since 2.4.0
 */
@Override
public void onMapTouchStart(TouchEvent<?> event) {
    onDown(event);
    event.stopPropagation();
    event.preventDefault();
}
项目:geomajas-project-client-gwt2    文件:AbstractController.java   
/**
 * Forward as mouse move and stop the event.
 * @since 2.4.0
 */
@Override
public void onMapTouchMove(TouchEvent<?> event) {
    onDrag(event);
    event.stopPropagation();
    event.preventDefault();
}
项目:geomajas-project-client-gwt2    文件:AbstractController.java   
/**
 * Forward as mouse up and stop the event.
 * @since 2.4.0
 */
@Override
public void onMapTouchEnd(TouchEvent<?> event) {
    onUp(event);
    event.stopPropagation();
    event.preventDefault();
}
项目:geomajas-project-client-gwt2    文件:AbstractController.java   
/**
 * Forward as mouse up and stop the event.
 * @since 2.4.0
 */
@Override
public void onMapTouchCancel(TouchEvent<?> event) {
    onUp(event);
    event.stopPropagation();
    event.preventDefault();
}
项目:touchkit    文件:VSwitch.java   
private void addHandlers() {
    addDomHandler(this, KeyUpEvent.getType());
    if (TouchEvent.isSupported()) {
        addDomHandler(this, TouchStartEvent.getType());
        addDomHandler(this, TouchMoveEvent.getType());
        addDomHandler(this, TouchEndEvent.getType());
        addDomHandler(this, TouchCancelEvent.getType());
    } else {
        addDomHandler(this, MouseDownEvent.getType());
        addDomHandler(this, MouseUpEvent.getType());
        addDomHandler(this, MouseMoveEvent.getType());
    }
    addDomHandler(this, FocusEvent.getType());
    addDomHandler(this, BlurEvent.getType());
}
项目:empiria.player    文件:TouchToImageEvent.java   
public TouchOnImageEvent getTouchOnImageEvent(TouchEvent<? extends EventHandler> touchEvent) {
    List<Point> pointsList = getPoints(touchEvent);

    return new TouchOnImageEvent(pointsList);
}
项目: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();
}
项目:geomajas-project-client-gwt2    文件:TouchNavigationController.java   
public void onMapTouchCancel(TouchEvent<?> event) {
    onMapTouchEnd(event);
}
项目:geomajas-project-client-gwt2    文件:MapTouchHandler.java   
void onMapTouchStart(TouchEvent<?> event);
项目:geomajas-project-client-gwt2    文件:MapTouchHandler.java   
void onMapTouchMove(TouchEvent<?> event);
项目:geomajas-project-client-gwt2    文件:MapTouchHandler.java   
void onMapTouchEnd(TouchEvent<?> event);
项目:geomajas-project-client-gwt2    文件:MapTouchHandler.java   
void onMapTouchCancel(TouchEvent<?> event);