/** * Sets the <code>x</code> property, * which controls the <code>x</code> value * of a component's location. * * @param x the spring controlling the <code>x</code> value * of a component's location * * @see #getX * @see SpringLayout.Constraints */ public void setX(Spring x) { this.x = x; pushConstraint(WEST, x, true); } /** * Returns the value of the <code>x</code> property. * * @return the spring controlling the <code>x</code> value * of a component's location * * @see #setX * @see SpringLayout.Constraints */ public Spring getX() { if (x == null) { if (defined(horizontalHistory, EAST, WIDTH)) { x = difference(east, width); } else if (defined(horizontalHistory, HORIZONTAL_CENTER, WIDTH)) { x = difference(horizontalCenter, scale(width, 0.5f)); } else if (defined(horizontalHistory, HORIZONTAL_CENTER, EAST)) { x = difference(scale(horizontalCenter, 2f), east); } } return x; } /** * Sets the <code>y</code> property, * which controls the <code>y</code> value * of a component's location. * * @param y the spring controlling the <code>y</code> value * of a component's location * * @see #getY * @see SpringLayout.Constraints */ public void setY(Spring y) { this.y = y; pushConstraint(NORTH, y, false); } /** * Returns the value of the <code>y</code> property. * * @return the spring controlling the <code>y</code> value * of a component's location * * @see #setY * @see SpringLayout.Constraints */ public Spring getY() { if (y == null) { if (defined(verticalHistory, SOUTH, HEIGHT)) { y = difference(south, height); } else if (defined(verticalHistory, VERTICAL_CENTER, HEIGHT)) { y = difference(verticalCenter, scale(height, 0.5f)); } else if (defined(verticalHistory, VERTICAL_CENTER, SOUTH)) { y = difference(scale(verticalCenter, 2f), south); } else if (defined(verticalHistory, BASELINE, HEIGHT)) { y = difference(baseline, heightToRelativeBaseline(height)); } else if (defined(verticalHistory, BASELINE, SOUTH)) { y = scale(difference(baseline, heightToRelativeBaseline(south)), 2f);/* } else if (defined(verticalHistory, BASELINE, VERTICAL_CENTER)) { y = scale(difference(baseline, heightToRelativeBaseline(scale(verticalCenter, 2))), 1f/(1-2*0.5f));*/ } } return y; } /** * Sets the <code>width</code> property, * which controls the width of a component. * * @param width the spring controlling the width of this * <code>Constraints</code> object * * @see #getWidth * @see SpringLayout.Constraints */ public void setWidth(Spring width) { this.width = width; pushConstraint(WIDTH, width, true); } /** * Returns the value of the <code>width</code> property. * * @return the spring controlling the width of a component * * @see #setWidth * @see SpringLayout.Constraints */ public Spring getWidth() { if (width == null) { if (horizontalHistory.contains(EAST)) { width = difference(east, getX()); } else if (horizontalHistory.contains(HORIZONTAL_CENTER)) { width = scale(difference(horizontalCenter, getX()), 2f); } } return width; } /** * Sets the <code>height</code> property, * which controls the height of a component. * * @param height the spring controlling the height of this <code>Constraints</code> * object * * @see #getHeight * @see SpringLayout.Constraints */ public void setHeight(Spring height) { this.height = height; pushConstraint(HEIGHT, height, false); } /** * Returns the value of the <code>height</code> property. * * @return the spring controlling the height of a component * * @see #setHeight * @see SpringLayout.Constraints */ public Spring getHeight() { if (height == null) { if (verticalHistory.contains(SOUTH)) { height = difference(south, getY()); } else if (verticalHistory.contains(VERTICAL_CENTER)) { height = scale(difference(verticalCenter, getY()), 2f); } else if (verticalHistory.contains(BASELINE)) { height = relativeBaselineToHeight(difference(baseline, getY())); } } return height; } private void setEast(Spring east) { this.east = east; pushConstraint(EAST, east, true); } private Spring getEast() { if (east == null) { east = sum(getX(), getWidth()); } return east; } private void setSouth(Spring south) { this.south = south; pushConstraint(SOUTH, south, false); } private Spring getSouth() { if (south == null) { south = sum(getY(), getHeight()); } return south; } private Spring getHorizontalCenter() { if (horizontalCenter == null) { horizontalCenter = sum(getX(), scale(getWidth(), 0.5f)); } return horizontalCenter; } private void setHorizontalCenter(Spring horizontalCenter) { this.horizontalCenter = horizontalCenter; pushConstraint(HORIZONTAL_CENTER, horizontalCenter, true); } private Spring getVerticalCenter() { if (verticalCenter == null) { verticalCenter = sum(getY(), scale(getHeight(), 0.5f)); } return verticalCenter; } private void setVerticalCenter(Spring verticalCenter) { this.verticalCenter = verticalCenter; pushConstraint(VERTICAL_CENTER, verticalCenter, false); } private Spring getBaseline() { if (baseline == null) { baseline = sum(getY(), heightToRelativeBaseline(getHeight())); } return baseline; } private void setBaseline(Spring baseline) { this.baseline = baseline; pushConstraint(BASELINE, baseline, false); } /** * Sets the spring controlling the specified edge. * The edge must have one of the following values: * <code>SpringLayout.NORTH</code>, * <code>SpringLayout.SOUTH</code>, * <code>SpringLayout.EAST</code>, * <code>SpringLayout.WEST</code>, * <code>SpringLayout.HORIZONTAL_CENTER</code>, * <code>SpringLayout.VERTICAL_CENTER</code>, * <code>SpringLayout.BASELINE</code>, * <code>SpringLayout.WIDTH</code> or * <code>SpringLayout.HEIGHT</code>. * For any other <code>String</code> value passed as the edge, * no action is taken. For a <code>null</code> edge, a * <code>NullPointerException</code> is thrown. * <p/> * <b>Note:</b> This method can affect {@code x} and {@code y} values * previously set for this {@code Constraints}. * * @param edgeName the edge to be set * @param s the spring controlling the specified edge * * @throws NullPointerException if <code>edgeName</code> is <code>null</code> * * @see #getConstraint * @see #NORTH * @see #SOUTH * @see #EAST * @see #WEST * @see #HORIZONTAL_CENTER * @see #VERTICAL_CENTER * @see #BASELINE * @see #WIDTH * @see #HEIGHT * @see SpringLayout.Constraints */ public void setConstraint(String edgeName, Spring s) { edgeName = edgeName.intern(); if (edgeName == WEST) { setX(s); } else if (edgeName == NORTH) { setY(s); } else if (edgeName == EAST) { setEast(s); } else if (edgeName == SOUTH) { setSouth(s); } else if (edgeName == HORIZONTAL_CENTER) { setHorizontalCenter(s); } else if (edgeName == WIDTH) { setWidth(s); } else if (edgeName == HEIGHT) { setHeight(s); } else if (edgeName == VERTICAL_CENTER) { setVerticalCenter(s); } else if (edgeName == BASELINE) { setBaseline(s); } } /** * Returns the value of the specified edge, which may be * a derived value, or even <code>null</code>. * The edge must have one of the following values: * <code>SpringLayout.NORTH</code>, * <code>SpringLayout.SOUTH</code>, * <code>SpringLayout.EAST</code>, * <code>SpringLayout.WEST</code>, * <code>SpringLayout.HORIZONTAL_CENTER</code>, * <code>SpringLayout.VERTICAL_CENTER</code>, * <code>SpringLayout.BASELINE</code>, * <code>SpringLayout.WIDTH</code> or * <code>SpringLayout.HEIGHT</code>. * For any other <code>String</code> value passed as the edge, * <code>null</code> will be returned. Throws * <code>NullPointerException</code> for a <code>null</code> edge. * * @param edgeName the edge whose value * is to be returned * * @return the spring controlling the specified edge, may be <code>null</code> * * @throws NullPointerException if <code>edgeName</code> is <code>null</code> * * @see #setConstraint * @see #NORTH * @see #SOUTH * @see #EAST * @see #WEST * @see #HORIZONTAL_CENTER * @see #VERTICAL_CENTER * @see #BASELINE * @see #WIDTH * @see #HEIGHT * @see SpringLayout.Constraints */ public Spring getConstraint(String edgeName) { edgeName = edgeName.intern(); return (edgeName == WEST) ? getX() : (edgeName == NORTH) ? getY() : (edgeName == EAST) ? getEast() : (edgeName == SOUTH) ? getSouth() : (edgeName == WIDTH) ? getWidth() : (edgeName == HEIGHT) ? getHeight() : (edgeName == HORIZONTAL_CENTER) ? getHorizontalCenter() : (edgeName == VERTICAL_CENTER) ? getVerticalCenter() : (edgeName == BASELINE) ? getBaseline() : null; } /*pp*/ void reset() { Spring[] allSprings = {x, y, width, height, east, south, horizontalCenter, verticalCenter, baseline}; for (Spring s : allSprings) { if (s != null) { s.setValue(Spring.UNSET); } } } } private static class SpringProxy extends Spring { private String edgeName; private Component c; private SpringLayout l; public SpringProxy(String edgeName, Component c, SpringLayout l) { this.edgeName = edgeName; this.c = c; this.l = l; } private Spring getConstraint() { return l.getConstraints(c).getConstraint(edgeName); } public int getMinimumValue() { return getConstraint().getMinimumValue(); } public int getPreferredValue() { return getConstraint().getPreferredValue(); } public int getMaximumValue() { return getConstraint().getMaximumValue(); } public int getValue() { return getConstraint().getValue(); } public void setValue(int size) { getConstraint().setValue(size); } /*pp*/ boolean isCyclic(SpringLayout l) { return l.isCyclic(getConstraint()); } public String toString() { return "SpringProxy for " + edgeName + " edge of " + c.getName() + "."; } } /** * Constructs a new <code>SpringLayout</code>. */ public SpringLayout() {} private void resetCyclicStatuses() { cyclicSprings = new HashSet<Spring>(); acyclicSprings = new HashSet<Spring>(); } private void setParent(Container p) { resetCyclicStatuses(); Constraints pc = getConstraints(p); pc.setX(Spring.constant(0)); pc.setY(Spring.constant(0)); // The applyDefaults() method automatically adds width and // height springs that delegate their calculations to the // getMinimumSize(), getPreferredSize() and getMaximumSize() // methods of the relevant component. In the case of the // parent this will cause an infinite loop since these // methods, in turn, delegate their calculations to the // layout manager. Check for this case and replace the // the springs that would cause this problem with a // constant springs that supply default values. Spring width = pc.getWidth(); if (width instanceof Spring.WidthSpring && ((Spring.WidthSpring)width).c == p) { pc.setWidth(Spring.constant(0, 0, Integer.MAX_VALUE)); } Spring height = pc.getHeight(); if (height instanceof Spring.HeightSpring && ((Spring.HeightSpring)height).c == p) { pc.setHeight(Spring.constant(0, 0, Integer.MAX_VALUE)); } } /*pp*/ boolean isCyclic(Spring s) { if (s == null) { return false; } if (cyclicSprings.contains(s)) { return true; } if (acyclicSprings.contains(s)) { return false; } cyclicSprings.add(s); boolean result = s.isCyclic(this); if (!result) { acyclicSprings.add(s); cyclicSprings.remove(s); } else { System.err.println(s + " is cyclic. "); } return result; } private Spring abandonCycles(Spring s) { return isCyclic(s) ? cyclicReference : s; } // LayoutManager methods. /** * Has no effect, * since this layout manager does not * use a per-component string. */ public void addLayoutComponent(String name, Component c) {} /** * Removes the constraints associated with the specified component. * * @param c the component being removed from the container */ public void removeLayoutComponent(Component c) { componentConstraints.remove(c); } private static Dimension addInsets(int width, int height, Container p) { Insets i = p.getInsets(); return new Dimension(width + i.left + i.right, height + i.top + i.bottom); } public Dimension minimumLayoutSize(Container parent) { setParent(parent); Constraints pc = getConstraints(parent); return addInsets(abandonCycles(pc.getWidth()).getMinimumValue(), abandonCycles(pc.getHeight()).getMinimumValue(), parent); } public Dimension preferredLayoutSize(Container parent) { setParent(parent); Constraints pc = getConstraints(parent); return addInsets(abandonCycles(pc.getWidth()).getPreferredValue(), abandonCycles(pc.getHeight()).getPreferredValue(), parent); } // LayoutManager2 methods. public Dimension maximumLayoutSize(Container parent) { setParent(parent); Constraints pc = getConstraints(parent); return addInsets(abandonCycles(pc.getWidth()).getMaximumValue(), abandonCycles(pc.getHeight()).getMaximumValue(), parent); } /** * If <code>constraints</code> is an instance of * <code>SpringLayout.Constraints</code>, * associates the constraints with the specified component. * <p> * @param component the component being added * @param constraints the component's constraints * * @see SpringLayout.Constraints */ public void addLayoutComponent(Component component, Object constraints) { if (constraints instanceof Constraints) {Lines 501–1000 of 1233. Previous lines Load more
/** * Sets the <code>x</code> property, * which controls the <code>x</code> value * of a component's location. * * @param x the spring controlling the <code>x</code> value * of a component's location * * @see #getX * @see SpringLayout.Constraints */ public void setX(Spring x) { this.x = x; pushConstraint(WEST, x, true); } /** * Returns the value of the <code>x</code> property. * * @return the spring controlling the <code>x</code> value * of a component's location * * @see #setX * @see SpringLayout.Constraints */ public Spring getX() { if (x == null) { if (defined(horizontalHistory, EAST, WIDTH)) { x = difference(east, width); } else if (defined(horizontalHistory, HORIZONTAL_CENTER, WIDTH)) { x = difference(horizontalCenter, scale(width, 0.5f)); } else if (defined(horizontalHistory, HORIZONTAL_CENTER, EAST)) { x = difference(scale(horizontalCenter, 2f), east); } } return x; } /** * Sets the <code>y</code> property, * which controls the <code>y</code> value * of a component's location. * * @param y the spring controlling the <code>y</code> value * of a component's location * * @see #getY * @see SpringLayout.Constraints */ public void setY(Spring y) { this.y = y; pushConstraint(NORTH, y, false); } /** * Returns the value of the <code>y</code> property. * * @return the spring controlling the <code>y</code> value * of a component's location * * @see #setY * @see SpringLayout.Constraints */ public Spring getY() { if (y == null) { if (defined(verticalHistory, SOUTH, HEIGHT)) { y = difference(south, height); } else if (defined(verticalHistory, VERTICAL_CENTER, HEIGHT)) { y = difference(verticalCenter, scale(height, 0.5f)); } else if (defined(verticalHistory, VERTICAL_CENTER, SOUTH)) { y = difference(scale(verticalCenter, 2f), south); } else if (defined(verticalHistory, BASELINE, HEIGHT)) { y = difference(baseline, heightToRelativeBaseline(height)); } else if (defined(verticalHistory, BASELINE, SOUTH)) { y = scale(difference(baseline, heightToRelativeBaseline(south)), 2f); /* } else if (defined(verticalHistory, BASELINE, VERTICAL_CENTER)) { y = scale(difference(baseline, heightToRelativeBaseline(scale(verticalCenter, 2))), 1f/(1-2*0.5f)); */ } } return y; } /** * Sets the <code>width</code> property, * which controls the width of a component. * * @param width the spring controlling the width of this * <code>Constraints</code> object * * @see #getWidth * @see SpringLayout.Constraints */ public void setWidth(Spring width) { this.width = width; pushConstraint(WIDTH, width, true); } /** * Returns the value of the <code>width</code> property. * * @return the spring controlling the width of a component * * @see #setWidth * @see SpringLayout.Constraints */ public Spring getWidth() { if (width == null) { if (horizontalHistory.contains(EAST)) { width = difference(east, getX()); } else if (horizontalHistory.contains(HORIZONTAL_CENTER)) { width = scale(difference(horizontalCenter, getX()), 2f); } } return width; } /** * Sets the <code>height</code> property, * which controls the height of a component. * * @param height the spring controlling the height of this <code>Constraints</code> * object * * @see #getHeight * @see SpringLayout.Constraints */ public void setHeight(Spring height) { this.height = height; pushConstraint(HEIGHT, height, false); } /** * Returns the value of the <code>height</code> property. * * @return the spring controlling the height of a component * * @see #setHeight * @see SpringLayout.Constraints */ public Spring getHeight() { if (height == null) { if (verticalHistory.contains(SOUTH)) { height = difference(south, getY()); } else if (verticalHistory.contains(VERTICAL_CENTER)) { height = scale(difference(verticalCenter, getY()), 2f); } else if (verticalHistory.contains(BASELINE)) { height = relativeBaselineToHeight(difference(baseline, getY())); } } return height; } private void setEast(Spring east) { this.east = east; pushConstraint(EAST, east, true); } private Spring getEast() { if (east == null) { east = sum(getX(), getWidth()); } return east; } private void setSouth(Spring south) { this.south = south; pushConstraint(SOUTH, south, false); } private Spring getSouth() { if (south == null) { south = sum(getY(), getHeight()); } return south; } private Spring getHorizontalCenter() { if (horizontalCenter == null) { horizontalCenter = sum(getX(), scale(getWidth(), 0.5f)); } return horizontalCenter; } private void setHorizontalCenter(Spring horizontalCenter) { this.horizontalCenter = horizontalCenter; pushConstraint(HORIZONTAL_CENTER, horizontalCenter, true); } private Spring getVerticalCenter() { if (verticalCenter == null) { verticalCenter = sum(getY(), scale(getHeight(), 0.5f)); } return verticalCenter; } private void setVerticalCenter(Spring verticalCenter) { this.verticalCenter = verticalCenter; pushConstraint(VERTICAL_CENTER, verticalCenter, false); } private Spring getBaseline() { if (baseline == null) { baseline = sum(getY(), heightToRelativeBaseline(getHeight())); } return baseline; } private void setBaseline(Spring baseline) { this.baseline = baseline; pushConstraint(BASELINE, baseline, false); } /** * Sets the spring controlling the specified edge. * The edge must have one of the following values: * <code>SpringLayout.NORTH</code>, * <code>SpringLayout.SOUTH</code>, * <code>SpringLayout.EAST</code>, * <code>SpringLayout.WEST</code>, * <code>SpringLayout.HORIZONTAL_CENTER</code>, * <code>SpringLayout.VERTICAL_CENTER</code>, * <code>SpringLayout.BASELINE</code>, * <code>SpringLayout.WIDTH</code> or * <code>SpringLayout.HEIGHT</code>. * For any other <code>String</code> value passed as the edge, * no action is taken. For a <code>null</code> edge, a * <code>NullPointerException</code> is thrown. * <p/> * <b>Note:</b> This method can affect {@code x} and {@code y} values * previously set for this {@code Constraints}. * * @param edgeName the edge to be set * @param s the spring controlling the specified edge * * @throws NullPointerException if <code>edgeName</code> is <code>null</code> * * @see #getConstraint * @see #NORTH * @see #SOUTH * @see #EAST * @see #WEST * @see #HORIZONTAL_CENTER * @see #VERTICAL_CENTER * @see #BASELINE * @see #WIDTH * @see #HEIGHT * @see SpringLayout.Constraints */ public void setConstraint(String edgeName, Spring s) { edgeName = edgeName.intern(); if (edgeName == WEST) { setX(s); } else if (edgeName == NORTH) { setY(s); } else if (edgeName == EAST) { setEast(s); } else if (edgeName == SOUTH) { setSouth(s); } else if (edgeName == HORIZONTAL_CENTER) { setHorizontalCenter(s); } else if (edgeName == WIDTH) { setWidth(s); } else if (edgeName == HEIGHT) { setHeight(s); } else if (edgeName == VERTICAL_CENTER) { setVerticalCenter(s); } else if (edgeName == BASELINE) { setBaseline(s); } } /** * Returns the value of the specified edge, which may be * a derived value, or even <code>null</code>. * The edge must have one of the following values: * <code>SpringLayout.NORTH</code>, * <code>SpringLayout.SOUTH</code>, * <code>SpringLayout.EAST</code>, * <code>SpringLayout.WEST</code>, * <code>SpringLayout.HORIZONTAL_CENTER</code>, * <code>SpringLayout.VERTICAL_CENTER</code>, * <code>SpringLayout.BASELINE</code>, * <code>SpringLayout.WIDTH</code> or * <code>SpringLayout.HEIGHT</code>. * For any other <code>String</code> value passed as the edge, * <code>null</code> will be returned. Throws * <code>NullPointerException</code> for a <code>null</code> edge. * * @param edgeName the edge whose value * is to be returned * * @return the spring controlling the specified edge, may be <code>null</code> * * @throws NullPointerException if <code>edgeName</code> is <code>null</code> * * @see #setConstraint * @see #NORTH * @see #SOUTH * @see #EAST * @see #WEST * @see #HORIZONTAL_CENTER * @see #VERTICAL_CENTER * @see #BASELINE * @see #WIDTH * @see #HEIGHT * @see SpringLayout.Constraints */ public Spring getConstraint(String edgeName) { edgeName = edgeName.intern(); return (edgeName == WEST) ? getX() : (edgeName == NORTH) ? getY() : (edgeName == EAST) ? getEast() : (edgeName == SOUTH) ? getSouth() : (edgeName == WIDTH) ? getWidth() : (edgeName == HEIGHT) ? getHeight() : (edgeName == HORIZONTAL_CENTER) ? getHorizontalCenter() : (edgeName == VERTICAL_CENTER) ? getVerticalCenter() : (edgeName == BASELINE) ? getBaseline() : null; } /*pp*/ void reset() { Spring[] allSprings = {x, y, width, height, east, south, horizontalCenter, verticalCenter, baseline}; for (Spring s : allSprings) { if (s != null) { s.setValue(Spring.UNSET); } } } } private static class SpringProxy extends Spring { private String edgeName; private Component c; private SpringLayout l; public SpringProxy(String edgeName, Component c, SpringLayout l) { this.edgeName = edgeName; this.c = c; this.l = l; } private Spring getConstraint() { return l.getConstraints(c).getConstraint(edgeName); } public int getMinimumValue() { return getConstraint().getMinimumValue(); } public int getPreferredValue() { return getConstraint().getPreferredValue(); } public int getMaximumValue() { return getConstraint().getMaximumValue(); } public int getValue() { return getConstraint().getValue(); } public void setValue(int size) { getConstraint().setValue(size); } /*pp*/ boolean isCyclic(SpringLayout l) { return l.isCyclic(getConstraint()); } public String toString() { return "SpringProxy for " + edgeName + " edge of " + c.getName() + "."; } } /** * Constructs a new <code>SpringLayout</code>. */ public SpringLayout() {} private void resetCyclicStatuses() { cyclicSprings = new HashSet<Spring>(); acyclicSprings = new HashSet<Spring>(); } private void setParent(Container p) { resetCyclicStatuses(); Constraints pc = getConstraints(p); pc.setX(Spring.constant(0)); pc.setY(Spring.constant(0)); // The applyDefaults() method automatically adds width and // height springs that delegate their calculations to the // getMinimumSize(), getPreferredSize() and getMaximumSize() // methods of the relevant component. In the case of the // parent this will cause an infinite loop since these // methods, in turn, delegate their calculations to the // layout manager. Check for this case and replace the // the springs that would cause this problem with a // constant springs that supply default values. Spring width = pc.getWidth(); if (width instanceof Spring.WidthSpring && ((Spring.WidthSpring)width).c == p) { pc.setWidth(Spring.constant(0, 0, Integer.MAX_VALUE)); } Spring height = pc.getHeight(); if (height instanceof Spring.HeightSpring && ((Spring.HeightSpring)height).c == p) { pc.setHeight(Spring.constant(0, 0, Integer.MAX_VALUE)); } } /*pp*/ boolean isCyclic(Spring s) { if (s == null) { return false; } if (cyclicSprings.contains(s)) { return true; } if (acyclicSprings.contains(s)) { return false; } cyclicSprings.add(s); boolean result = s.isCyclic(this); if (!result) { acyclicSprings.add(s); cyclicSprings.remove(s); } else { System.err.println(s + " is cyclic. "); } return result; } private Spring abandonCycles(Spring s) { return isCyclic(s) ? cyclicReference : s; } // LayoutManager methods. /** * Has no effect, * since this layout manager does not * use a per-component string. */ public void addLayoutComponent(String name, Component c) {} /** * Removes the constraints associated with the specified component. * * @param c the component being removed from the container */ public void removeLayoutComponent(Component c) { componentConstraints.remove(c); } private static Dimension addInsets(int width, int height, Container p) { Insets i = p.getInsets(); return new Dimension(width + i.left + i.right, height + i.top + i.bottom); } public Dimension minimumLayoutSize(Container parent) { setParent(parent); Constraints pc = getConstraints(parent); return addInsets(abandonCycles(pc.getWidth()).getMinimumValue(), abandonCycles(pc.getHeight()).getMinimumValue(), parent); } public Dimension preferredLayoutSize(Container parent) { setParent(parent); Constraints pc = getConstraints(parent); return addInsets(abandonCycles(pc.getWidth()).getPreferredValue(), abandonCycles(pc.getHeight()).getPreferredValue(), parent); } // LayoutManager2 methods. public Dimension maximumLayoutSize(Container parent) { setParent(parent); Constraints pc = getConstraints(parent); return addInsets(abandonCycles(pc.getWidth()).getMaximumValue(), abandonCycles(pc.getHeight()).getMaximumValue(), parent); } /** * If <code>constraints</code> is an instance of * <code>SpringLayout.Constraints</code>, * associates the constraints with the specified component. * <p> * @param component the component being added * @param constraints the component's constraints * * @see SpringLayout.Constraints */ public void addLayoutComponent(Component component, Object constraints) { if (constraints instanceof Constraints) {