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


Java ScrollEvent类代码示例

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


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

示例1: makeZoomable

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
public void makeZoomable(Scene scene4EventFilter, Node control4Scaling) {
    scene4EventFilter.addEventFilter(ScrollEvent.ANY, (ScrollEvent event) -> {
        double delta = 1.2;
        double scale = control4Scaling.getScaleX();

        if (ObjectUtils.smallerDoublePrecision(event.getDeltaY(), 0)) {
            scale /= delta;
        } else {
            scale *= delta;
        }

        if (scale < MIN_SCALE || scale > MAX_SCALE) {
            scale = scale < MIN_SCALE ? MIN_SCALE : MAX_SCALE;
        }

        control4Scaling.setScaleX(scale);
        control4Scaling.setScaleY(scale);

        event.consume();
    });
}
 
开发者ID:adihubba,项目名称:javafx-3d-surface-chart,代码行数:22,代码来源:Mesh3DChartPanel.java

示例2: changeHiddenPower

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
public void changeHiddenPower(Event event) {
    if (event instanceof MouseEvent) {
        MouseEvent mouseEvent = (MouseEvent) event;
        MouseButton mouseButton = mouseEvent.getButton();
        if (mouseEvent.isShiftDown() || mouseButton.equals(MouseButton.SECONDARY)) {
            pokemon.setHiddenPower(hiddenPowerCalculator.updateToNext());
        } else if (mouseButton.equals(MouseButton.PRIMARY)) {
            pokemon.setHiddenPower(hiddenPowerCalculator.updateToPrevious());
        } else if (mouseButton.equals(MouseButton.MIDDLE)) {
            pokemon.setHiddenPower(hiddenPowerCalculator.setUnknown());
        }
    } else if (event instanceof ScrollEvent) {
        double delta = ((ScrollEvent) event).getDeltaY();
        if (delta > 0) {
            pokemon.setHiddenPower(hiddenPowerCalculator.updateToNext());
        } else if (delta < 0) {
            pokemon.setHiddenPower(hiddenPowerCalculator.updateToPrevious());
        }
    }
}
 
开发者ID:wartab,项目名称:gen7-iv-calculator,代码行数:21,代码来源:OutputPresenter.java

示例3: handleZoomable

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (canvas.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (canvas.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
开发者ID:jfree,项目名称:jfreechart-fx,代码行数:32,代码来源:ScrollHandlerFX.java

示例4: setupInterface

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
/**
 * Creates the canvas for scrolling and panning.
 *
 * @param primaryStage - Stage as given by the start method
 */
private void setupInterface(Stage primaryStage) {
    root = new Group();

    primaryStage.setTitle("Drone simulator");
    primaryStage.setResizable(false);
    primaryStage.setOnCloseRequest(onCloseEventHandler);

    Runtime.getRuntime().addShutdownHook(new Thread(() -> onCloseEventHandler.handle(null)));

    // create canvas
    canvas = new PannableCanvas(Settings.CANVAS_WIDTH, Settings.CANVAS_HEIGHT);
    canvas.setId("pane");
    canvas.setTranslateX(0);
    canvas.setTranslateY(0);

    root.getChildren().add(canvas);

    double width = Settings.SCENE_WIDTH > Settings.CANVAS_WIDTH ? Settings.CANVAS_WIDTH : Settings.SCENE_WIDTH;
    double height = Settings.SCENE_HEIGHT > Settings.CANVAS_HEIGHT ? Settings.CANVAS_HEIGHT : Settings.SCENE_HEIGHT;

    // create scene which can be dragged and zoomed
    Scene scene = new Scene(root, width, height);
    SceneGestures sceneGestures = new SceneGestures(canvas);
    scene.addEventFilter(MouseEvent.MOUSE_PRESSED, sceneGestures.getOnMousePressedEventHandler());
    scene.addEventFilter(MouseEvent.MOUSE_DRAGGED, sceneGestures.getOnMouseDraggedEventHandler());
    scene.addEventFilter(ScrollEvent.ANY, sceneGestures.getOnScrollEventHandler());
    scene.getStylesheets().addAll(this.getClass().getResource("/style.css").toExternalForm());

    primaryStage.setScene(scene);
    primaryStage.show();
    canvas.addGrid();
}
 
开发者ID:INAETICS,项目名称:Drones-Simulator,代码行数:38,代码来源:Game.java

示例5: handle

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
/**
 * Zooms the canvas to the mouse pointer
 * @param event
 */
@Override
public void handle(ScrollEvent event) {
    double delta = 1.2;
    double scale = canvas.getScale(); // currently we only use Y, same value is used for X
    double oldScale = scale;

    if (event.getDeltaY() < 0) {
        scale /= delta;
    } else {
        scale *= delta;
    }
    scale = clamp(scale, MIN_SCALE, MAX_SCALE);

    double f = (scale / oldScale) - 1;
    double dx = (event.getSceneX() - (canvas.getBoundsInParent().getWidth() / 2 + canvas.getBoundsInParent().getMinX()));
    double dy = (event.getSceneY() - (canvas.getBoundsInParent().getHeight() / 2 + canvas.getBoundsInParent().getMinY()));

    canvas.setScale(scale);
    canvas.setPivot(f * dx, f * dy);
    canvas.setTranslateX(clamp(canvas.getTranslateX(), minX(), maxX()));
    canvas.setTranslateY(clamp(canvas.getTranslateX(), minY(), maxY()));

    event.consume();
}
 
开发者ID:INAETICS,项目名称:Drones-Simulator,代码行数:29,代码来源:SceneGestures.java

示例6: registerListeners

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
 
开发者ID:HanSolo,项目名称:worldheatmap,代码行数:17,代码来源:World.java

示例7: processScroll

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
/**
 * The process of scrolling value.
 */
private void processScroll(@NotNull final ScrollEvent event) {
    if (!event.isControlDown()) return;

    final TextField source = (TextField) event.getSource();
    final String text = source.getText();

    float value;
    try {
        value = parseFloat(text);
    } catch (final NumberFormatException e) {
        return;
    }

    long longValue = (long) (value * 1000);
    longValue += event.getDeltaY() * 1;

    final String result = String.valueOf(max(min(longValue / 1000F, 1F), 0F));
    source.setText(result);
    source.positionCaret(result.length());

    processChange((KeyEvent) null);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:26,代码来源:AlphaInterpolationElement.java

示例8: setOnScrollListener

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
/**
 * Enables handling of scroll and mouse wheel events for the node.
 * This type of events has a peculiarity on Windows. See the javadoc of notifyScrollEvents for more information.
 * @see #notifyScrollEvent
 * @param intersectionTestFunc a function that takes an event object and must return boolean
 * @return itself to let you use a chain of calls
 */
MouseEventNotificator setOnScrollListener(Function<NativeMouseWheelEvent, Boolean> intersectionTestFunc) {
    if (SystemUtils.IS_OS_WINDOWS) {
        if (!GlobalScreen.isNativeHookRegistered()) {
            try {
                GlobalScreen.registerNativeHook();
            } catch (NativeHookException | UnsatisfiedLinkError e) {
                e.printStackTrace();
                Main.log("Failed to initialize the native hooking. Rolling back to using JavaFX events...");
                sender.addEventFilter(ScrollEvent.SCROLL, this::notifyScrollEvent);
                return this;
            }
        }
        mouseWheelListener = event -> notifyScrollEvent(event, intersectionTestFunc);
        GlobalScreen.addNativeMouseWheelListener(mouseWheelListener);
    } else {
        sender.addEventFilter(ScrollEvent.SCROLL, this::notifyScrollEvent);
    }

    return this;
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:28,代码来源:MouseEventNotificator.java

示例9: handleZoomable

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
/**
 * Handle the case where a plot implements the {@link Zoomable} interface.
 *
 * @param zoomable  the zoomable plot.
 * @param e  the mouse wheel event.
 */
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, 
        ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = canvas.getRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = new Point2D.Double(e.getX(), e.getY());
    if (pinfo.getDataArea().contains(p)) {
        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
        boolean notifyState = plot.isNotify();
        plot.setNotify(false);
        int clicks = (int) e.getDeltaY();
        double zf = 1.0 + this.zoomFactor;
        if (clicks < 0) {
            zf = 1.0 / zf;
        }
        if (true) { //this.chartPanel.isDomainZoomable()) {
            zoomable.zoomDomainAxes(zf, pinfo, p, true);
        }
        if (true) { //this.chartPanel.isRangeZoomable()) {
            zoomable.zoomRangeAxes(zf, pinfo, p, true);
        }
        plot.setNotify(notifyState);  // this generates the change event too
    } 
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:32,代码来源:ScrollHandlerFX.java

示例10: handleScroll

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
protected void handleScroll(ScrollEvent ev)
{
	if(ev.isShiftDown())
	{
		// TODO horizontal scroll perhaps?
		D.print("horizontal scroll", ev.getDeltaX());
	}
	else if(ev.isShortcutDown())
	{
		// page up / page down
		if(ev.getDeltaY() >= 0)
		{
			editor.pageUp();
		}
		else
		{
			editor.pageDown();
		}
	}
	else
	{
		// vertical block scroll
		editor.blockScroll(ev.getDeltaY() >= 0);
	}
}
 
开发者ID:andy-goryachev,项目名称:FxEditor,代码行数:26,代码来源:FxEditorMouseHandler.java

示例11: setupListeners

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
private void setupListeners() {
    ObjectProperty<Point2D> mouseDown = new SimpleObjectProperty<>();

    EventStreams.eventsOf(imageView, MouseEvent.MOUSE_PRESSED).subscribe(e -> {
        Point2D mousePress = imageViewToImage(new Point2D(e.getX(), e.getY()));
        mouseDown.set(mousePress);
    });

    EventStreams.eventsOf(imageView, MouseEvent.MOUSE_DRAGGED).subscribe(e -> {
        Point2D dragPoint = imageViewToImage(new Point2D(e.getX(), e.getY()));
        shift(dragPoint.subtract(mouseDown.get()));
        mouseDown.set(imageViewToImage(new Point2D(e.getX(), e.getY())));
    });

    EventStream<ScrollEvent> scrollEvents = EventStreams.eventsOf(imageView, ScrollEvent.SCROLL);
    EventStream<ScrollEvent> scrollEventsUp = scrollEvents.filter(scrollEvent -> scrollEvent.getDeltaY() < 0);
    EventStream<ScrollEvent> scrollEventsDown = scrollEvents.filter(scrollEvent -> scrollEvent.getDeltaY() > 0);
    scrollEventsUp.subscribe(scrollEvent -> scale = Math.min(scale + 0.25, 3));
    scrollEventsDown.subscribe(scrollEvent -> scale = Math.max(scale - 0.25, 0.25));
    EventStreams.merge(scrollEventsUp, scrollEventsDown).subscribe(scrollEvent -> scaleImageViewport(scale));

    EventStreams.eventsOf(imageView, MouseEvent.MOUSE_CLICKED)
            .filter(mouseEvent -> mouseEvent.getClickCount() == 2)
            .subscribe(mouseEvent -> fitToView());
}
 
开发者ID:cameronleger,项目名称:neural-style-gui,代码行数:26,代码来源:MovingImageView.java

示例12: onScroll

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
@Test(timeout = 60000)
public void onScroll() {
    if (control.getProcessedEvents().contains(ScrollEvent.class)) {
        test(EventTypes.SCROLL, new Command() {

            public void invoke() {
                new GetAction<Object>() {
                    @Override
                    public void run(Object... os) throws Exception {
                        primeDock.mouse().move();
                        primeDock.mouse().turnWheel(1);
                    }
                }.dispatch(Root.ROOT.getEnvironment());
            }
        });
    }
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:18,代码来源:EventTestCommon.java

示例13: handle

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
@Override
public void handle(ScrollEvent event) {
	event.consume();

	double deltaY = event.getDeltaY();
	double deltaX = event.getDeltaX();

	if (deltaY < 0) {
		scrollPane.setHvalue(Math.min(1, scrollPane.getHvalue() + 0.0007));
	} else if (deltaY > 0) {
		scrollPane.setHvalue(Math.max(0, scrollPane.getHvalue() - 0.0007));
	}
	if (deltaX < 0) {
		scrollPane.setVvalue(Math.min(1, scrollPane.getVvalue() + 0.05));
	} else if (deltaX > 0) {
		scrollPane.setVvalue(Math.max(0, scrollPane.getVvalue() - 0.05));
	}
	
}
 
开发者ID:ProgrammingLife2016,项目名称:PL3-2016,代码行数:20,代码来源:AnnotationController.java

示例14: initialize

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
/**
	 * Initialize fxml file.
	 */
	@Override
	public void initialize(URL arg0, ResourceBundle arg1) {
		scrollPane.addEventFilter(ScrollEvent.ANY, scrollEventHandler);
		loadData();
		pane.boundsInParentProperty().addListener((observable, oldValue, newValue) -> {
		    scrollPane.setPrefWidth(newValue.getWidth());
		    scrollPane.setPrefHeight(newValue.getHeight());
		});
		scrollPane.setHvalue(0);
		scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
		innerGroup = getAnnotations();
//		innerGroup.scaleYProperty().bind(scrollPane.heightProperty().divide(innerGroup.getBoundsInLocal().getHeight()));
		outerGroup = new Group(innerGroup);
		scrollPane.setContent(outerGroup);
	}
 
开发者ID:ProgrammingLife2016,项目名称:PL3-2016,代码行数:19,代码来源:AnnotationController.java

示例15: mouseWheelMoved

import javafx.scene.input.ScrollEvent; //导入依赖的package包/类
public void mouseWheelMoved(ScrollEvent e) {

		double scaledDeltaY = e.getDeltaY() > 0 ? -1 : 1;
		double formerZoom = zoom;
		zoom -= scaledDeltaY;
		zoom = zoom <= 1 ? 1 : zoom;

		double deltaX = deltaStart.getX() - delta.getX();
		double deltaY = deltaStart.getY() - delta.getY();

		double projX = (e.getX() + deltaX) / (formerZoom * zoomFactor);
		double projY = (e.getY() + deltaY) / (formerZoom * zoomFactor);

		double newPointX = (projX * zoom * zoomFactor) - deltaX;
		double newPointY = (projY * zoom * zoomFactor) - deltaY;

		setDeltaStart(new Point((int) newPointX, (int) newPointY));
		delta = new Point((int) e.getX(), (int) e.getY());
	}
 
开发者ID:MayerTh,项目名称:RVRPSimulator,代码行数:20,代码来源:TransformationManager.java


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