本文整理汇总了Java中javafx.scene.input.ScrollEvent.getSceneY方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollEvent.getSceneY方法的具体用法?Java ScrollEvent.getSceneY怎么用?Java ScrollEvent.getSceneY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.input.ScrollEvent
的用法示例。
在下文中一共展示了ScrollEvent.getSceneY方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: handle
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@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();
}
}
示例3: handle
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handle(ScrollEvent event) {
System.out.println("Scroll DelatY " + event.getDeltaY());
double delta = 1.2;
double scale = getMyScale().doubleValue();
double oldScale = scale;
if (event.getDeltaY() < 0) {
scale /= delta;
} else {
scale *= delta;
}
scale = clamp(scale, MIN_SCALE, MAX_SCALE);
double f = (scale / oldScale) - 1;
getMyScale().set(scale);
System.out.println("DV-B in Parent Width " + diagramView.getDiagramView().getBoundsInParent().getWidth());
System.out.println("DV-B in Parent Height " + diagramView.getDiagramView().getBoundsInParent().getHeight());
System.out.println("DV-B in Parent MinX " + diagramView.getDiagramView().getBoundsInParent().getMinX());
System.out.println("DV-B in Parent MinY " + diagramView.getDiagramView().getBoundsInParent().getMinY());
System.out.println("DV-B in Local Width " + diagramView.getDiagramView().getBoundsInLocal().getWidth());
System.out.println("DV-B in Local Height " + diagramView.getDiagramView().getBoundsInLocal().getHeight());
System.out.println("DV-B in Local MinX " + diagramView.getDiagramView().getBoundsInLocal().getMinX());
System.out.println("DV-B in Local MinY " + diagramView.getDiagramView().getBoundsInLocal().getMinY());
System.out.println("SceneX " + event.getSceneX());
System.out.println("SceneY " + event.getSceneY());
double dx = (event.getSceneX()
- (paper.getBoundsInParent().getWidth() / 2 + paper.getBoundsInParent().getMinX()));
System.out.println(diagramView.getDiagramView()
.localToScene(diagramView.getDiagramView().getBoundsInLocal()).getMinY());
double dy = (event.getSceneY()
- (paper.getBoundsInParent().getHeight() / 2 + paper.getBoundsInParent().getMinY()));
paper.setScaleX(scale);
paper.setScaleY(scale);
paper.setTranslateX(paper.getTranslateX() - f * dx);
paper.setTranslateY(paper.getTranslateY() - f * (dy));
event.consume();
}
示例4: handle
import javafx.scene.input.ScrollEvent; //导入方法依赖的package包/类
@Override
public void handle(ScrollEvent event) {
/*double scaleDelta = 1.2;
double factor = (event.getDeltaY() > 0) ? scaleDelta : 1 / scaleDelta;
final Point2D center = canvas.localToParent(event.getX(), event.getY());
final Bounds bounds = canvas.getBoundsInParent();
final double w = bounds.getWidth();
final double h = bounds.getHeight();
final double dw = w * (factor - 1);
final double xr = 2 * (w / 2 - (center.getX() - bounds.getMinX())) / w;
final double dh = h * (factor - 1);
final double yr = 2 * (h / 2 - (center.getY() - bounds.getMinY())) / h;
canvas.setScaleX(canvas.getScaleX() * factor);
canvas.setScaleY(canvas.getScaleY() * factor);
canvas.setTranslateX(canvas.getTranslateX() + xr * dw / 2);
canvas.setTranslateY(canvas.getTranslateY() + yr * dh / 2);*/
//FIXME fix scrolling/scaling
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;
}
double f = (scale / oldScale) - 1;
double dx = (event.getSceneX() - (canvas.getGhost().getBoundsInParent().getWidth() / 2 + canvas.getGhost().getBoundsInParent().getMinX()));
double dy = (event.getSceneY() - (canvas.getGhost().getBoundsInParent().getHeight() / 2 + canvas.getGhost().getBoundsInParent().getMinY()));
//logger.debug(canvas.getBoundsInParent());
//canvas.setPrefHeight(600 / canvas.getScale());
//canvas.setPrefWidth(600 / canvas.getScale());
canvas.setScale( scale);
// note: pivot value must be untransformed, i. e. without scaling
canvas.setPivot(f * dx, f * dy);
event.consume();
}