本文整理汇总了Java中javafx.geometry.Bounds类的典型用法代码示例。如果您正苦于以下问题:Java Bounds类的具体用法?Java Bounds怎么用?Java Bounds使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Bounds类属于javafx.geometry包,在下文中一共展示了Bounds类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPoint
import javafx.geometry.Bounds; //导入依赖的package包/类
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
TableRow<?> row = null;
for (Node tableRow : tableRowCell) {
TableRow<?> r = (TableRow<?>) tableRow;
if (r.getIndex() == rowIndex) {
row = r;
break;
}
}
Set<Node> cells = row.lookupAll(".table-cell");
for (Node node : cells) {
TableCell<?, ?> cell = (TableCell<?, ?>) node;
if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
Bounds bounds = cell.getBoundsInParent();
Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
Point2D rowLocal = row.localToScene(localToParent, true);
return rowLocal;
}
}
return null;
}
示例2: ensureVisible
import javafx.geometry.Bounds; //导入依赖的package包/类
private static void ensureVisible(ScrollPane pane, Node node) {
Bounds viewport = pane.getViewportBounds();
double contentHeight = pane.getContent().getBoundsInLocal().getHeight();
double contentWidth = pane.getContent().getBoundsInLocal().getWidth();
double nodeMinY = node.getBoundsInParent().getMinY();
double nodeMaxY = node.getBoundsInParent().getMaxY();
double nodeMinX = node.getBoundsInParent().getMinX();
double nodeMaxX = node.getBoundsInParent().getMaxX();
double viewportMinY = (contentHeight - viewport.getHeight()) * pane.getVvalue();
double viewportMaxY = viewportMinY + viewport.getHeight();
double viewportMinX = (contentWidth - viewport.getWidth()) * pane.getHvalue();
double viewportMaxX = viewportMinX + viewport.getWidth();
if (nodeMinY < viewportMinY) {
pane.setVvalue(nodeMinY / (contentHeight - viewport.getHeight()));
} else if (nodeMaxY > viewportMaxY) {
pane.setVvalue((nodeMaxY - viewport.getHeight()) / (contentHeight - viewport.getHeight()));
}
if (nodeMinX < viewportMinX) {
pane.setHvalue(nodeMinX / (contentWidth - viewport.getWidth()));
} else if (nodeMaxX > viewportMaxX) {
pane.setHvalue((nodeMaxX - viewport.getWidth()) / (contentWidth - viewport.getWidth()));
}
}
示例3: ensureVisible
import javafx.geometry.Bounds; //导入依赖的package包/类
protected void ensureVisible(Node target) {
ScrollPane scrollPane = getParentScrollPane(target);
if (scrollPane == null) {
return;
}
Node content = scrollPane.getContent();
Bounds contentBounds = content.localToScene(content.getBoundsInLocal());
Bounds viewportBounds = scrollPane.getViewportBounds();
Bounds nodeBounds = target.localToScene(target.getBoundsInLocal());
if (scrollPane.contains(nodeBounds.getMinX() - contentBounds.getMinX(), nodeBounds.getMinY() - contentBounds.getMinY())) {
return;
}
double toVScroll = (nodeBounds.getMinY() - contentBounds.getMinY())
* ((scrollPane.getVmax() - scrollPane.getVmin()) / (contentBounds.getHeight() - viewportBounds.getHeight()));
scrollPane.setVvalue(toVScroll);
double toHScroll = (nodeBounds.getMinX() - contentBounds.getMinX())
* ((scrollPane.getHmax() - scrollPane.getHmin()) / (contentBounds.getWidth() - viewportBounds.getWidth()));
scrollPane.setHvalue(toHScroll);
}
示例4: getIndexAt
import javafx.geometry.Bounds; //导入依赖的package包/类
protected int getIndexAt(ListView<?> listView, Point2D point) {
if (point == null) {
return listView.getSelectionModel().getSelectedIndex();
}
point = listView.localToScene(point);
Set<Node> lookupAll = getListCells(listView);
ListCell<?> selected = null;
for (Node cellNode : lookupAll) {
Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
if (boundsInScene.contains(point)) {
selected = (ListCell<?>) cellNode;
break;
}
}
if (selected == null) {
return -1;
}
return selected.getIndex();
}
示例5: getRowAt
import javafx.geometry.Bounds; //导入依赖的package包/类
public int getRowAt(TreeView<?> treeView, Point2D point) {
if (point == null) {
return treeView.getSelectionModel().getSelectedIndex();
}
point = treeView.localToScene(point);
int itemCount = treeView.getExpandedItemCount();
@SuppressWarnings("rawtypes")
List<TreeCell> cells = new ArrayList<>();
for (int i = 0; i < itemCount; i++) {
cells.add(getCellAt(treeView, i));
}
TreeCell<?> selected = null;
for (Node cellNode : cells) {
Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
if (boundsInScene.contains(point)) {
selected = (TreeCell<?>) cellNode;
break;
}
}
if (selected == null) {
return -1;
}
return selected.getIndex();
}
示例6: getBounds
import javafx.geometry.Bounds; //导入依赖的package包/类
private double[] getBounds(final List<Country> COUNTRIES) {
double upperLeftX = PREFERRED_WIDTH;
double upperLeftY = PREFERRED_HEIGHT;
double lowerRightX = 0;
double lowerRightY = 0;
for (Country country : COUNTRIES) {
List<CountryPath> paths = countryPaths.get(country.getName());
for (int i = 0; i < paths.size(); i++) {
CountryPath path = paths.get(i);
Bounds bounds = path.getLayoutBounds();
upperLeftX = Math.min(bounds.getMinX(), upperLeftX);
upperLeftY = Math.min(bounds.getMinY(), upperLeftY);
lowerRightX = Math.max(bounds.getMaxX(), lowerRightX);
lowerRightY = Math.max(bounds.getMaxY(), lowerRightY);
}
}
return new double[]{ upperLeftX, upperLeftY, lowerRightX, lowerRightY };
}
示例7: scrollTo
import javafx.geometry.Bounds; //导入依赖的package包/类
private void scrollTo(Node target) {
ScrollPane scrollPane = getParentScrollPane(target);
if (scrollPane == null)
return;
Node content = scrollPane.getContent();
Bounds contentBounds = content.localToScene(content.getBoundsInLocal());
Bounds viewportBounds = scrollPane.getViewportBounds();
Bounds nodeBounds = target.localToScene(target.getBoundsInLocal());
double toVScroll = (nodeBounds.getMinY() - contentBounds.getMinY())
* ((scrollPane.getVmax() - scrollPane.getVmin())
/ (contentBounds.getHeight() - viewportBounds.getHeight()));
if (toVScroll >= scrollPane.getVmin() && toVScroll < scrollPane.getVmax())
scrollPane.setVvalue(toVScroll);
double toHScroll = (nodeBounds.getMinX() - contentBounds.getMinX())
* ((scrollPane.getHmax() - scrollPane.getHmin())
/ (contentBounds.getWidth() - viewportBounds.getWidth()));
if (toHScroll >= scrollPane.getHmin() && toHScroll < scrollPane.getHmax())
scrollPane.setHvalue(toHScroll);
}
示例8: handleDropItem
import javafx.geometry.Bounds; //导入依赖的package包/类
private void handleDropItem() {
addEventFilter(MouseEvent.MOUSE_RELEASED, mouseEvent -> {
if(selectedItem != null) {
Bounds boundsInScene = draggingIcon.localToScene(draggingIcon.getBoundsInLocal());
Bounds mapViewPort_coords = mapViewPort.sceneToLocal(boundsInScene);
Bounds map_coords = mapPane.sceneToLocal(boundsInScene);
//Si l'item est dans le viewport
if(mapViewPort_coords.getMinX() > 0 && mapViewPort_coords.getMaxX() < mapViewPort.getWidth() && mapViewPort_coords.getMinY() > 0 && mapViewPort_coords.getMaxY() < mapViewPort.getHeight()) {
createItem(map_coords.getMinX(), map_coords.getMinY());
}
stackPaneRoot.getChildren().remove(draggingIcon);
draggingIcon = null;
selectedItem = null;
}
});
}
示例9: zoomInAndCenter
import javafx.geometry.Bounds; //导入依赖的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);
}
示例10: showPopup
import javafx.geometry.Bounds; //导入依赖的package包/类
/**
* Shows the popup.
*/
private void showPopup() {
if (popup.isShowing())
return;
calendarView.setVisible(true);
//calendarView.setManaged(true);
Bounds calendarBounds = calendarView.getBoundsInLocal();
Bounds bounds = getSkinnable().localToScene(getSkinnable().getBoundsInLocal());
double posX = calendarBounds.getMinX() + bounds.getMinX() + getSkinnable().getScene().getX() + getSkinnable().getScene().getWindow().getX();
double posY = calendarBounds.getMinY() + bounds.getHeight() + bounds.getMinY() + getSkinnable().getScene().getY() + getSkinnable().getScene().getWindow().getY();
popup.show(getSkinnable(), posX, posY);
}
示例11: initialize
import javafx.geometry.Bounds; //导入依赖的package包/类
/**
* Initializes the controller class.
*
* @param url
* @param rb
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
scrollPan.viewportBoundsProperty().addListener((ObservableValue<? extends Bounds> observable, Bounds oldValue, Bounds newValue) -> {
flowPane.setPrefWidth(newValue.getWidth());
});
lblTotalPatient.setText("Loading..........");
Platform.runLater(() -> {
totalPatient = patientGetway.totalPatient();
loadPatients();
lblTotalPatient.setText("Total :" + totalPatient);
lblShowingPatient.setText("Showing " + paginate.getStart() + " To " + paginate.getEnd());
if (totalPatient == 0) {
lblTotalPatient.setText("No patient found");
lblShowingPatient.setVisible(false);
}
});
}
示例12: checkHit
import javafx.geometry.Bounds; //导入依赖的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);
}
}
}
示例13: getTableCellAt
import javafx.geometry.Bounds; //导入依赖的package包/类
private TableCell<?, ?> getTableCellAt(TableView<?> tableView, Point2D point) {
point = tableView.localToScene(point);
Set<Node> lookupAll = getTableCells(tableView);
TableCell<?, ?> selected = null;
for (Node cellNode : lookupAll) {
Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
if (boundsInScene.contains(point)) {
selected = (TableCell<?, ?>) cellNode;
break;
}
}
return selected;
}
示例14: getTreeTableCellAt
import javafx.geometry.Bounds; //导入依赖的package包/类
public TreeTableCell<?, ?> getTreeTableCellAt(TreeTableView<?> treeTableView, Point2D point) {
point = treeTableView.localToScene(point);
Set<Node> lookupAll = getTreeTableCells(treeTableView);
TreeTableCell<?, ?> selected = null;
for (Node cellNode : lookupAll) {
Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
if (boundsInScene.contains(point)) {
selected = (TreeTableCell<?, ?>) cellNode;
break;
}
}
return selected;
}
示例15: _getMidpoint
import javafx.geometry.Bounds; //导入依赖的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));
}