1102 }
1103
1104 private Dimension adjustSize(int width, int height) {
1105 Insets insets = host.getInsets();
1106 return new Dimension(width + insets.left + insets.right,
1107 height + insets.top + insets.bottom);
1108 }
1109
1110 private void checkParent(Container parent) {
1111 if (parent != host) {
1112 throw new IllegalArgumentException(
1113 "GroupLayout can only be used with one Container at a time");
1114 }
1115 }
1116
1117 /**
1118 * Returns the {@code ComponentInfo} for the specified Component,
1119 * creating one if necessary.
1120 */
1121 private ComponentInfo getComponentInfo(Component component) {
1122 ComponentInfo info = (ComponentInfo)componentInfos.get(component);
1123 if (info == null) {
1124 info = new ComponentInfo(component);
1125 componentInfos.put(component, info);
1126 if (component.getParent() != host) {
1127 host.add(component);
1128 }
1129 }
1130 return info;
1131 }
1132
1133 /**
1134 * Adjusts the autopadding springs for the horizontal and vertical
1135 * groups. If {@code insert} is {@code true} this will insert auto padding
1136 * springs, otherwise this will only adjust the springs that
1137 * comprise auto preferred padding springs.
1138 */
1139 private void insertAutopadding(boolean insert) {
1140 horizontalGroup.insertAutopadding(HORIZONTAL,
1141 new ArrayList<AutoPreferredGapSpring>(1),
1142 new ArrayList<AutoPreferredGapSpring>(1),
1681 for (int counter = springs.size() - 1; counter >= 0; counter--) {
1682 Spring spring = springs.get(counter);
1683 if (spring instanceof AutoPreferredGapSpring) {
1684 if (((AutoPreferredGapSpring)spring).getUserCreated()) {
1685 ((AutoPreferredGapSpring)spring).reset();
1686 } else {
1687 springs.remove(counter);
1688 }
1689 } else if (spring instanceof Group) {
1690 ((Group)spring).removeAutopadding();
1691 }
1692 }
1693 }
1694
1695 void unsetAutopadding() {
1696 // Clear cached pref/min/max.
1697 unset();
1698 for (int counter = springs.size() - 1; counter >= 0; counter--) {
1699 Spring spring = springs.get(counter);
1700 if (spring instanceof AutoPreferredGapSpring) {
1701 ((AutoPreferredGapSpring)spring).unset();
1702 } else if (spring instanceof Group) {
1703 ((Group)spring).unsetAutopadding();
1704 }
1705 }
1706 }
1707
1708 void calculateAutopadding(int axis) {
1709 for (int counter = springs.size() - 1; counter >= 0; counter--) {
1710 Spring spring = springs.get(counter);
1711 if (spring instanceof AutoPreferredGapSpring) {
1712 // Force size to be reset.
1713 spring.unset();
1714 ((AutoPreferredGapSpring)spring).calculatePadding(axis);
1715 } else if (spring instanceof Group) {
1716 ((Group)spring).calculateAutopadding(axis);
1717 }
1718 }
1719 // Clear cached pref/min/max.
1720 unset();
1721 }
|
1102 }
1103
1104 private Dimension adjustSize(int width, int height) {
1105 Insets insets = host.getInsets();
1106 return new Dimension(width + insets.left + insets.right,
1107 height + insets.top + insets.bottom);
1108 }
1109
1110 private void checkParent(Container parent) {
1111 if (parent != host) {
1112 throw new IllegalArgumentException(
1113 "GroupLayout can only be used with one Container at a time");
1114 }
1115 }
1116
1117 /**
1118 * Returns the {@code ComponentInfo} for the specified Component,
1119 * creating one if necessary.
1120 */
1121 private ComponentInfo getComponentInfo(Component component) {
1122 ComponentInfo info = componentInfos.get(component);
1123 if (info == null) {
1124 info = new ComponentInfo(component);
1125 componentInfos.put(component, info);
1126 if (component.getParent() != host) {
1127 host.add(component);
1128 }
1129 }
1130 return info;
1131 }
1132
1133 /**
1134 * Adjusts the autopadding springs for the horizontal and vertical
1135 * groups. If {@code insert} is {@code true} this will insert auto padding
1136 * springs, otherwise this will only adjust the springs that
1137 * comprise auto preferred padding springs.
1138 */
1139 private void insertAutopadding(boolean insert) {
1140 horizontalGroup.insertAutopadding(HORIZONTAL,
1141 new ArrayList<AutoPreferredGapSpring>(1),
1142 new ArrayList<AutoPreferredGapSpring>(1),
1681 for (int counter = springs.size() - 1; counter >= 0; counter--) {
1682 Spring spring = springs.get(counter);
1683 if (spring instanceof AutoPreferredGapSpring) {
1684 if (((AutoPreferredGapSpring)spring).getUserCreated()) {
1685 ((AutoPreferredGapSpring)spring).reset();
1686 } else {
1687 springs.remove(counter);
1688 }
1689 } else if (spring instanceof Group) {
1690 ((Group)spring).removeAutopadding();
1691 }
1692 }
1693 }
1694
1695 void unsetAutopadding() {
1696 // Clear cached pref/min/max.
1697 unset();
1698 for (int counter = springs.size() - 1; counter >= 0; counter--) {
1699 Spring spring = springs.get(counter);
1700 if (spring instanceof AutoPreferredGapSpring) {
1701 spring.unset();
1702 } else if (spring instanceof Group) {
1703 ((Group)spring).unsetAutopadding();
1704 }
1705 }
1706 }
1707
1708 void calculateAutopadding(int axis) {
1709 for (int counter = springs.size() - 1; counter >= 0; counter--) {
1710 Spring spring = springs.get(counter);
1711 if (spring instanceof AutoPreferredGapSpring) {
1712 // Force size to be reset.
1713 spring.unset();
1714 ((AutoPreferredGapSpring)spring).calculatePadding(axis);
1715 } else if (spring instanceof Group) {
1716 ((Group)spring).calculateAutopadding(axis);
1717 }
1718 }
1719 // Clear cached pref/min/max.
1720 unset();
1721 }
|