本文整理汇总了Java中javafx.scene.Node.getBoundsInParent方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getBoundsInParent方法的具体用法?Java Node.getBoundsInParent怎么用?Java Node.getBoundsInParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.Node
的用法示例。
在下文中一共展示了Node.getBoundsInParent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: checkHit
import javafx.scene.Node; //导入方法依赖的package包/类
private void checkHit(Node child, double x, double y, List<Node> hits, String indent) {
Bounds boundsInParent = child.getBoundsInParent();
if (boundsInParent.contains(x, y)) {
hits.add(child);
if (!(child instanceof Parent)) {
return;
}
ObservableList<Node> childrenUnmodifiable = ((Parent) child).getChildrenUnmodifiable();
for (Node node : childrenUnmodifiable) {
checkHit(node, x, y, hits, " " + indent);
}
}
}
示例3: _getMidpoint
import javafx.scene.Node; //导入方法依赖的package包/类
@Override public Point2D _getMidpoint() {
Node cell = getPseudoComponent();
Bounds boundsInParent = cell.getBoundsInParent();
double x = boundsInParent.getWidth() / 2;
double y = boundsInParent.getHeight() / 2;
return cell.getParent().localToParent(cell.localToParent(x, y));
}
示例4: _getMidpoint
import javafx.scene.Node; //导入方法依赖的package包/类
@Override public Point2D _getMidpoint() {
TreeView<?> treeView = (TreeView<?>) getComponent();
Node cell = getCellAt(treeView, getPath(treeView, path));
Bounds boundsInParent = cell.getBoundsInParent();
double x = boundsInParent.getWidth() / 2;
double y = boundsInParent.getHeight() / 2;
return cell.localToParent(x, y);
}
示例5: _getMidpoint
import javafx.scene.Node; //导入方法依赖的package包/类
@Override public Point2D _getMidpoint() {
Node cell = getPseudoComponent();
Bounds boundsInParent = cell.getBoundsInParent();
double x = boundsInParent.getWidth() / 2;
double y = boundsInParent.getHeight() / 2;
return cell.localToParent(x, y);
}
示例6: createStateLabels
import javafx.scene.Node; //导入方法依赖的package包/类
private void createStateLabels() {
Group overlay = map.getOverlayGroup();
for(String state: Region.ALL_STATES) {
Node stateNode = map.lookup("#"+state);
if (stateNode != null) {
Label label = new Label("+10");
label.getStyleClass().add("heatmap-label");
label.setTextAlignment(TextAlignment.CENTER);
label.setAlignment(Pos.CENTER);
label.setManaged(false);
label.setOpacity(0);
label.setVisible(false);
Bounds stateBounds = stateNode.getBoundsInParent();
if ("DE".equals(state)) {
label.resizeRelocate(stateBounds.getMinX()-25, stateBounds.getMinY(),
stateBounds.getWidth()+50, stateBounds.getHeight());
} else if ("VT".equals(state)) {
label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()-25,
stateBounds.getWidth(), stateBounds.getHeight());
} else if ("NH".equals(state)) {
label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+30,
stateBounds.getWidth(), stateBounds.getHeight());
} else if ("MA".equals(state)) {
label.resizeRelocate(stateBounds.getMinX()-20, stateBounds.getMinY()-18,
stateBounds.getWidth(), stateBounds.getHeight());
} else if ("RI".equals(state)) {
label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(),
stateBounds.getWidth()+40, stateBounds.getHeight());
} else if ("ID".equals(state)) {
label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+60,
stateBounds.getWidth(), stateBounds.getHeight());
} else if ("MI".equals(state)) {
label.resizeRelocate(stateBounds.getMinX()+60, stateBounds.getMinY(),
stateBounds.getWidth(), stateBounds.getHeight());
} else if ("FL".equals(state)) {
label.resizeRelocate(stateBounds.getMinX()+95, stateBounds.getMinY(),
stateBounds.getWidth(), stateBounds.getHeight());
} else if ("LA".equals(state)) {
label.resizeRelocate(stateBounds.getMinX()-50, stateBounds.getMinY(),
stateBounds.getWidth(), stateBounds.getHeight());
} else {
label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(),
stateBounds.getWidth(), stateBounds.getHeight());
}
stateLabelMap.put(state, label);
overlay.getChildren().add(label);
}
}
}