javafx.scene.input.ScrollEvent Java Examples

The following examples show how to use javafx.scene.input.ScrollEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlotCanvasBase.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Zoom in/out triggered by mouse wheel
 *  @param event Scroll event
 */
protected void wheelZoom(final ScrollEvent event)
{
    // Invoked by mouse scroll wheel.
    // Only allow zoom (with control), not pan.
    if (! event.isControlDown())
        return;

    if (event.getDeltaY() > 0)
        zoomInOut(event.getX(), event.getY(), 1.0/ZOOM_FACTOR);
    else if (event.getDeltaY() < 0)
        zoomInOut(event.getX(), event.getY(), ZOOM_FACTOR);
    else
        return;
    event.consume();
}
 
Example #2
Source File: ScrollHandlerFX.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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
    } 
}
 
Example #3
Source File: MovingImageView.java    From neural-style-gui with GNU General Public License v3.0 6 votes vote down vote up
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());
}
 
Example #4
Source File: Fx3DStageController.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param event
 *            Zooms in and out when the mouse is scrolled.
 */
public void onScrollHandler(ScrollEvent event) {
    double delta = 1.2;
    double scale = (plot.getScaleX());

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

    scale = clamp(scale, MIN_SCALE, MAX_SCALE);

    plot.setScaleX(scale);
    plot.setScaleY(scale);

    event.consume();
}
 
Example #5
Source File: ScrollHandlerFX.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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
    } 
}
 
Example #6
Source File: ScrollGesture.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 *
 * @param viewer
 *            The {@link IViewer}
 * @return An {@link EventHandler} for {@link ScrollEvent}.
 */
protected EventHandler<ScrollEvent> createScrollFilter(
		final IViewer viewer) {
	return new EventHandler<ScrollEvent>() {
		@Override
		public void handle(ScrollEvent event) {
			if (!(event.getTarget() instanceof Node)
					|| PartUtils.retrieveViewer(getDomain(),
							(Node) event.getTarget()) != viewer) {
				return;
			}
			playFinishDelayTransition(viewer);
			if (!inScroll.contains(viewer)) {
				inScroll.add(viewer);
				scrollStarted(viewer, event);
			} else {
				scroll(viewer, event);
			}
		}
	};
}
 
Example #7
Source File: MouseEventNotificator.java    From DeskChan with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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
 */
public 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;
}
 
Example #8
Source File: World.java    From charts with Apache License 2.0 6 votes vote down vote up
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()));
            }
        });
    });
}
 
Example #9
Source File: Fx3DStageController.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param event Zooms in and out when the mouse is scrolled.
 */
public void onScrollHandler(ScrollEvent event) {
  double delta = 1.2;
  double scale = (plot.getScaleX());

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

  scale = clamp(scale, MIN_SCALE, MAX_SCALE);

  plot.setScaleX(scale);
  plot.setScaleY(scale);

  event.consume();
}
 
Example #10
Source File: TaScrollHandlerFX.java    From TAcharting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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(TaChartCanvas canvas, Zoomable zoomable,
                            ScrollEvent e) {
    // don't zoom unless the mouse pointer is in the plot's org.sjwimmer.tacharting.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
    }
}
 
Example #11
Source File: ScrollHandlerFX.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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
    } 
}
 
Example #12
Source File: ScrollHandlerFX.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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
    } 
}
 
Example #13
Source File: ScrollHandlerFX.java    From jfreechart-fx with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void handleScroll(ChartCanvas canvas, ScrollEvent e) {
    JFreeChart chart = canvas.getChart();
    if (chart == null) {
        return;
    }
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(canvas, zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation((int) e.getDeltaY());
    }
}
 
Example #14
Source File: CellListManager.java    From Flowless with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private C cellForItem(T item) {
    C cell = cellPool.getCell(item);

    // apply CSS when the cell is first added to the scene
    Node node = cell.getNode();
    EventStreams.nonNullValuesOf(node.sceneProperty())
            .subscribeForOne(scene -> {
                node.applyCss();
            });

    // Make cell initially invisible.
    // It will be made visible when it is positioned.
    node.setVisible(false);

    if (cell.isReusable()) {
        // if cell is reused i think adding event handler
        // would cause resource leakage.
        node.setOnScroll(this::pushScrollEvent);
        node.setOnScrollStarted(this::pushScrollEvent);
        node.setOnScrollFinished(this::pushScrollEvent);
    } else {
        node.addEventHandler(ScrollEvent.ANY, this::pushScrollEvent);
    }

    return cell;
}
 
Example #15
Source File: ScrollHandlerFX.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * 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
    } 
}
 
Example #16
Source File: FXCanvasEx.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private void sendScrollEventToFX(EventType<ScrollEvent> eventType,
		double scrollX, double scrollY, int x, int y, int stateMask,
		boolean inertia) {
	// up to and including SWT 4.5, direction was inverted for pan
	// gestures on the Mac
	// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=481331)
	final double multiplier = ("cocoa".equals(SWT.getPlatform())
			&& SWT.getVersion() < 4600) ? -5.0 : 5.0;

	if (eventType == ScrollEvent.SCROLL_STARTED) {
		totalScrollX = 0;
		totalScrollY = 0;
	} else if (inertia) {
		// inertia events do not belong to the gesture,
		// thus total scroll is not accumulated
		totalScrollX = scrollX;
		totalScrollY = scrollY;
	} else {
		// accumulate total scroll as long as the gesture occurs
		totalScrollX += scrollX;
		totalScrollY += scrollY;
	}

	final Point los = toDisplay(x, y);
	scheduleSceneRunnable(new ISceneRunnable() {
		@Override
		public void run(TKSceneListenerWrapper sceneListener) {
			sceneListener.scrollEvent(eventType, scrollX, scrollY,
					totalScrollX, totalScrollY, multiplier, multiplier,
					0, 0, 0, 0, 0, x, y, los.x, los.y,
					(stateMask & SWT.SHIFT) != 0,
					(stateMask & SWT.CONTROL) != 0,
					(stateMask & SWT.ALT) != 0,
					(stateMask & SWT.COMMAND) != 0, false, inertia);
		}
	});
}
 
Example #17
Source File: ChartGestureMouseAdapterFX.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handles a scroll event. This implementation does nothing, override the method if required.
 * 
 * @param canvas the canvas ({@code null} not permitted).
 * @param e the event ({@code null} not permitted).
 */
@Override
public void handleScroll(ChartCanvas chartPanel, ScrollEvent eOrig) {
  if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.MOUSE_WHEEL))
    return;

  MouseEventWrapper e = new MouseEventWrapper(eOrig);
  ChartEntity entity = findChartEntity(e);
  ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
  Button button = Button.getButton(e.getButton());

  // handle event
  handleEvent(new ChartGestureEvent(cw, e, entity,
      new ChartGesture(gestureEntity, Event.MOUSE_WHEEL, button)));
}
 
Example #18
Source File: PanOrZoomOnScrollHandler.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void scroll(ScrollEvent event) {
	// each event is tested for suitability so that you can switch between
	// multiple scroll actions instantly when pressing/releasing modifiers
	if (isPan(event)) {
		pan(event);
	} else if (isZoom(event)) {
		zoom(event);
	}
}
 
Example #19
Source File: FXCanvasEx.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void handleEvent(org.eclipse.swt.widgets.Event e) {
	if (!gestureActive
			&& (!panGestureInertiaActive || lastGestureEvent == null
					|| e.time != lastGestureEvent.time)) {
		if (e.type == SWT.MouseVerticalWheel) {
			sendScrollEventToFX(ScrollEvent.SCROLL, 0,
					e.count > 0 ? 1 : -1, e.x, e.y, e.stateMask);
		} else {
			sendScrollEventToFX(ScrollEvent.SCROLL,
					e.count > 0 ? 1 : -1, 0, e.x, e.y, e.stateMask);
		}
	}
}
 
Example #20
Source File: MnistImageView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void removeListeners() {
    this.removeEventHandler(MouseEvent.MOUSE_PRESSED, pressedHandler);
    this.removeEventHandler(MouseEvent.MOUSE_DRAGGED, draggedHandler);
    this.removeEventHandler(MouseEvent.MOUSE_RELEASED, releasedHandler);
    if (Platform.isDesktop()) {
        this.removeEventHandler(ScrollEvent.ANY, scrollHandler);
    } else {
        this.removeEventHandler(ZoomEvent.ZOOM_STARTED, zoomStartedHandler);
        this.removeEventHandler(ZoomEvent.ZOOM_FINISHED, zoomFinishedHandler);
        this.removeEventHandler(ZoomEvent.ZOOM, zoomHandler);
    }
}
 
Example #21
Source File: PanOrZoomOnScrollHandler.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void startScroll(ScrollEvent event) {
	this.viewportPolicy = determineViewportPolicy();
	init(viewportPolicy);
	// delegate to scroll() to perform panning/zooming
	scroll(event);
}
 
Example #22
Source File: PanOrZoomOnScrollHandler.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Performs zooming according to the given {@link ScrollEvent}.
 *
 * @param event
 *            The {@link ScrollEvent} according to which zooming is
 *            performed.
 */
protected void zoom(ScrollEvent event) {
	// compute zoom factor from the given event
	double zoomFactor = computeZoomFactor(event);
	if (isContentRestricted()) {
		// Ensure content is aligned with the viewport on the left and top
		// sides if there is free space on these sides and the content fits
		// into the viewport
		panningSupport.removeFreeSpace(viewportPolicy, Pos.TOP_LEFT, true);
		// calculate a pivot points to achieve a zooming similar to that of
		// a text editor (fix absolute content left in x-direction, fix
		// visible content top in y-direction)
		InfiniteCanvas infiniteCanvas = (InfiniteCanvas) getHost().getRoot()
				.getViewer().getCanvas();
		// XXX: The pivot point computation needs to be done after free
		// space top/left is removed so that the content-bounds minX
		// coordinate is correct.
		Point2D pivotPointInScene = infiniteCanvas.localToScene(
				infiniteCanvas.getContentBounds().getMinX(), 0);
		// performing zooming
		viewportPolicy.zoom(true, true, zoomFactor,
				pivotPointInScene.getX(), pivotPointInScene.getY());
		// Ensure content is aligned with the viewport on the right and
		// bottom sides if there is free space on these sides and the
		// content does not fit into the viewport
		panningSupport.removeFreeSpace(viewportPolicy, Pos.BOTTOM_RIGHT,
				false);
	} else {
		// zoom into/out-of the event location
		viewportPolicy.zoom(true, true, zoomFactor, event.getSceneX(),
				event.getSceneY());
	}
}
 
Example #23
Source File: ChartCanvas.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Handles a scroll event by passing it on to the registered handlers.
 * 
 * @param e  the scroll event.
 */
protected void handleScroll(ScrollEvent e) {
    if (this.liveHandler != null && this.liveHandler.isEnabled()) {
        this.liveHandler.handleScroll(this, e);
    }
    for (MouseHandlerFX handler: this.auxiliaryMouseHandlers) {
        if (handler.isEnabled()) {
            handler.handleScroll(this, e);
        }
    }
}
 
Example #24
Source File: MnistImageView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void addListeners() {
    this.addEventHandler(MouseEvent.MOUSE_PRESSED, pressedHandler);
    this.addEventHandler(MouseEvent.MOUSE_DRAGGED, draggedHandler);
    this.addEventHandler(MouseEvent.MOUSE_RELEASED, releasedHandler);
    
    if (Platform.isDesktop()) {
        this.addEventHandler(ScrollEvent.ANY, scrollHandler);
    } else {
        this.addEventHandler(ZoomEvent.ZOOM_STARTED, zoomStartedHandler);
        this.addEventHandler(ZoomEvent.ZOOM_FINISHED, zoomFinishedHandler);
        this.addEventHandler(ZoomEvent.ZOOM, zoomHandler);
    }
}
 
Example #25
Source File: ScrollGesture.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Callback method that is invoked for the first {@link ScrollEvent} of a
 * scroll gesture.
 *
 * @param viewer
 *            The {@link IViewer}.
 * @param event
 *            The corresponding {@link ScrollEvent}.
 */
protected void scrollStarted(IViewer viewer, ScrollEvent event) {
	EventTarget eventTarget = event.getTarget();
	getDomain().openExecutionTransaction(ScrollGesture.this);
	setActiveHandlers(viewer,
			getHandlerResolver().resolve(ScrollGesture.this,
					eventTarget instanceof Node ? (Node) eventTarget : null,
					viewer, ON_SCROLL_POLICY_KEY));
	for (IOnScrollHandler policy : getActiveHandlers(viewer)) {
		policy.startScroll(event);
	}
}
 
Example #26
Source File: ScrollHandlerFX.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void handleScroll(ChartCanvas canvas, ScrollEvent e) {
    JFreeChart chart = canvas.getChart();
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(canvas, zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation((int) e.getDeltaY());
    }
}
 
Example #27
Source File: ScrollHandlerFX.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handleScroll(ChartCanvas canvas, ScrollEvent e) {
    JFreeChart chart = canvas.getChart();
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(canvas, zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation((int) e.getDeltaY());
    }
}
 
Example #28
Source File: ChartCanvas.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Handles a scroll event by passing it on to the registered handlers.
 * 
 * @param e  the scroll event.
 */
protected void handleScroll(ScrollEvent e) {
    if (this.liveHandler != null && this.liveHandler.isEnabled()) {
        this.liveHandler.handleScroll(this, e);
    }
    for (MouseHandlerFX handler: this.auxiliaryMouseHandlers) {
        if (handler.isEnabled()) {
            handler.handleScroll(this, e);
        }
    }
}
 
Example #29
Source File: MouseEventNotificator.java    From DeskChan with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Removes all event listeners that were set earlier.
 */
public void cleanListeners() {
    // All methods have their own internal checks for the case when a filter is not set and equals null.
    sender.removeEventFilter(MouseEvent.MOUSE_CLICKED, this::notifyClickEvent);
    sender.removeEventFilter(ScrollEvent.SCROLL, this::notifyScrollEvent);
    if (SystemUtils.IS_OS_WINDOWS) {
        GlobalScreen.removeNativeMouseWheelListener(mouseWheelListener);
    }
}
 
Example #30
Source File: ScrollHandlerFX.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handleScroll(ChartCanvas canvas, ScrollEvent e) {
    JFreeChart chart = canvas.getChart();
    Plot plot = chart.getPlot();
    if (plot instanceof Zoomable) {
        Zoomable zoomable = (Zoomable) plot;
        handleZoomable(canvas, zoomable, e);
    }
    else if (plot instanceof PiePlot) {
        PiePlot pp = (PiePlot) plot;
        pp.handleMouseWheelRotation((int) e.getDeltaY());
    }
}