Java 类javafx.scene.input.ZoomEvent 实例源码

项目: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;
    }
项目:GestureFX    文件:GesturePaneTest.java   
@Test
public void testScaleByTouch() throws Exception {
    double factor = 4.2;
    pane.fireEvent(new ZoomEvent(ZoomEvent.ZOOM, 0, 0, 0, 0, false, false, false, false,
                                        false, false, factor, factor, null));
    assertThat(pane.getCurrentXScale()).isEqualTo(factor);
}
项目:javaone2016    文件:ExhibitionMapPresenter.java   
private void addListeners() {
    imageView.addEventHandler(MouseEvent.MOUSE_PRESSED, pressedHandler);
    imageView.addEventHandler(MouseEvent.MOUSE_DRAGGED, draggedHandler);
    imageView.addEventHandler(MouseEvent.MOUSE_RELEASED, releasedHandler);

    if (Platform.isDesktop()) {
        imageView.addEventHandler(ScrollEvent.ANY, scrollHandler);
    } else {
        imageView.addEventHandler(ZoomEvent.ZOOM_STARTED, zoomStartedHandler);
        imageView.addEventHandler(ZoomEvent.ZOOM_FINISHED, zoomFinishedHandler);
        imageView.addEventHandler(ZoomEvent.ZOOM, zoomHandler);
    }
    imageView.addEventHandler(MouseEvent.MOUSE_CLICKED, clickedHandler);
}
项目:javaone2016    文件:ExhibitionMapPresenter.java   
private void removeListeners() {
    imageView.removeEventHandler(MouseEvent.MOUSE_PRESSED, pressedHandler);
    imageView.removeEventHandler(MouseEvent.MOUSE_DRAGGED, draggedHandler);
    imageView.removeEventHandler(MouseEvent.MOUSE_RELEASED, releasedHandler);
    if (Platform.isDesktop()) {
        imageView.removeEventHandler(ScrollEvent.ANY, scrollHandler);
    } else {
        imageView.removeEventHandler(ZoomEvent.ZOOM_STARTED, zoomStartedHandler);
        imageView.removeEventHandler(ZoomEvent.ZOOM_FINISHED, zoomFinishedHandler);
        imageView.removeEventHandler(ZoomEvent.ZOOM, zoomHandler);
    }
    imageView.removeEventHandler(MouseEvent.MOUSE_CLICKED, clickedHandler);
}
项目:zorkClone    文件:EditorView.java   
@FXML
void scrollPaneOnZoom(ZoomEvent event) {
    FOKLogger.fine(MainWindow.class.getName(), "Zooming in view, new Zoom level: " + event.getZoomFactor());
    drawing.setScaleX(drawing.getScaleX() * event.getZoomFactor());
    drawing.setScaleY(drawing.getScaleY() * event.getZoomFactor());
    // TODO: Update the actual size in the scrollpane (so that scrollbars appear when zooming in
    // TODO: Add Keyboard and touchpad zoom
    // TODO: do the zoom with the right zoom center
}
项目:kelvin-maps    文件:ChartController.java   
/**
 * On zoom event.
 *
 * @param e The zoom event.
 */
@FXML
private void onZoom(final ZoomEvent e) {
  this.chart.zoom(
    e.getZoomFactor(),
    this.initialMouseScrollX,
    this.initialMouseScrollY
  );
}
项目:tokentool    文件:TokenTool_Controller.java   
@FXML
void compositeTokenPane_OnZoom(ZoomEvent event) {
    Double scale = portraitImageView.getScaleY() * event.getZoomFactor();

    portraitImageView.setScaleX(scale);
    portraitImageView.setScaleY(scale);
}
项目:candlelight    文件:Baron.java   
public static void initialize(ViewPort view, InputHandler input, RenderHandler render, Stage primaryStage) throws Exception
{
    final ResizeableLayeredCanvasPane canvasPane = new ResizeableLayeredCanvasPane(
            render.getNumOfLayers(), 640, 480);

    canvasPane.setFocusTraversable(true);
    canvasPane.addEventHandler(MouseEvent.MOUSE_MOVED, event ->
            view.setCursorPosition(event.getX(), event.getY()));
    canvasPane.addEventHandler(MouseEvent.MOUSE_DRAGGED, event ->
            view.setCursorPosition(event.getX(), event.getY()));
    canvasPane.addEventHandler(MouseEvent.MOUSE_PRESSED, event ->
            view.setCursorDown(true));
    canvasPane.addEventHandler(MouseEvent.MOUSE_RELEASED, event ->
            view.setCursorDown(false));
    canvasPane.addEventHandler(ScrollEvent.SCROLL, event ->
            view.move(event.getDeltaX(), event.getDeltaY()));
    canvasPane.addEventHandler(ZoomEvent.ZOOM, event ->
            view.zoom(event.getZoomFactor()));
    canvasPane.addEventFilter(KeyEvent.KEY_PRESSED, event ->
            input.onInput(event.getCode()));

    final BorderPane root = new BorderPane(canvasPane);
    final AnimationTimer timer = new AnimationTimer()
    {
        @Override
        public void handle(long now)
        {
            render.onDraw(primaryStage, canvasPane, view);
        }
    };

    Scene scene = new Scene(root);
    scene.setFill(Color.WHITE);
    primaryStage.setScene(scene);
    primaryStage.setTitle("Application");
    primaryStage.show();

    render.onLoad(primaryStage, canvasPane, view);

    timer.start();
}
项目:truffle-hog    文件:FxUtils.java   
public static void zoom(Node node, ZoomEvent event) {
    zoom(node, event.getZoomFactor(), event.getSceneX(), event.getSceneY());
}
项目:FollowTheBitcoin    文件:ZoomPane.java   
public void zooming(ZoomEvent ze) {
    zoom(ze.getTotalZoomFactor(), ze.getX(), ze.getY());
}
项目: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;
}
项目:Augendiagnose    文件:SizableImageView.java   
/**
 * Handle a zoom event.
 *
 * @param event
 *            The zoom event.
 */
private void handleZoomEvent(final ZoomEvent event) {
    if (!Double.isNaN(event.getZoomFactor())) {
        zoomImage(event.getZoomFactor());
    }
}