Java 类javafx.scene.input.ScrollEvent 实例源码
项目:javafx-3d-surface-chart
文件:Mesh3DChartPanel.java
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();
});
}
项目:gen7-iv-calculator
文件:OutputPresenter.java
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());
}
}
}
项目:jfreechart-fx
文件:ScrollHandlerFX.java
/**
* 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
}
}
项目:Drones-Simulator
文件:Game.java
/**
* 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();
}
项目:Drones-Simulator
文件:SceneGestures.java
/**
* 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();
}
项目:worldheatmap
文件:World.java
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()));
}
});
});
}
项目:charts
文件:World.java
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()));
}
});
});
}
项目:jmonkeybuilder
文件:AlphaInterpolationElement.java
/**
* 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);
}
项目:DeskChan
文件:MouseEventNotificator.java
/**
* 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;
}
项目:ccu-historian
文件:ScrollHandlerFX.java
/**
* 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
}
}
项目:Paradinc-FX
文件:World.java
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()));
}
});
});
}
项目:FxEditor
文件:FxEditorMouseHandler.java
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);
}
}
项目:worldfx
文件:World.java
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()));
}
});
});
}
项目:neural-style-gui
文件:MovingImageView.java
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());
}
项目:aya-lang
文件:ScrollHandlerFX.java
/**
* 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
}
}
项目:openjfx-8u-dev-tests
文件:EventTestCommon.java
@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());
}
});
}
}
项目:PL3-2016
文件:AnnotationController.java
@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));
}
}
项目:PL3-2016
文件:AnnotationController.java
/**
* 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);
}
项目:RVRPSimulator
文件:TransformationManager.java
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());
}
项目:build-hotspots
文件:BuildHotspotsApplicationBase.java
@Override
public void handle(ScrollEvent scrollEvent) {
if (scrollEvent.isControlDown()) {
Point2D mousePos = new Point2D(scrollEvent.getSceneX(), scrollEvent.getSceneY());
Point2D scenePositionToCentreZoomAround = m_root.sceneToLocal(new Point2D(scrollEvent.getSceneX(), scrollEvent.getSceneY()));
final double scale = calculateScale(scrollEvent);
m_root.setScaleX(scale);
m_root.setScaleY(scale);
scrollTo(mousePos, scenePositionToCentreZoomAround);
scrollEvent.consume();
}
}
项目:JavaFXUtils
文件:Zoomer.java
@Override
public void mount(){
EventHandler<? super ScrollEvent> oldHandler = pane.getOnScroll();
EventHandler<? super ScrollEvent> newHandler = (event)->{
if (event.isControlDown() == controlPressed) {
double scale = pane.getScaleX() + event.getDeltaY() / zoomFactor;
if (scale <= min)
scale = min;
if (scale >= max)
scale = max;
pane.setScaleX(scale);
pane.setScaleY(scale);
event.consume();
}
};
Utils.chain(oldHandler, newHandler);
pane.setOnScroll(newHandler);
}
项目:populus
文件:ScrollHandlerFX.java
/**
* 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
}
}
项目:org.csstudio.display.builder
文件:PlotCanvasBase.java
/** 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();
}
项目:ECG-Viewer
文件:ScrollHandlerFX.java
/**
* 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
}
}
项目:group-five
文件:ScrollHandlerFX.java
/**
* 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
}
}
项目:Moduro-Toolbox
文件:ScrollHandlerFX.java
/**
* 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
}
}
项目:FollowTheBitcoin
文件:ZoomPane.java
public void scrolling(ScrollEvent se) {
double clickCount;
if (se.getTouchCount() == 0) {
finish();
clickCount = Math.signum(se.getDeltaY())*4;
} else {
if (!set) {
start(se.getX(), se.getY());
}
if (se.isInertia()) return; // inertia tends to cause crazy zooms
clickCount = se.getTotalDeltaY() / se.getMultiplierY();
}
zoom(Math.pow(scrollScaleFactor, clickCount),
se.getX(), se.getY());
}
项目:buffer_bci
文件:ScrollHandlerFX.java
/**
* 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
}
}
项目:buffer_bci
文件:ScrollHandlerFX.java
/**
* 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
}
}
项目: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
}
项目:hygene
文件:GraphController.java
/**
* When the user starts scrolling on the graph.
*
* @param scrollEvent {@link ScrollEvent} associated with the event
*/
@FXML
void onScrollStarted(final ScrollEvent scrollEvent) {
((Node) scrollEvent.getSource()).getScene().setCursor(Cursor.CROSSHAIR);
scrollEvent.consume();
}
项目:hygene
文件:GraphController.java
/**
* When the user scroll on the graph.
*
* @param scrollEvent {@link ScrollEvent} associated with the event
*/
@FXML
void onScroll(final ScrollEvent scrollEvent) {
graphMovementCalculator.onScroll(-scrollEvent.getDeltaY());
scrollEvent.consume();
}
项目:hygene
文件:GraphController.java
/**
* When the user finished scrolling.
*
* @param scrollEvent {@link ScrollEvent} associated with the event
*/
@FXML
void onScrollFinished(final ScrollEvent scrollEvent) {
((Node) scrollEvent.getSource()).getScene().setCursor(Cursor.DEFAULT);
scrollEvent.consume();
}
项目:jfreechart-fx
文件:ChartCanvas.java
/**
* 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);
}
}
}
项目:jfreechart-fx
文件:ScrollHandlerFX.java
@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());
}
}
项目:Curriculum-design-of-data-structure
文件:HuffmanController.java
public void bindHboxEvents(){
hbox.setOnScroll(new EventHandler<ScrollEvent>() {
@Override
public void handle(ScrollEvent event) {
if(hbox.getLayoutX() >= -850)
hbox.setLayoutX(hbox.getLayoutX() - 100);
else{
hbox.setLayoutX(50);
}
System.out.println(hbox.getLayoutX());
}
});
}
项目:CalendarFX
文件:YearPageSkin.java
public YearPageSkin(YearPage view) {
super(view);
view.addEventFilter(ScrollEvent.SCROLL, this::handleScroll);
view.displayModeProperty().addListener(it -> updateVisibility());
updateVisibility();
}
项目:CalendarFX
文件:YearPageSkin.java
private void handleScroll(ScrollEvent evt) {
YearPage yearPage = getSkinnable();
double delta = evt.getDeltaX();
if (delta == 0) {
return;
}
if (delta < 0) {
yearPage.goForward();
} else if (delta > 0) {
yearPage.goBack();
}
}
项目:jmonkeybuilder
文件:Base3DFileEditor.java
@Override
@FXThread
public boolean isInside(final double sceneX, final double sceneY, @NotNull final Class<? extends Event> eventType) {
final Pane editorPage = getPage();
final Pane editor3DPage = get3DArea() == null ? editorPage : get3DArea();
final boolean only3D = eventType.isAssignableFrom(MouseEvent.class) ||
eventType.isAssignableFrom(ScrollEvent.class);
final Pane page = only3D ? editor3DPage : editorPage;
final Point2D point2D = page.sceneToLocal(sceneX, sceneY);
return page.contains(point2D);
}
项目:jmonkeybuilder
文件:SettingsDialog.java
/**
* The process of scrolling.
*/
@FXThread
private void processScroll(@NotNull final Spinner<Double> spinner, @NotNull final ScrollEvent event) {
if (!event.isControlDown()) return;
final double deltaY = event.getDeltaY();
if (deltaY > 0) {
spinner.increment(1);
} else {
spinner.decrement(1);
}
}