当前位置: 首页>>代码示例>>Java>>正文


Java TouchEvent类代码示例

本文整理汇总了Java中com.google.gwt.event.dom.client.TouchEvent的典型用法代码示例。如果您正苦于以下问题:Java TouchEvent类的具体用法?Java TouchEvent怎么用?Java TouchEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TouchEvent类属于com.google.gwt.event.dom.client包,在下文中一共展示了TouchEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLocation

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
@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());
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt,代码行数:21,代码来源:AbstractGraphicsController.java

示例2: onMapTouchMove

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
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();
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:20,代码来源:TouchNavigationController.java

示例3: getAbsoluteX

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
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;
}
 
开发者ID:lsst,项目名称:firefly,代码行数:11,代码来源:PopupPane.java

示例4: getAbsoluteY

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
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;
}
 
开发者ID:lsst,项目名称:firefly,代码行数:11,代码来源:PopupPane.java

示例5: getPoint

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
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);
	}
}
 
开发者ID:umlet,项目名称:umlet,代码行数:16,代码来源:EventHandlingUtils.java

示例6: getPointAbsolute

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
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);
	}
}
 
开发者ID:umlet,项目名称:umlet,代码行数:15,代码来源:EventHandlingUtils.java

示例7: setColour

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:languageininteraction,项目名称:GraphemeColourSynaesthesiaApp,代码行数:10,代码来源:ColourPickerCanvasView.java

示例8: setHue

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:languageininteraction,项目名称:GraphemeColourSynaesthesiaApp,代码行数:10,代码来源:ColourPickerCanvasView.java

示例9: onMapTouchStart

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
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();
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:15,代码来源:TouchNavigationController.java

示例10: onMapTouchEnd

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
public void onMapTouchEnd(TouchEvent<?> event) {
	if (zooming) {
		if (event.getTouches().length() == 0) {
			zooming = false;
		}
		mapPresenter.getViewPort().stopInteraction();
	} else {
		onUp(event);
	}
	event.preventDefault();
	event.stopPropagation();
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:13,代码来源:TouchNavigationController.java

示例11: onMapTouchStart

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
/**
 * Forward as mouse down and stop the event.
 * @since 2.4.0
 */
@Override
public void onMapTouchStart(TouchEvent<?> event) {
	onDown(event);
	event.stopPropagation();
	event.preventDefault();
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:11,代码来源:AbstractController.java

示例12: onMapTouchMove

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
/**
 * Forward as mouse move and stop the event.
 * @since 2.4.0
 */
@Override
public void onMapTouchMove(TouchEvent<?> event) {
	onDrag(event);
	event.stopPropagation();
	event.preventDefault();
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:11,代码来源:AbstractController.java

示例13: onMapTouchEnd

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
/**
 * Forward as mouse up and stop the event.
 * @since 2.4.0
 */
@Override
public void onMapTouchEnd(TouchEvent<?> event) {
	onUp(event);
	event.stopPropagation();
	event.preventDefault();
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:11,代码来源:AbstractController.java

示例14: onMapTouchCancel

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
/**
 * Forward as mouse up and stop the event.
 * @since 2.4.0
 */
@Override
public void onMapTouchCancel(TouchEvent<?> event) {
	onUp(event);
	event.stopPropagation();
	event.preventDefault();
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:11,代码来源:AbstractController.java

示例15: addHandlers

import com.google.gwt.event.dom.client.TouchEvent; //导入依赖的package包/类
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());
}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:16,代码来源:VSwitch.java


注:本文中的com.google.gwt.event.dom.client.TouchEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。