本文整理匯總了Java中javafx.scene.layout.GridPane.getRowIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java GridPane.getRowIndex方法的具體用法?Java GridPane.getRowIndex怎麽用?Java GridPane.getRowIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.layout.GridPane
的用法示例。
在下文中一共展示了GridPane.getRowIndex方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: removeRowFromGridPane
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private GridPane removeRowFromGridPane(int row, GridPane gridPane ) {
Set<Node> deleteNodes = new HashSet<>();
for (Node child : gridPane.getChildren()) {
// get index from child
Integer rowIndex = GridPane.getRowIndex(child);
// handle null values for index=0
int r = rowIndex == null ? 0 : rowIndex;
if (r == row) {
// collect matching rows for deletion
deleteNodes.add(child);
}
}
gridPane.getChildren().removeAll(deleteNodes);
return gridPane;
}
示例2: render
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private void render(TimeLine timeLine) {
int columnsNumber = getCellNumber(width, SPACING, sideSize);
int rowsNumber = getCellNumber(height, SPACING, sideSize);
int centerColumn = columnsNumber / 2;
int centerRow = rowsNumber / 2;
for (Node node : scene.getChildren()) {
int x = GridPane.getColumnIndex(node);
int y = GridPane.getRowIndex(node);
Rectangle square = (Rectangle) node;
if (timeLine.isAlive(new Point(x - centerColumn, y - centerRow))) {
square.setFill(ALIVE_COLOR);
} else {
square.setFill(DEAD_COLOR);
}
}
}
示例3: getNodeByRowColumnIndex
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private javafx.scene.Node getNodeByRowColumnIndex(final int row, final int column, GridPane gridPane) {
javafx.scene.Node result = null;
ObservableList<javafx.scene.Node> children = gridPane.getChildren();
for (javafx.scene.Node node : children) {
if(GridPane.getRowIndex(node) == row && GridPane.getColumnIndex(node) == column) {
result = node;
break;
}
}
return result;
}
示例4: isOverlapping
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
/**
* Checks if a tile with the given width and height would overlap a pre-existing tile at the point {@code (col, row)},
* ignoring some nodes when calculating collisions. Note that this method does <i>not</i> perform bounds checking;
* use {@link #isOpen(int, int, int, int, Predicate) isOpen} to check if a widget can be placed at that point.
*
* @param col the column index of the point to check
* @param row the row index of the point to check
* @param tileWidth the width of the tile
* @param tileHeight the height of the tile
* @param ignore a predicate to use to ignore nodes when calculating collisions
*/
public boolean isOverlapping(int col, int row, int tileWidth, int tileHeight, Predicate<Node> ignore) {
for (Node child : getChildren()) {
if (ignore.test(child)) {
continue;
}
// All "real" children have a column index, row index, and column and row spans
// Other children (like the grid lines) don't have these properties and will throw null pointers
// when trying to access these properties
if (GridPane.getColumnIndex(child) != null) {
int x = GridPane.getColumnIndex(child);
int y = GridPane.getRowIndex(child);
int width = GridPane.getColumnSpan(child);
int height = GridPane.getRowSpan(child);
if (x + width > col && y + height > row
&& x - tileWidth < col && y - tileHeight < row) {
// There's an intersection
return true;
}
}
}
return false;
}
示例5: getRowCount
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private int getRowCount(GridPane pane) {
int numRows = pane.getRowConstraints().size();
for (int i = 0; i < pane.getChildren().size(); i++) {
Node child = pane.getChildren().get(i);
if (child.isManaged()) {
Integer rowIndex = GridPane.getRowIndex(child);
if (rowIndex != null) {
numRows = Math.max(numRows, rowIndex + 1);
}
}
}
return numRows;
}
示例6: getColCount
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private int getColCount(GridPane pane) {
int numCols = pane.getRowConstraints().size();
for (int i = 0; i < pane.getChildren().size(); i++) {
Node child = pane.getChildren().get(i);
if (child.isManaged()) {
Integer colIndex = GridPane.getRowIndex(child);
if (colIndex != null) {
numCols = Math.max(numCols, colIndex + 1);
}
}
}
return numCols;
}
示例7: getY
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private double getY(javafx.scene.Node node) {
int row = GridPane.getRowIndex(node);
return (projection.getSideSize() + TwoDimensionalProjection.SPACING) * row;
}