本文整理汇总了Java中javafx.scene.Node.getLayoutBounds方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getLayoutBounds方法的具体用法?Java Node.getLayoutBounds怎么用?Java Node.getLayoutBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.Node
的用法示例。
在下文中一共展示了Node.getLayoutBounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SeparatedStage
import javafx.scene.Node; //导入方法依赖的package包/类
SeparatedStage(Node node){
super();
position = new Point2D(node.getLayoutX(),node.getLayoutY());
root.getChildren().add(node);
//scene.setFill(Color.WHITE);
this.node = node;
setOnShowing(showHandler);
setOnHiding(showHandler);
root.setOnMouseDragged(startDragHandler);
root.setOnMouseExited(stopDragHandler);
root.setOnMouseReleased(stopDragHandler);
setAlwaysOnTop();
try {
node.setLayoutX(0);
node.setLayoutY(0);
} catch (Exception e){ }
show();
stage.setX(position.getX());
stage.setY(position.getY());
Bounds bounds = node.getLayoutBounds();
stage.setHeight(bounds.getHeight()+5);
stage.setWidth(bounds.getWidth()+5);
}
示例2: snapshotNode
import javafx.scene.Node; //导入方法依赖的package包/类
private void snapshotNode(Scene scene, Node node) {
SnapshotParameters params = new SnapshotParameters();
Bounds layoutBounds = node.getLayoutBounds();
Bounds bounds = node.localToScene(layoutBounds);
if (!(bounds.getWidth() > 0 && bounds.getHeight() > 0)) {
return;
}
params.setViewport(new Rectangle2D(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()));
WritableImage writable = new WritableImage((int) bounds.getWidth(), (int) bounds.getHeight());
writable = scene.getRoot().snapshot(params, writable);
ImageView imageView = new ImageView(writable);
imageView.getStyleClass().add("snapshot-image");
imageView.setManaged(false);
imageView.setLayoutX(bounds.getMinX());
imageView.setLayoutY(bounds.getMinY());
imageView.setFitWidth(bounds.getWidth());
imageView.setFitHeight(bounds.getHeight());
Region rect = new Region();
rect.getStyleClass().add("snapshot-background");
rect.setLayoutX(bounds.getMinX() - 5);
rect.setLayoutY(bounds.getMinY() - 5);
rect.resize(bounds.getWidth() + 10, bounds.getHeight() + 10);
rect.setManaged(false);
Line line = new Line();
line.setStartX(bounds.getMaxX() + 4);
line.setStartY(bounds.getMaxY() + 4);
line.setEndX(bounds.getMaxX() + 200);
line.setEndY(bounds.getMaxY() + 200);
line.setStroke(imagePattern);
line.setStrokeWidth(5);
line.setManaged(false);
getChildren().addAll(rect, imageView); //, line);
}