modules/graphics/src/main/java/javafx/scene/layout/TilePane.java
Print this page
*** 797,831 ****
final Insets insets = getInsets();
int prefCols = 0;
if (forHeight != -1) {
// first compute number of rows that will fit in given height and
// compute pref columns from that
! int prefRows = computeRows(forHeight - snapSpace(insets.getTop()) - snapSpace(insets.getBottom()), getTileHeight());
prefCols = computeOther(managed.size(), prefRows);
} else {
prefCols = getOrientation() == HORIZONTAL? getPrefColumns() : computeOther(managed.size(), getPrefRows());
}
! return snapSpace(insets.getLeft()) +
computeContentWidth(prefCols, getTileWidth()) +
! snapSpace(insets.getRight());
}
@Override protected double computePrefHeight(double forWidth) {
List<Node> managed = getManagedChildren();
final Insets insets = getInsets();
int prefRows = 0;
if (forWidth != -1) {
// first compute number of columns that will fit in given width and
// compute pref rows from that
! int prefCols = computeColumns(forWidth - snapSpace(insets.getLeft()) - snapSpace(insets.getRight()), getTileWidth());
prefRows = computeOther(managed.size(), prefCols);
} else {
prefRows = getOrientation() == HORIZONTAL? computeOther(managed.size(), getPrefColumns()) : getPrefRows();
}
! return snapSpace(insets.getTop()) +
computeContentHeight(prefRows, getTileHeight()) +
! snapSpace(insets.getBottom());
}
private double computeTileWidth() {
List<Node> managed = getManagedChildren();
double preftilewidth = getPrefTileWidth();
--- 797,831 ----
final Insets insets = getInsets();
int prefCols = 0;
if (forHeight != -1) {
// first compute number of rows that will fit in given height and
// compute pref columns from that
! int prefRows = computeRows(forHeight - snapSpaceY(insets.getTop()) - snapSpaceY(insets.getBottom()), getTileHeight());
prefCols = computeOther(managed.size(), prefRows);
} else {
prefCols = getOrientation() == HORIZONTAL? getPrefColumns() : computeOther(managed.size(), getPrefRows());
}
! return snapSpaceX(insets.getLeft()) +
computeContentWidth(prefCols, getTileWidth()) +
! snapSpaceX(insets.getRight());
}
@Override protected double computePrefHeight(double forWidth) {
List<Node> managed = getManagedChildren();
final Insets insets = getInsets();
int prefRows = 0;
if (forWidth != -1) {
// first compute number of columns that will fit in given width and
// compute pref rows from that
! int prefCols = computeColumns(forWidth - snapSpaceX(insets.getLeft()) - snapSpaceX(insets.getRight()), getTileWidth());
prefRows = computeOther(managed.size(), prefCols);
} else {
prefRows = getOrientation() == HORIZONTAL? computeOther(managed.size(), getPrefColumns()) : getPrefRows();
}
! return snapSpaceY(insets.getTop()) +
computeContentHeight(prefRows, getTileHeight()) +
! snapSpaceY(insets.getBottom());
}
private double computeTileWidth() {
List<Node> managed = getManagedChildren();
double preftilewidth = getPrefTileWidth();
*** 841,853 ****
}
if (vertBias) {
// widest may depend on height of tile
h = computeMaxPrefAreaHeight(managed, marginAccessor, -1, getTileAlignmentInternal().getVpos());
}
! return snapSize(computeMaxPrefAreaWidth(managed, marginAccessor, h, true));
}
! return snapSize(preftilewidth);
}
private double computeTileHeight() {
List<Node> managed = getManagedChildren();
double preftileheight = getPrefTileHeight();
--- 841,853 ----
}
if (vertBias) {
// widest may depend on height of tile
h = computeMaxPrefAreaHeight(managed, marginAccessor, -1, getTileAlignmentInternal().getVpos());
}
! return snapSizeX(computeMaxPrefAreaWidth(managed, marginAccessor, h, true));
}
! return snapSizeX(preftilewidth);
}
private double computeTileHeight() {
List<Node> managed = getManagedChildren();
double preftileheight = getPrefTileHeight();
*** 863,912 ****
}
if (horizBias) {
// tallest may depend on width of tile
w = computeMaxPrefAreaWidth(managed, marginAccessor);
}
! return snapSize(computeMaxPrefAreaHeight(managed, marginAccessor, w, getTileAlignmentInternal().getVpos()));
}
! return snapSize(preftileheight);
}
private int computeOther(int numNodes, int numCells) {
double other = (double)numNodes/(double)Math.max(1, numCells);
return (int)Math.ceil(other);
}
private int computeColumns(double width, double tilewidth) {
! return Math.max(1,(int)((width + snapSpace(getHgap())) / (tilewidth + snapSpace(getHgap()))));
}
private int computeRows(double height, double tileheight) {
! return Math.max(1, (int)((height + snapSpace(getVgap())) / (tileheight + snapSpace(getVgap()))));
}
private double computeContentWidth(int columns, double tilewidth) {
if (columns == 0) return 0;
! return columns * tilewidth + (columns - 1) * snapSpace(getHgap());
}
private double computeContentHeight(int rows, double tileheight) {
if (rows == 0) return 0;
! return rows * tileheight + (rows - 1) * snapSpace(getVgap());
}
@Override protected void layoutChildren() {
List<Node> managed = getManagedChildren();
HPos hpos = getAlignmentInternal().getHpos();
VPos vpos = getAlignmentInternal().getVpos();
double width = getWidth();
double height = getHeight();
! double top = snapSpace(getInsets().getTop());
! double left = snapSpace(getInsets().getLeft());
! double bottom = snapSpace(getInsets().getBottom());
! double right = snapSpace(getInsets().getRight());
! double vgap = snapSpace(getVgap());
! double hgap = snapSpace(getHgap());
double insideWidth = width - left - right;
double insideHeight = height - top - bottom;
double tileWidth = getTileWidth() > insideWidth ? insideWidth : getTileWidth();
double tileHeight = getTileHeight() > insideHeight ? insideHeight : getTileHeight();
--- 863,914 ----
}
if (horizBias) {
// tallest may depend on width of tile
w = computeMaxPrefAreaWidth(managed, marginAccessor);
}
! return snapSizeY(computeMaxPrefAreaHeight(managed, marginAccessor, w, getTileAlignmentInternal().getVpos()));
}
! return snapSizeY(preftileheight);
}
private int computeOther(int numNodes, int numCells) {
double other = (double)numNodes/(double)Math.max(1, numCells);
return (int)Math.ceil(other);
}
private int computeColumns(double width, double tilewidth) {
! double snappedHgap = snapSpaceX(getHgap());
! return Math.max(1,(int)((width + snappedHgap) / (tilewidth + snappedHgap)));
}
private int computeRows(double height, double tileheight) {
! double snappedVgap = snapSpaceY(getVgap());
! return Math.max(1, (int)((height + snappedVgap) / (tileheight + snappedVgap)));
}
private double computeContentWidth(int columns, double tilewidth) {
if (columns == 0) return 0;
! return columns * tilewidth + (columns - 1) * snapSpaceX(getHgap());
}
private double computeContentHeight(int rows, double tileheight) {
if (rows == 0) return 0;
! return rows * tileheight + (rows - 1) * snapSpaceY(getVgap());
}
@Override protected void layoutChildren() {
List<Node> managed = getManagedChildren();
HPos hpos = getAlignmentInternal().getHpos();
VPos vpos = getAlignmentInternal().getVpos();
double width = getWidth();
double height = getHeight();
! double top = snapSpaceY(getInsets().getTop());
! double left = snapSpaceX(getInsets().getLeft());
! double bottom = snapSpaceY(getInsets().getBottom());
! double right = snapSpaceX(getInsets().getRight());
! double vgap = snapSpaceY(getVgap());
! double hgap = snapSpaceX(getHgap());
double insideWidth = width - left - right;
double insideHeight = height - top - bottom;
double tileWidth = getTileWidth() > insideWidth ? insideWidth : getTileWidth();
double tileHeight = getTileHeight() > insideHeight ? insideHeight : getTileHeight();