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


Java Node.setScaleX方法代碼示例

本文整理匯總了Java中javafx.scene.Node.setScaleX方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.setScaleX方法的具體用法?Java Node.setScaleX怎麽用?Java Node.setScaleX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.Node的用法示例。


在下文中一共展示了Node.setScaleX方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: scaleAll

import javafx.scene.Node; //導入方法依賴的package包/類
private static void scaleAll(Scene scene, Node node) {
    double translateX = node.getTranslateX();
    double translateY = node.getTranslateY();
    double baseX = node.getBoundsInParent().getMinX();
    double baseY = node.getBoundsInParent().getMinY();
    double sceneWidth = scene.getWidth();
    double sceneHeight = scene.getHeight();
    ChangeListener<Number> widthResizer = (arg0, oldValue, newValue) -> {
        node.setScaleX(newValue.doubleValue() / sceneWidth);
        node.setTranslateX(translateX + (baseX * newValue.doubleValue() / sceneWidth) - baseX);
    };

    scene.widthProperty().addListener(widthResizer);
    ChangeListener<Number> heightResizer = (arg0, oldValue, newValue) -> {
        node.setScaleY(newValue.doubleValue() / sceneHeight);
        node.setTranslateY(translateY + (baseY * newValue.doubleValue() / sceneHeight) - baseY);
    };
    scene.heightProperty().addListener(heightResizer);

}
 
開發者ID:ciphertechsolutions,項目名稱:IO,代碼行數:21,代碼來源:BaseController.java

示例2: zoomInAndCenter

import javafx.scene.Node; //導入方法依賴的package包/類
private static void zoomInAndCenter(Node node, double initialWidth, double initialHeight, boolean preserveRatio) {
    Parent parent = node.getParent();

    node.toFront();

    Bounds parentBoundsInParent = parent.getBoundsInLocal();

    double xScaleRatio = parentBoundsInParent.getMaxX() / initialWidth;
    double yScaleRatio = parentBoundsInParent.getMaxY() / initialHeight;

    if (preserveRatio) {
        double bestScaleRatio = Math.min(xScaleRatio, yScaleRatio);
        node.setScaleX(bestScaleRatio);
        node.setScaleY(bestScaleRatio);
    } else {
        node.setScaleX(xScaleRatio);
        node.setScaleY(yScaleRatio);
    }

    Bounds boundsInParent = node.getBoundsInParent();

    double translateX = -1 * Math.abs(boundsInParent.getMinY());
    double translateY = -1 * Math.abs(boundsInParent.getMinY());

    node.setTranslateX(translateX);
    node.setTranslateY(translateY);
}
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:28,代碼來源:StatsDisplay.java

示例3: draw

import javafx.scene.Node; //導入方法依賴的package包/類
protected void draw (Node node, Drawable sprite) {
    Coordinate location = sprite.getLocation();
    node.relocate(getScale().scale(location.getX()) -
                  sprite.getDrawer().getGraphic().getHeight().get() / 2,
                  getScale().scale(location.getY()) - sprite.getDrawer().getGraphic()
                          .getHeight().get() / 2);
    node.setScaleX(getScale().getScale());
    node.setScaleY(getScale().getScale());
    node.setVisible(sprite.getDrawer().isVisible());
    node.setRotate(sprite.getOrientation());
}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:12,代碼來源:LevelRenderer.java

示例4: setupValuePane

import javafx.scene.Node; //導入方法依賴的package包/類
private Pane setupValuePane(Dimension<?> dimension, Label titleLabel, Pane contentPane) {
	final HBox titlePane = new HBox();
	final VBox valueVBox = new VBox();
	final Node backValueGraphicNode = new ImageView(backValueGraphic);
	final double buttonScale = 0.66;
	backValueGraphicNode.setScaleX(1 / buttonScale);
	backValueGraphicNode.setScaleY(1 / buttonScale);
	final Button backValue = new Button("", backValueGraphicNode);
	backValue.setOnAction((e) -> {
		traceExplorer.backValue(dimension);
	});
	backValue.setScaleX(buttonScale);
	backValue.setScaleY(buttonScale);
	backValue.setDisable(!traceExplorer.canBackValue(dimension));
	final Node stepValueGraphicNode = new ImageView(stepValueGraphic);
	stepValueGraphicNode.setScaleX(1 / buttonScale);
	stepValueGraphicNode.setScaleY(1 / buttonScale);
	final Button stepValue = new Button("", stepValueGraphicNode);
	stepValue.setOnAction((e) -> {
		traceExplorer.stepValue(dimension);
	});
	stepValue.setDisable(!traceExplorer.canStepValue(dimension));
	stepValue.setScaleX(buttonScale);
	stepValue.setScaleY(buttonScale);
	titlePane.setAlignment(Pos.CENTER_LEFT);
	VBox.setMargin(titlePane, HALF_MARGIN_INSETS);
	VBox.setMargin(contentPane, MARGIN_INSETS);

	final CheckBox showValueCheckBox = new CheckBox();
	showValueCheckBox.setScaleX(buttonScale);
	showValueCheckBox.setScaleY(buttonScale);
	boolean hide = traceExtractor.isDimensionIgnored(dimension);
	if (hide) {
		showValueCheckBox.setSelected(false);
	} else {
		showValueCheckBox.setSelected(true);
	}
	BooleanProperty sel = showValueCheckBox.selectedProperty();
	backValue.visibleProperty().bind(sel);
	stepValue.visibleProperty().bind(sel);
	sel.addListener((v, o, n) -> {
		if (o != n) {
			traceExtractor.ignoreDimension(dimension, !n);
			if (n) {
				valueVBox.getChildren().add(contentPane);
			} else {
				valueVBox.getChildren().remove(contentPane);
			}
			sortValueLines();
		}
	});
	titlePane.getChildren().addAll(showValueCheckBox, titleLabel, backValue, stepValue);
	valueVBox.getChildren().add(titlePane);
	if (!hide) {
		valueVBox.getChildren().add(contentPane);
	}

	valuesLines.getChildren().add(valueVBox);
	valueVBox.setUserData(dimension);
	titleLabel.minWidthProperty().bind(valueTitleWidth);
	titleLabel.widthProperty().addListener((v, o, n) -> {
		if (n.doubleValue() > valueTitleWidth.get()) {
			valueTitleWidth.set(n.doubleValue());
		}
	});
	if (titleLabel.widthProperty().doubleValue() > valueTitleWidth.get()) {
		valueTitleWidth.set(titleLabel.widthProperty().doubleValue());
	}

	return valueVBox;
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:72,代碼來源:MultidimensionalTimelineRenderer.java

示例5: zoomOutAndReset

import javafx.scene.Node; //導入方法依賴的package包/類
private static void zoomOutAndReset(Node node) {
    node.setScaleX(1);
    node.setScaleY(1);
    node.setTranslateX(0);
    node.setTranslateY(0);
}
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:7,代碼來源:StatsDisplay.java


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