protected Alignment createHorizontalLeading(Component me, Rectangle bounds, Container parent) {
int min = Integer.MIN_VALUE;
int pref = Integer.MIN_VALUE;
int count = parent.getComponentCount();
GroupLayout layout = (GroupLayout) parent.getLayout();
LayoutStyle layoutStyle = LayoutStyle.getInstance();
for (int i = 0; i < count; i++) {
Component target = parent.getComponent(i);
Constraints constraints = layout.getConstraints(target);
Rectangle targetBounds = target.getBounds();
if (constraints != null && isOverlap(bounds.y, bounds.height, targetBounds.y, targetBounds.height)) {
Alignment horizontal = constraints.getHorizontal();
Dimension prefs = target.getPreferredSize();
Dimension mins = target.getMinimumSize();
if (horizontal instanceof Trailing) {
int gap = layoutStyle.getPreferredGap((JComponent) target, (JComponent) me, ComponentPlacement.UNRELATED, SwingConstants.WEST, parent);
Trailing trailing = (Trailing) horizontal;
int pref_size = trailing.getSize() == Alignment.PREFERRED ? prefs.width : trailing.getSize();
int min_size = pref_size > mins.width ? mins.width : pref_size;
int actual = gap + min_size + trailing.getTrailing();
if (actual > min)
min = actual;
actual = gap + pref_size + trailing.getTrailing();
if (actual > pref)
pref = actual;
} else if (horizontal instanceof Bilateral) {
int gap = layoutStyle.getPreferredGap((JComponent) target, (JComponent) me, ComponentPlacement.RELATED, SwingConstants.WEST, parent);
Bilateral bilateral = (Bilateral) horizontal;
int actual = gap + mins.width + bilateral.getTrailing();
if (actual > min)
min = actual;
actual = gap + prefs.width + bilateral.getTrailing();
if (actual > pref)
pref = actual;
}
}
}
int gap = layoutStyle.getContainerGap((JComponent) me, SwingConstants.EAST, parent);
if (gap > min)
min = gap;
if (gap > pref)
pref = gap;
Spring spring = new Spring(min, pref);