當前位置: 首頁>>代碼示例>>Java>>正文


Java ScrollEvent.getSceneY方法代碼示例

本文整理匯總了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();
}
 
開發者ID:INAETICS,項目名稱:Drones-Simulator,代碼行數:29,代碼來源:SceneGestures.java

示例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();
    }
}
 
開發者ID:quiram,項目名稱:build-hotspots,代碼行數:17,代碼來源:BuildHotspotsApplicationBase.java

示例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();
}
 
開發者ID:alexejsailer,項目名稱:FXGraphs,代碼行數:51,代碼來源:Main.java

示例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();
}
 
開發者ID:truffle-hog,項目名稱:truffle-hog,代碼行數:51,代碼來源:SceneGestures.java


注:本文中的javafx.scene.input.ScrollEvent.getSceneY方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。