in src/main/java/org/jetbrains/plugins/spotbugs/gui/common/MultiSplitLayout.java [492:572]
private void layoutGrow(final Split split, final Rectangle bounds) {
final Rectangle splitBounds = split.getBounds();
final ListIterator<Node> splitChildren = split.getChildren().listIterator();
final Node lastWeightedChild = split.lastWeightedChild();
/* Layout the Split's child Nodes' along the X axis. The bounds
* of each child will have the same y coordinate and height as the
* layoutGrow() bounds argument. Extra width is allocated to the
* to each child with a non-zero weight:
* newWidth = currentWidth + (extraWidth * splitChild.getWeight())
* Any extraWidth "left over" (that's availableWidth in the loop
* below) is given to the last child. Note that Dividers always
* have a weight of zero, and they're never the last child.
*/
if (split.isRowLayout()) {
double x = bounds.getX();
final double extraWidth = bounds.getWidth() - splitBounds.getWidth();
double availableWidth = extraWidth;
while (splitChildren.hasNext()) {
final Node splitChild = splitChildren.next();
final Rectangle splitChildBounds = splitChild.getBounds();
final double splitChildWeight = splitChild.getWeight();
if (!splitChildren.hasNext()) {
final double newWidth = bounds.getMaxX() - x;
final Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, newWidth);
layout2(splitChild, newSplitChildBounds);
} else if (availableWidth > 0.0 && splitChildWeight > 0.0) {
final double allocatedWidth = splitChild.equals(lastWeightedChild) ? availableWidth : Math.rint(splitChildWeight * extraWidth);
final double newWidth = splitChildBounds.getWidth() + allocatedWidth;
final Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, newWidth);
layout2(splitChild, newSplitChildBounds);
availableWidth -= allocatedWidth;
} else {
final double existingWidth = splitChildBounds.getWidth();
final Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, existingWidth);
layout2(splitChild, newSplitChildBounds);
}
x = splitChild.getBounds().getMaxX();
}
}
/* Layout the Split's child Nodes' along the Y axis. The bounds
* of each child will have the same x coordinate and width as the
* layoutGrow() bounds argument. Extra height is allocated to the
* to each child with a non-zero weight:
* newHeight = currentHeight + (extraHeight * splitChild.getWeight())
* Any extraHeight "left over" (that's availableHeight in the loop
* below) is given to the last child. Note that Dividers always
* have a weight of zero, and they're never the last child.
*/
else {
double y = bounds.getY();
final double extraHeight = bounds.getMaxY() - splitBounds.getHeight();
double availableHeight = extraHeight;
while (splitChildren.hasNext()) {
final Node splitChild = splitChildren.next();
final Rectangle splitChildBounds = splitChild.getBounds();
final double splitChildWeight = splitChild.getWeight();
if (!splitChildren.hasNext()) {
final double newHeight = bounds.getMaxY() - y;
final Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, newHeight);
layout2(splitChild, newSplitChildBounds);
} else if (availableHeight > 0.0 && splitChildWeight > 0.0) {
final double allocatedHeight = splitChild.equals(lastWeightedChild) ? availableHeight : Math.rint(splitChildWeight * extraHeight);
final double newHeight = splitChildBounds.getHeight() + allocatedHeight;
final Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, newHeight);
layout2(splitChild, newSplitChildBounds);
availableHeight -= allocatedHeight;
} else {
final double existingHeight = splitChildBounds.getHeight();
final Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, existingHeight);
layout2(splitChild, newSplitChildBounds);
}
y = splitChild.getBounds().getMaxY();
}
}
}