本文整理汇总了Java中javafx.scene.Node.toFront方法的典型用法代码示例。如果您正苦于以下问题:Java Node.toFront方法的具体用法?Java Node.toFront怎么用?Java Node.toFront使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.Node
的用法示例。
在下文中一共展示了Node.toFront方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: onPressed
import javafx.scene.Node; //导入方法依赖的package包/类
private void onPressed(Node dragged, MouseEvent event) {
if (event.getButton() == MouseButton.PRIMARY) {
dragActive = true;
inertiaOvercome = false;
nodeXOnPress = dragged.getLayoutX();
mouseXOnPress = event.getScreenX();
minWidthBackup = container.getMinWidth();
prefWidthBackup = container.getPrefWidth();
maxWidthBackup = container.getMaxWidth();
container.setMinWidth(container.getWidth());
container.setPrefWidth(container.getWidth());
container.setMaxWidth(container.getWidth());
translates = moveableChildren().collect(Collectors.toMap(Function.identity(), child -> new TranslateAnimation(child, dragged)));
moveableChildren().forEach(child -> child.setManaged(false));
// Move dragged node temporarily to front. Reset to original index on mouse release.
dragged.toFront();
}
}