modules/graphics/src/main/java/javafx/scene/layout/HBox.java
Print this page
*** 394,406 ****
return bias;
}
@Override protected double computeMinWidth(double height) {
Insets insets = getInsets();
! return snapSpace(insets.getLeft()) +
computeContentWidth(getManagedChildren(), height, true) +
! snapSpace(insets.getRight());
}
@Override protected double computeMinHeight(double width) {
Insets insets = getInsets();
List<Node>managed = getManagedChildren();
--- 394,406 ----
return bias;
}
@Override protected double computeMinWidth(double height) {
Insets insets = getInsets();
! return snapSpaceX(insets.getLeft()) +
computeContentWidth(getManagedChildren(), height, true) +
! snapSpaceX(insets.getRight());
}
@Override protected double computeMinHeight(double width) {
Insets insets = getInsets();
List<Node>managed = getManagedChildren();
*** 410,429 ****
adjustAreaWidths(managed, prefWidths, width, -1);
contentHeight = computeMaxMinAreaHeight(managed, marginAccessor, prefWidths[0], getAlignmentInternal().getVpos());
} else {
contentHeight = computeMaxMinAreaHeight(managed, marginAccessor, getAlignmentInternal().getVpos());
}
! return snapSpace(insets.getTop()) +
contentHeight +
! snapSpace(insets.getBottom());
}
@Override protected double computePrefWidth(double height) {
Insets insets = getInsets();
! return snapSpace(insets.getLeft()) +
computeContentWidth(getManagedChildren(), height, false) +
! snapSpace(insets.getRight());
}
@Override protected double computePrefHeight(double width) {
Insets insets = getInsets();
List<Node>managed = getManagedChildren();
--- 410,429 ----
adjustAreaWidths(managed, prefWidths, width, -1);
contentHeight = computeMaxMinAreaHeight(managed, marginAccessor, prefWidths[0], getAlignmentInternal().getVpos());
} else {
contentHeight = computeMaxMinAreaHeight(managed, marginAccessor, getAlignmentInternal().getVpos());
}
! return snapSpaceY(insets.getTop()) +
contentHeight +
! snapSpaceY(insets.getBottom());
}
@Override protected double computePrefWidth(double height) {
Insets insets = getInsets();
! return snapSpaceX(insets.getLeft()) +
computeContentWidth(getManagedChildren(), height, false) +
! snapSpaceX(insets.getRight());
}
@Override protected double computePrefHeight(double width) {
Insets insets = getInsets();
List<Node>managed = getManagedChildren();
*** 433,452 ****
adjustAreaWidths(managed, prefWidths, width, -1);
contentHeight = computeMaxPrefAreaHeight(managed, marginAccessor, prefWidths[0], getAlignmentInternal().getVpos());
} else {
contentHeight = computeMaxPrefAreaHeight(managed, marginAccessor, getAlignmentInternal().getVpos());
}
! return snapSpace(insets.getTop()) +
contentHeight +
! snapSpace(insets.getBottom());
}
private double[][] getAreaWidths(List<Node>managed, double height, boolean minimum) {
// height could be -1
double[][] temp = getTempArray(managed.size());
final double insideHeight = height == -1? -1 : height -
! snapSpace(getInsets().getTop()) - snapSpace(getInsets().getBottom());
final boolean shouldFillHeight = shouldFillHeight();
for (int i = 0, size = managed.size(); i < size; i++) {
Node child = managed.get(i);
Insets margin = getMargin(child);
if (minimum) {
--- 433,452 ----
adjustAreaWidths(managed, prefWidths, width, -1);
contentHeight = computeMaxPrefAreaHeight(managed, marginAccessor, prefWidths[0], getAlignmentInternal().getVpos());
} else {
contentHeight = computeMaxPrefAreaHeight(managed, marginAccessor, getAlignmentInternal().getVpos());
}
! return snapSpaceY(insets.getTop()) +
contentHeight +
! snapSpaceY(insets.getBottom());
}
private double[][] getAreaWidths(List<Node>managed, double height, boolean minimum) {
// height could be -1
double[][] temp = getTempArray(managed.size());
final double insideHeight = height == -1? -1 : height -
! snapSpaceY(getInsets().getTop()) - snapSpaceY(getInsets().getBottom());
final boolean shouldFillHeight = shouldFillHeight();
for (int i = 0, size = managed.size(); i < size; i++) {
Node child = managed.get(i);
Insets margin = getMargin(child);
if (minimum) {
*** 458,473 ****
return temp;
}
private double adjustAreaWidths(List<Node>managed, double areaWidths[][], double width, double height) {
Insets insets = getInsets();
! double top = snapSpace(insets.getTop());
! double bottom = snapSpace(insets.getBottom());
! double contentWidth = sum(areaWidths[0], managed.size()) + (managed.size()-1)*snapSpace(getSpacing());
double extraWidth = width -
! snapSpace(insets.getLeft()) - snapSpace(insets.getRight()) - contentWidth;
if (extraWidth != 0) {
final double refHeight = shouldFillHeight() && height != -1? height - top - bottom : -1;
double remaining = growOrShrinkAreaWidths(managed, areaWidths, Priority.ALWAYS, extraWidth, refHeight);
remaining = growOrShrinkAreaWidths(managed, areaWidths, Priority.SOMETIMES, remaining, refHeight);
--- 458,473 ----
return temp;
}
private double adjustAreaWidths(List<Node>managed, double areaWidths[][], double width, double height) {
Insets insets = getInsets();
! double top = snapSpaceY(insets.getTop());
! double bottom = snapSpaceY(insets.getBottom());
! double contentWidth = sum(areaWidths[0], managed.size()) + (managed.size()-1)*snapSpaceX(getSpacing());
double extraWidth = width -
! snapSpaceX(insets.getLeft()) - snapSpaceX(insets.getRight()) - contentWidth;
if (extraWidth != 0) {
final double refHeight = shouldFillHeight() && height != -1? height - top - bottom : -1;
double remaining = growOrShrinkAreaWidths(managed, areaWidths, Priority.ALWAYS, extraWidth, refHeight);
remaining = growOrShrinkAreaWidths(managed, areaWidths, Priority.SOMETIMES, remaining, refHeight);
*** 502,512 ****
}
}
double available = extraWidth; // will be negative in shrinking case
outer:while (Math.abs(available) > 1 && adjustingNumber > 0) {
! final double portion = snapPortion(available / adjustingNumber); // negative in shrinking case
for (int i = 0, size = managed.size(); i < size; i++) {
if (temp[i] == -1) {
continue;
}
final double limit = temp[i] - usedWidths[i]; // negative in shrinking case
--- 502,512 ----
}
}
double available = extraWidth; // will be negative in shrinking case
outer:while (Math.abs(available) > 1 && adjustingNumber > 0) {
! final double portion = snapPortionX(available / adjustingNumber); // negative in shrinking case
for (int i = 0, size = managed.size(); i < size; i++) {
if (temp[i] == -1) {
continue;
}
final double limit = temp[i] - usedWidths[i]; // negative in shrinking case
*** 526,536 ****
return available; // might be negative in shrinking case
}
private double computeContentWidth(List<Node> managedChildren, double height, boolean minimum) {
return sum(getAreaWidths(managedChildren, height, minimum)[0], managedChildren.size())
! + (managedChildren.size()-1)*snapSpace(getSpacing());
}
private static double sum(double[] array, int size) {
int i = 0;
double res = 0;
--- 526,536 ----
return available; // might be negative in shrinking case
}
private double computeContentWidth(List<Node> managedChildren, double height, boolean minimum) {
return sum(getAreaWidths(managedChildren, height, minimum)[0], managedChildren.size())
! + (managedChildren.size()-1)*snapSpaceX(getSpacing());
}
private static double sum(double[] array, int size) {
int i = 0;
double res = 0;
*** 613,627 ****
Pos align = getAlignmentInternal();
HPos alignHpos = align.getHpos();
VPos alignVpos = align.getVpos();
double width = getWidth();
double height = getHeight();
! double top = snapSpace(insets.getTop());
! double left = snapSpace(insets.getLeft());
! double bottom = snapSpace(insets.getBottom());
! double right = snapSpace(insets.getRight());
! double space = snapSpace(getSpacing());
boolean shouldFillHeight = shouldFillHeight();
final double[][] actualAreaWidths = getAreaWidths(managed, height, false);
double contentWidth = adjustAreaWidths(managed, actualAreaWidths, width, height);
double contentHeight = height - top - bottom;
--- 613,627 ----
Pos align = getAlignmentInternal();
HPos alignHpos = align.getHpos();
VPos alignVpos = align.getVpos();
double width = getWidth();
double height = getHeight();
! double top = snapSpaceY(insets.getTop());
! double left = snapSpaceX(insets.getLeft());
! double bottom = snapSpaceY(insets.getBottom());
! double right = snapSpaceX(insets.getRight());
! double space = snapSpaceX(getSpacing());
boolean shouldFillHeight = shouldFillHeight();
final double[][] actualAreaWidths = getAreaWidths(managed, height, false);
double contentWidth = adjustAreaWidths(managed, actualAreaWidths, width, height);
double contentHeight = height - top - bottom;