modules/graphics/src/main/java/javafx/scene/layout/GridPane.java
Print this page
*** 1202,1214 ****
computeGridMetrics();
performingLayout = true;
try {
final double[] heights = height == -1 ? null : computeHeightsToFit(height).asArray();
! return snapSpace(getInsets().getLeft()) +
computeMinWidths(heights).computeTotalWithMultiSize() +
! snapSpace(getInsets().getRight());
} finally {
performingLayout = false;
}
}
--- 1202,1214 ----
computeGridMetrics();
performingLayout = true;
try {
final double[] heights = height == -1 ? null : computeHeightsToFit(height).asArray();
! return snapSpaceX(getInsets().getLeft()) +
computeMinWidths(heights).computeTotalWithMultiSize() +
! snapSpaceX(getInsets().getRight());
} finally {
performingLayout = false;
}
}
*** 1217,1229 ****
computeGridMetrics();
performingLayout = true;
try {
final double[] widths = width == -1 ? null : computeWidthsToFit(width).asArray();
! return snapSpace(getInsets().getTop()) +
computeMinHeights(widths).computeTotalWithMultiSize() +
! snapSpace(getInsets().getBottom());
} finally {
performingLayout = false;
}
}
--- 1217,1229 ----
computeGridMetrics();
performingLayout = true;
try {
final double[] widths = width == -1 ? null : computeWidthsToFit(width).asArray();
! return snapSpaceY(getInsets().getTop()) +
computeMinHeights(widths).computeTotalWithMultiSize() +
! snapSpaceY(getInsets().getBottom());
} finally {
performingLayout = false;
}
}
*** 1231,1243 ****
computeGridMetrics();
performingLayout = true;
try {
final double[] heights = height == -1 ? null : computeHeightsToFit(height).asArray();
! return snapSpace(getInsets().getLeft()) +
computePrefWidths(heights).computeTotalWithMultiSize() +
! snapSpace(getInsets().getRight());
} finally {
performingLayout = false;
}
}
--- 1231,1243 ----
computeGridMetrics();
performingLayout = true;
try {
final double[] heights = height == -1 ? null : computeHeightsToFit(height).asArray();
! return snapSpaceX(getInsets().getLeft()) +
computePrefWidths(heights).computeTotalWithMultiSize() +
! snapSpaceX(getInsets().getRight());
} finally {
performingLayout = false;
}
}
*** 1245,1257 ****
computeGridMetrics();
performingLayout = true;
try {
final double[] widths = width == -1 ? null : computeWidthsToFit(width).asArray();
! return snapSpace(getInsets().getTop()) +
computePrefHeights(widths).computeTotalWithMultiSize() +
! snapSpace(getInsets().getBottom());
} finally {
performingLayout = false;
}
}
--- 1245,1257 ----
computeGridMetrics();
performingLayout = true;
try {
final double[] widths = width == -1 ? null : computeWidthsToFit(width).asArray();
! return snapSpaceY(getInsets().getTop()) +
computePrefHeights(widths).computeTotalWithMultiSize() +
! snapSpaceY(getInsets().getBottom());
} finally {
performingLayout = false;
}
}
*** 1360,1377 ****
// in Region.layoutInArea call
final ObservableList<RowConstraints> rowConstr = getRowConstraints();
CompositeSize prefHeights = null;
for (int i = 0; i < rowConstr.size(); ++i) {
final RowConstraints curConstraint = rowConstr.get(i);
! double maxRowHeight = snapSize(curConstraint.getMaxHeight());
if (maxRowHeight == USE_PREF_SIZE) {
if (prefHeights == null) {
prefHeights = computePrefHeights(null);
}
rowMaxHeight.setPresetSize(i, prefHeights.getSize(i));
} else if (maxRowHeight != USE_COMPUTED_SIZE) {
! final double min = snapSize(curConstraint.getMinHeight());
if (min >= 0 ) {
rowMaxHeight.setPresetSize(i, boundedSize(min, maxRowHeight, maxRowHeight));
} else {
rowMaxHeight.setPresetSize(i, maxRowHeight);
}
--- 1360,1377 ----
// in Region.layoutInArea call
final ObservableList<RowConstraints> rowConstr = getRowConstraints();
CompositeSize prefHeights = null;
for (int i = 0; i < rowConstr.size(); ++i) {
final RowConstraints curConstraint = rowConstr.get(i);
! double maxRowHeight = snapSizeY(curConstraint.getMaxHeight());
if (maxRowHeight == USE_PREF_SIZE) {
if (prefHeights == null) {
prefHeights = computePrefHeights(null);
}
rowMaxHeight.setPresetSize(i, prefHeights.getSize(i));
} else if (maxRowHeight != USE_COMPUTED_SIZE) {
! final double min = snapSizeY(curConstraint.getMinHeight());
if (min >= 0 ) {
rowMaxHeight.setPresetSize(i, boundedSize(min, maxRowHeight, maxRowHeight));
} else {
rowMaxHeight.setPresetSize(i, maxRowHeight);
}
*** 1394,1407 ****
}
final ObservableList<RowConstraints> rowConstr = getRowConstraints();
for (int i = 0; i < rowConstr.size(); ++i) {
final RowConstraints curConstraint = rowConstr.get(i);
! double prefRowHeight = snapSize(curConstraint.getPrefHeight());
! final double min = snapSize(curConstraint.getMinHeight());
if (prefRowHeight != USE_COMPUTED_SIZE) {
! final double max = snapSize(curConstraint.getMaxHeight());
if (min >= 0 || max >= 0) {
result.setPresetSize(i, boundedSize(min < 0 ? 0 : min,
prefRowHeight,
max < 0 ? Double.POSITIVE_INFINITY : max));
} else {
--- 1394,1407 ----
}
final ObservableList<RowConstraints> rowConstr = getRowConstraints();
for (int i = 0; i < rowConstr.size(); ++i) {
final RowConstraints curConstraint = rowConstr.get(i);
! double prefRowHeight = snapSizeY(curConstraint.getPrefHeight());
! final double min = snapSizeY(curConstraint.getMinHeight());
if (prefRowHeight != USE_COMPUTED_SIZE) {
! final double max = snapSizeY(curConstraint.getMaxHeight());
if (min >= 0 || max >= 0) {
result.setPresetSize(i, boundedSize(min < 0 ? 0 : min,
prefRowHeight,
max < 0 ? Double.POSITIVE_INFINITY : max));
} else {
*** 1442,1452 ****
}
final ObservableList<RowConstraints> rowConstr = getRowConstraints();
CompositeSize prefHeights = null;
for (int i = 0; i < rowConstr.size(); ++i) {
! double minRowHeight = snapSize(rowConstr.get(i).getMinHeight());
if (minRowHeight == USE_PREF_SIZE) {
if (prefHeights == null) {
prefHeights = computePrefHeights(widths);
}
result.setPresetSize(i, prefHeights.getSize(i));
--- 1442,1452 ----
}
final ObservableList<RowConstraints> rowConstr = getRowConstraints();
CompositeSize prefHeights = null;
for (int i = 0; i < rowConstr.size(); ++i) {
! double minRowHeight = snapSizeY(rowConstr.get(i).getMinHeight());
if (minRowHeight == USE_PREF_SIZE) {
if (prefHeights == null) {
prefHeights = computePrefHeights(widths);
}
result.setPresetSize(i, prefHeights.getSize(i));
*** 1489,1506 ****
// in Region.layoutInArea call
final ObservableList<ColumnConstraints> columnConstr = getColumnConstraints();
CompositeSize prefWidths = null;
for (int i = 0; i < columnConstr.size(); ++i) {
final ColumnConstraints curConstraint = columnConstr.get(i);
! double maxColumnWidth = snapSize(curConstraint.getMaxWidth());
if (maxColumnWidth == USE_PREF_SIZE) {
if (prefWidths == null) {
prefWidths = computePrefWidths(null);
}
columnMaxWidth.setPresetSize(i, prefWidths.getSize(i));
} else if (maxColumnWidth != USE_COMPUTED_SIZE) {
! final double min = snapSize(curConstraint.getMinWidth());
if (min >= 0) {
columnMaxWidth.setPresetSize(i, boundedSize(min, maxColumnWidth, maxColumnWidth));
} else {
columnMaxWidth.setPresetSize(i, maxColumnWidth);
}
--- 1489,1506 ----
// in Region.layoutInArea call
final ObservableList<ColumnConstraints> columnConstr = getColumnConstraints();
CompositeSize prefWidths = null;
for (int i = 0; i < columnConstr.size(); ++i) {
final ColumnConstraints curConstraint = columnConstr.get(i);
! double maxColumnWidth = snapSizeX(curConstraint.getMaxWidth());
if (maxColumnWidth == USE_PREF_SIZE) {
if (prefWidths == null) {
prefWidths = computePrefWidths(null);
}
columnMaxWidth.setPresetSize(i, prefWidths.getSize(i));
} else if (maxColumnWidth != USE_COMPUTED_SIZE) {
! final double min = snapSizeX(curConstraint.getMinWidth());
if (min >= 0) {
columnMaxWidth.setPresetSize(i, boundedSize(min, maxColumnWidth, maxColumnWidth));
} else {
columnMaxWidth.setPresetSize(i, maxColumnWidth);
}
*** 1523,1536 ****
}
final ObservableList<ColumnConstraints> columnConstr = getColumnConstraints();
for (int i = 0; i < columnConstr.size(); ++i) {
final ColumnConstraints curConstraint = columnConstr.get(i);
! double prefColumnWidth = snapSize(curConstraint.getPrefWidth());
! final double min = snapSize(curConstraint.getMinWidth());
if (prefColumnWidth != USE_COMPUTED_SIZE) {
! final double max = snapSize(curConstraint.getMaxWidth());
if (min >= 0 || max >= 0) {
result.setPresetSize(i, boundedSize(min < 0 ? 0 : min,
prefColumnWidth,
max < 0 ? Double.POSITIVE_INFINITY : max));
} else {
--- 1523,1536 ----
}
final ObservableList<ColumnConstraints> columnConstr = getColumnConstraints();
for (int i = 0; i < columnConstr.size(); ++i) {
final ColumnConstraints curConstraint = columnConstr.get(i);
! double prefColumnWidth = snapSizeX(curConstraint.getPrefWidth());
! final double min = snapSizeX(curConstraint.getMinWidth());
if (prefColumnWidth != USE_COMPUTED_SIZE) {
! final double max = snapSizeX(curConstraint.getMaxWidth());
if (min >= 0 || max >= 0) {
result.setPresetSize(i, boundedSize(min < 0 ? 0 : min,
prefColumnWidth,
max < 0 ? Double.POSITIVE_INFINITY : max));
} else {
*** 1574,1584 ****
}
final ObservableList<ColumnConstraints> columnConstr = getColumnConstraints();
CompositeSize prefWidths = null;
for (int i = 0; i < columnConstr.size(); ++i) {
! double minColumnWidth = snapSize(columnConstr.get(i).getMinWidth());
if (minColumnWidth == USE_PREF_SIZE) {
if (prefWidths == null) {
prefWidths = computePrefWidths(heights);
}
result.setPresetSize(i, prefWidths.getSize(i));
--- 1574,1584 ----
}
final ObservableList<ColumnConstraints> columnConstr = getColumnConstraints();
CompositeSize prefWidths = null;
for (int i = 0; i < columnConstr.size(); ++i) {
! double minColumnWidth = snapSizeX(columnConstr.get(i).getMinWidth());
if (minColumnWidth == USE_PREF_SIZE) {
if (prefWidths == null) {
prefWidths = computePrefWidths(heights);
}
result.setPresetSize(i, prefWidths.getSize(i));
*** 1661,1676 ****
}
@Override protected void layoutChildren() {
performingLayout = true;
try {
! final double snaphgap = snapSpace(getHgap());
! final double snapvgap = snapSpace(getVgap());
! final double top = snapSpace(getInsets().getTop());
! final double bottom = snapSpace(getInsets().getBottom());
! final double left = snapSpace(getInsets().getLeft());
! final double right = snapSpace(getInsets().getRight());
final double width = getWidth();
final double height = getHeight();
final double contentHeight = height - top - bottom;
final double contentWidth = width - left - right;
--- 1661,1676 ----
}
@Override protected void layoutChildren() {
performingLayout = true;
try {
! final double snaphgap = snapSpaceX(getHgap());
! final double snapvgap = snapSpaceY(getVgap());
! final double top = snapSpaceY(getInsets().getTop());
! final double bottom = snapSpaceY(getInsets().getBottom());
! final double left = snapSpaceX(getInsets().getLeft());
! final double right = snapSpaceX(getInsets().getRight());
final double width = getWidth();
final double height = getHeight();
final double contentHeight = height - top - bottom;
final double contentWidth = width - left - right;
*** 1797,1809 ****
}
}
private double adjustRowHeights(final CompositeSize heights, double height) {
assert(height != -1);
! final double snapvgap = snapSpace(getVgap());
! final double top = snapSpace(getInsets().getTop());
! final double bottom = snapSpace(getInsets().getBottom());
final double vgaps = snapvgap * (getNumberOfRows() - 1);
final double contentHeight = height - top - bottom;
// if there are percentage rows, give them their percentages first
if (rowPercentTotal > 0) {
--- 1797,1809 ----
}
}
private double adjustRowHeights(final CompositeSize heights, double height) {
assert(height != -1);
! final double snapvgap = snapSpaceY(getVgap());
! final double top = snapSpaceY(getInsets().getTop());
! final double bottom = snapSpaceY(getInsets().getBottom());
final double vgaps = snapvgap * (getNumberOfRows() - 1);
final double contentHeight = height - top - bottom;
// if there are percentage rows, give them their percentages first
if (rowPercentTotal > 0) {
*** 2002,2012 ****
Math.ceil(available / adjusting.size()); // negative in shrinking case
}
if (portion != 0) {
for (Iterator<Integer> i = adjusting.iterator(); i.hasNext();) {
final int index = i.next();
! double limit = snapSpace(limitSize.getProportionalMinOrMaxSize(index, shrinking))
- heights.getSize(index); // negative in shrinking case
if (shrinking && limit > 0
|| !shrinking && limit < 0) { // Limit completely if current size
// (originally based on preferred) already passed the computed limit
limit = 0;
--- 2002,2012 ----
Math.ceil(available / adjusting.size()); // negative in shrinking case
}
if (portion != 0) {
for (Iterator<Integer> i = adjusting.iterator(); i.hasNext();) {
final int index = i.next();
! double limit = snapSpaceY(limitSize.getProportionalMinOrMaxSize(index, shrinking))
- heights.getSize(index); // negative in shrinking case
if (shrinking && limit > 0
|| !shrinking && limit < 0) { // Limit completely if current size
// (originally based on preferred) already passed the computed limit
limit = 0;
*** 2038,2050 ****
return available; // might be negative in shrinking case
}
private double adjustColumnWidths(final CompositeSize widths, double width) {
assert(width != -1);
! final double snaphgap = snapSpace(getHgap());
! final double left = snapSpace(getInsets().getLeft());
! final double right = snapSpace(getInsets().getRight());
final double hgaps = snaphgap * (getNumberOfColumns() - 1);
final double contentWidth = width - left - right;
// if there are percentage rows, give them their percentages first
if (columnPercentTotal > 0) {
--- 2038,2050 ----
return available; // might be negative in shrinking case
}
private double adjustColumnWidths(final CompositeSize widths, double width) {
assert(width != -1);
! final double snaphgap = snapSpaceX(getHgap());
! final double left = snapSpaceX(getInsets().getLeft());
! final double right = snapSpaceX(getInsets().getRight());
final double hgaps = snaphgap * (getNumberOfColumns() - 1);
final double contentWidth = width - left - right;
// if there are percentage rows, give them their percentages first
if (columnPercentTotal > 0) {
*** 2246,2256 ****
Math.ceil(available / adjusting.size()); // negative in shrinking case
}
if (portion != 0) {
for (Iterator<Integer> i = adjusting.iterator(); i.hasNext();) {
final int index = i.next();
! double limit = snapSpace(limitSize.getProportionalMinOrMaxSize(index, shrinking))
- widths.getSize(index); // negative in shrinking case
if (shrinking && limit > 0
|| !shrinking && limit < 0) { // Limit completely if current size
// (originally based on preferred) already passed the computed limit
limit = 0;
--- 2246,2256 ----
Math.ceil(available / adjusting.size()); // negative in shrinking case
}
if (portion != 0) {
for (Iterator<Integer> i = adjusting.iterator(); i.hasNext();) {
final int index = i.next();
! double limit = snapSpaceX(limitSize.getProportionalMinOrMaxSize(index, shrinking))
- widths.getSize(index); // negative in shrinking case
if (shrinking && limit > 0
|| !shrinking && limit < 0) { // Limit completely if current size
// (originally based on preferred) already passed the computed limit
limit = 0;
*** 2287,2298 ****
return;
}
if (!gridLines.getChildren().isEmpty()) {
gridLines.getChildren().clear();
}
! double hgap = snapSpace(getHgap());
! double vgap = snapSpace(getVgap());
// create vertical lines
double linex = x;
double liney = y;
for (int i = 0; i <= columnWidths.getLength(); i++) {
--- 2287,2298 ----
return;
}
if (!gridLines.getChildren().isEmpty()) {
gridLines.getChildren().clear();
}
! double hgap = snapSpaceX(getHgap());
! double vgap = snapSpaceY(getVgap());
// create vertical lines
double linex = x;
double liney = y;
for (int i = 0; i <= columnWidths.getLength(); i++) {
*** 2339,2354 ****
return "Grid hgap="+getHgap()+", vgap="+getVgap()+", alignment="+getAlignment();
}
private CompositeSize createCompositeRows(double initSize) {
return new CompositeSize(getNumberOfRows(), rowPercentHeight, rowPercentTotal,
! snapSpace(getVgap()), initSize);
}
private CompositeSize createCompositeColumns(double initSize) {
return new CompositeSize(getNumberOfColumns(), columnPercentWidth, columnPercentTotal,
! snapSpace(getHgap()), initSize);
}
private int getNodeRowEndConvertRemaining(Node child) {
int rowSpan = getNodeRowSpan(child);
return rowSpan != REMAINING? getNodeRowIndex(child) + rowSpan - 1 : getNumberOfRows() - 1;
--- 2339,2354 ----
return "Grid hgap="+getHgap()+", vgap="+getVgap()+", alignment="+getAlignment();
}
private CompositeSize createCompositeRows(double initSize) {
return new CompositeSize(getNumberOfRows(), rowPercentHeight, rowPercentTotal,
! snapSpaceY(getVgap()), initSize);
}
private CompositeSize createCompositeColumns(double initSize) {
return new CompositeSize(getNumberOfColumns(), columnPercentWidth, columnPercentTotal,
! snapSpaceX(getHgap()), initSize);
}
private int getNodeRowEndConvertRemaining(Node child) {
int rowSpan = getNodeRowSpan(child);
return rowSpan != REMAINING? getNodeRowIndex(child) + rowSpan - 1 : getNumberOfRows() - 1;
*** 2738,2755 ****
* @treatAsPrivate implementation detail
* @deprecated This is an internal API that is not intended for use and will be removed in the next version
*/
@Deprecated // SB-dependency: RT-33381 has been filed to track this
public final Bounds impl_getCellBounds(int columnIndex, int rowIndex) {
! final double snaphgap = this.snapSpace(this.getHgap());
! final double snapvgap = this.snapSpace(this.getVgap());
! final double top = this.snapSpace(this.getInsets().getTop());
! final double right = this.snapSpace(this.getInsets().getRight());
! final double bottom = this.snapSpace(this.getInsets().getBottom());
! final double left = this.snapSpace(this.getInsets().getLeft());
! final double gridPaneHeight = this.snapSize(this.getHeight()) - (top + bottom);
! final double gridPaneWidth = this.snapSize(this.getWidth()) - (left + right);
// Compute grid. Result contains two double arrays, first for columns, second for rows
double[] columnWidths;
double[] rowHeights;
--- 2738,2755 ----
* @treatAsPrivate implementation detail
* @deprecated This is an internal API that is not intended for use and will be removed in the next version
*/
@Deprecated // SB-dependency: RT-33381 has been filed to track this
public final Bounds impl_getCellBounds(int columnIndex, int rowIndex) {
! final double snaphgap = this.snapSpaceX(this.getHgap());
! final double snapvgap = this.snapSpaceY(this.getVgap());
! final double top = this.snapSpaceY(this.getInsets().getTop());
! final double right = this.snapSpaceX(this.getInsets().getRight());
! final double bottom = this.snapSpaceY(this.getInsets().getBottom());
! final double left = this.snapSpaceX(this.getInsets().getLeft());
! final double gridPaneHeight = this.snapSizeY(this.getHeight()) - (top + bottom);
! final double gridPaneWidth = this.snapSizeX(this.getWidth()) - (left + right);
// Compute grid. Result contains two double arrays, first for columns, second for rows
double[] columnWidths;
double[] rowHeights;