當前位置: 首頁>>代碼示例>>Java>>正文


Java GestureEvent類代碼示例

本文整理匯總了Java中org.eclipse.swt.events.GestureEvent的典型用法代碼示例。如果您正苦於以下問題:Java GestureEvent類的具體用法?Java GestureEvent怎麽用?Java GestureEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GestureEvent類屬於org.eclipse.swt.events包,在下文中一共展示了GestureEvent類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendScrollEvent

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
private void sendScrollEvent(EventType<ScrollEvent> fxEventType,
			final GestureEvent event,
			TKSceneListener sceneListener) {
		currentState.totalScrollX += event.xDirection;
		currentState.totalScrollY += event.yDirection;
		Point screenPosition = canvas.toDisplay(event.x, event.y);
//		System.out.println(fxEventType + " " + screenPosition);
		sceneListener.scrollEvent(fxEventType, 
				event.xDirection, event.yDirection, // scrollX, scrollY
				0, 0,        // totalScrollX, totalScrollY
				5.0, 5.0,  // xMultiplier, yMultiplier
				0,           // touchCount 
				0, 0,        // scrollTextX, scrollTextY
				0, 0,        // defaultTextX, defaultTextY
				event.x, event.y, // x, y
				screenPosition.x, screenPosition.y, // screenX, screenY
				isShift(event), isControl(event), isAlt(event), isMeta(event), 
				false,       // direct 
				false);      // inertia
	}
 
開發者ID:JanKoehnlein,項目名稱:JavaFX-SWT-Gesture-Bridge,代碼行數:21,代碼來源:SwtToFXGestureConverter.java

示例2: sendZoomEvent

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
private void sendZoomEvent(EventType<ZoomEvent> fxEventType,
			final GestureEvent event,
			TKSceneListener sceneListener) {
		Point screenPosition = canvas.toDisplay(event.x, event.y);
		double magnification = (fxEventType == ZoomEvent.ZOOM_FINISHED) 
				? currentState.lastZoomFactor
				: event.magnification;
//		System.out.println(fxEventType + " " + magnification);
		sceneListener.zoomEvent(fxEventType,
				magnification / currentState.lastZoomFactor, // zoom factor
				magnification,    // totalZoomFactor
				event.x, event.y,       // x, y
				screenPosition.x, screenPosition.y,           // screenX, screenY
				isShift(event), isControl(event), isAlt(event), isMeta(event), 
				false,      // direct 
				false);     // inertia
		currentState.lastZoomFactor = magnification;
	}
 
開發者ID:JanKoehnlein,項目名稱:JavaFX-SWT-Gesture-Bridge,代碼行數:19,代碼來源:SwtToFXGestureConverter.java

示例3: sendRotateEvent

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
private void sendRotateEvent(EventType<RotateEvent> fxEventType,
			final GestureEvent event,
			TKSceneListener sceneListener) {
		Point screenPosition = canvas.toDisplay(event.x, event.y);
		double rotation = (fxEventType == RotateEvent.ROTATION_FINISHED) 
				? currentState.lastRotation
				: -event.rotation;
//		System.out.println(fxEventType + " " + rotation);
		sceneListener.rotateEvent(fxEventType,
				rotation - currentState.lastRotation, // rotation
				rotation,               // totalRotation
				event.x, event.y,       // x, y
				screenPosition.x, screenPosition.y,           // screenX, screenY
				isShift(event), isControl(event), isAlt(event), isMeta(event), 
				false,      // direct 
				false);     // inertia
		currentState.lastRotation = rotation;
	}
 
開發者ID:JanKoehnlein,項目名稱:JavaFX-SWT-Gesture-Bridge,代碼行數:19,代碼來源:SwtToFXGestureConverter.java

示例4: sendSwipeEvent

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
private void sendSwipeEvent(final GestureEvent event,
				TKSceneListener sceneListener) {
		Point screenPosition = canvas.toDisplay(event.x, event.y);
		EventType<SwipeEvent> fxEventType = null;
		if(event.yDirection > 0)
			fxEventType = SwipeEvent.SWIPE_DOWN;
		else if(event.yDirection < 0) 
			fxEventType = SwipeEvent.SWIPE_UP;
		else if(event.xDirection > 0)
			fxEventType = SwipeEvent.SWIPE_RIGHT;
		else if(event.xDirection < 0) 
			fxEventType = SwipeEvent.SWIPE_LEFT;
//		System.out.println(fxEventType.toString());
		sceneListener.swipeEvent(fxEventType,
				0,                  // touch
				event.x, event.y,   // x, y
				screenPosition.x, screenPosition.y, // screenX, screenY
				isShift(event), isControl(event), isAlt(event), isMeta(event), 
				false);             // direct 
	}
 
開發者ID:JanKoehnlein,項目名稱:JavaFX-SWT-Gesture-Bridge,代碼行數:21,代碼來源:SwtToFXGestureConverter.java

示例5: GraphViewerZoomable

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
GraphViewerZoomable(Composite composite, int style) {
	super(composite, style);
	getZoomManager().setZoom(1.0);
	Graph graph = getGraphControl();
	graph.setScrollBarVisibility(FigureCanvas.ALWAYS);
	graph.setTouchEnabled(false);
	graph.addGestureListener(new GestureListener() {
		public void gesture(GestureEvent e) {
			if(e.detail == SWT.GESTURE_MAGNIFY)
				zoom(e.magnification);
		}
	});
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:14,代碼來源:GraphViewerZoomable.java

示例6: mouseScrolled

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
@Override
public void mouseScrolled(final MouseEvent e) {
	Platform.runLater(new Runnable() {
           @Override
           public void run() {
           	final Object scenePeer = getPrivateField(canvas, "scenePeer");
               AccessController.doPrivileged(new PrivilegedAction<Void>() {
                   @Override
                   public Void run() {
                   	TKSceneListener sceneListener = getPrivateField(scenePeer, "sceneListener");
					if (sceneListener == null) {
                           return null;
                       }
					Event mockEvent = new Event();
					mockEvent.stateMask = e.stateMask;
					mockEvent.x = e.x;
					mockEvent.y = e.y;
					mockEvent.xDirection = 0;
					mockEvent.yDirection = e.count;
					mockEvent.widget = e.widget;
					mockEvent.display = e.display;
					mockEvent.time = e.time;
					mockEvent.data = e.data;
					GestureEvent mockGestureEvent = new GestureEvent(mockEvent);
					mockGestureEvent.stateMask = e.stateMask;
					sendScrollEvent(ScrollEvent.SCROLL_STARTED, mockGestureEvent, sceneListener);
					sendScrollEvent(ScrollEvent.SCROLL_FINISHED, mockGestureEvent, sceneListener);
                       return null;
                   }

               }, (AccessControlContext) getPrivateField(scenePeer, "accessCtrlCtx"));
           }
       });
}
 
開發者ID:JanKoehnlein,項目名稱:JavaFX-SWT-Gesture-Bridge,代碼行數:35,代碼來源:SwtToFXGestureConverter.java

示例7: sendGestureEventToFX

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
protected void sendGestureEventToFX(final GestureEvent event) {
       Platform.runLater(new Runnable() {
           @Override
           public void run() {
           	final Object scenePeer = getPrivateField(canvas, "scenePeer");
               AccessController.doPrivileged(new PrivilegedAction<Void>() {
                   @Override
                   public Void run() {
                   	TKSceneListener sceneListener = getPrivateField(scenePeer, "sceneListener");
					if (sceneListener == null) {
                           return null;
                       }
					switch(event.detail) {
						case SWT.GESTURE_BEGIN:
							break;
						case SWT.GESTURE_END:
							changeState(StateType.IDLE, event, sceneListener);
							break;
						case SWT.GESTURE_MAGNIFY:
							changeState(StateType.ZOOMING, event, sceneListener);
							break;
						case SWT.GESTURE_PAN:
							changeState(StateType.SCROLLING, event, sceneListener);
							break;
						case SWT.GESTURE_ROTATE:
							changeState(StateType.ROTATING, event, sceneListener);
							break;
						case SWT.GESTURE_SWIPE:
							changeState(StateType.IDLE, event, sceneListener);
					}
                       return null;
                   }

               }, (AccessControlContext) getPrivateField(scenePeer, "accessCtrlCtx"));
           }
       });
}
 
開發者ID:JanKoehnlein,項目名稱:JavaFX-SWT-Gesture-Bridge,代碼行數:38,代碼來源:SwtToFXGestureConverter.java

示例8: gesture

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
@Override
public void gesture(GestureEvent event) {
	sendGestureEventToFX(event);
}
 
開發者ID:JanKoehnlein,項目名稱:JavaFX-SWT-Gesture-Bridge,代碼行數:5,代碼來源:SwtToFXGestureConverter.java

示例9: changeState

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
protected boolean changeState(StateType newStateType, GestureEvent event, TKSceneListener sceneListener) {
	if(newStateType != currentState.type) { 
		switch (currentState.type) {
			case SCROLLING:
				sendScrollEvent(ScrollEvent.SCROLL_FINISHED, event, sceneListener);
				break;
			case ROTATING:
				sendRotateEvent(RotateEvent.ROTATION_FINISHED, event, sceneListener);
				break;
			case ZOOMING:
				sendZoomEvent(ZoomEvent.ZOOM_FINISHED, event, sceneListener);
				break;
			default:
				// do nothing
		}
		switch (newStateType) {
			case SCROLLING:
				sendScrollEvent(ScrollEvent.SCROLL_STARTED, event, sceneListener);
				break;
			case ROTATING:
				sendRotateEvent(RotateEvent.ROTATION_STARTED, event, sceneListener);
				break;
			case ZOOMING:
				sendZoomEvent(ZoomEvent.ZOOM_STARTED, event, sceneListener);
				break;
			case IDLE:
				if(event.detail == SWT.GESTURE_SWIPE)
					sendSwipeEvent(event, sceneListener);
				break;
			default:
				// do nothing
		}
		currentState = new State(newStateType);
		return true;
	}
	switch (newStateType) {
		case SCROLLING:
			sendScrollEvent(ScrollEvent.SCROLL, event, sceneListener);
			break;
		case ROTATING:
			sendRotateEvent(RotateEvent.ROTATE, event, sceneListener);
			break;
		case ZOOMING:
			sendZoomEvent(ZoomEvent.ZOOM, event, sceneListener);
			break;
		case IDLE:
			if(event.detail == SWT.GESTURE_SWIPE)
				sendSwipeEvent(event, sceneListener);
		default:
			// do nothing
	}
	return false;
}
 
開發者ID:JanKoehnlein,項目名稱:JavaFX-SWT-Gesture-Bridge,代碼行數:54,代碼來源:SwtToFXGestureConverter.java

示例10: isShift

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
private boolean isShift(final GestureEvent event) {
	return (event.stateMask & SWT.SHIFT) != 0;
}
 
開發者ID:JanKoehnlein,項目名稱:JavaFX-SWT-Gesture-Bridge,代碼行數:4,代碼來源:SwtToFXGestureConverter.java

示例11: isControl

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
private boolean isControl(final GestureEvent event) {
	return (event.stateMask & SWT.CONTROL) != 0;
}
 
開發者ID:JanKoehnlein,項目名稱:JavaFX-SWT-Gesture-Bridge,代碼行數:4,代碼來源:SwtToFXGestureConverter.java

示例12: isAlt

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
private boolean isAlt(final GestureEvent event) {
	return (event.stateMask & SWT.ALT) != 0;
}
 
開發者ID:JanKoehnlein,項目名稱:JavaFX-SWT-Gesture-Bridge,代碼行數:4,代碼來源:SwtToFXGestureConverter.java

示例13: isMeta

import org.eclipse.swt.events.GestureEvent; //導入依賴的package包/類
private boolean isMeta(final GestureEvent event) {
	return (event.stateMask & SWT.COMMAND) != 0;
}
 
開發者ID:JanKoehnlein,項目名稱:JavaFX-SWT-Gesture-Bridge,代碼行數:4,代碼來源:SwtToFXGestureConverter.java


注:本文中的org.eclipse.swt.events.GestureEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。