Java 类org.eclipse.swt.events.GestureEvent 实例源码

项目:JavaFX-SWT-Gesture-Bridge    文件:SwtToFXGestureConverter.java   
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
    }
项目:JavaFX-SWT-Gesture-Bridge    文件:SwtToFXGestureConverter.java   
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;
    }
项目:JavaFX-SWT-Gesture-Bridge    文件:SwtToFXGestureConverter.java   
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;
    }
项目:JavaFX-SWT-Gesture-Bridge    文件:SwtToFXGestureConverter.java   
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 
    }
项目:pandionj    文件:GraphViewerZoomable.java   
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);
        }
    });
}
项目:JavaFX-SWT-Gesture-Bridge    文件:SwtToFXGestureConverter.java   
@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"));
           }
       });
}
项目:JavaFX-SWT-Gesture-Bridge    文件:SwtToFXGestureConverter.java   
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"));
           }
       });
}
项目:JavaFX-SWT-Gesture-Bridge    文件:SwtToFXGestureConverter.java   
@Override
public void gesture(GestureEvent event) {
    sendGestureEventToFX(event);
}
项目:JavaFX-SWT-Gesture-Bridge    文件:SwtToFXGestureConverter.java   
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;
}
项目:JavaFX-SWT-Gesture-Bridge    文件:SwtToFXGestureConverter.java   
private boolean isShift(final GestureEvent event) {
    return (event.stateMask & SWT.SHIFT) != 0;
}
项目:JavaFX-SWT-Gesture-Bridge    文件:SwtToFXGestureConverter.java   
private boolean isControl(final GestureEvent event) {
    return (event.stateMask & SWT.CONTROL) != 0;
}
项目:JavaFX-SWT-Gesture-Bridge    文件:SwtToFXGestureConverter.java   
private boolean isAlt(final GestureEvent event) {
    return (event.stateMask & SWT.ALT) != 0;
}
项目:JavaFX-SWT-Gesture-Bridge    文件:SwtToFXGestureConverter.java   
private boolean isMeta(final GestureEvent event) {
    return (event.stateMask & SWT.COMMAND) != 0;
}