< prev index next >

src/java.desktop/share/classes/javax/swing/SpringLayout.java

Print this page

        

*** 32,50 **** import java.awt.LayoutManager2; import java.awt.Rectangle; import java.util.*; /** ! * A <code>SpringLayout</code> lays out the children of its associated container * according to a set of constraints. * See <a href="http://docs.oracle.com/javase/tutorial/uiswing/layout/spring.html">How to Use SpringLayout</a> * in <em>The Java Tutorial</em> for examples of using ! * <code>SpringLayout</code>. * * <p> * Each constraint, ! * represented by a <code>Spring</code> object, * controls the vertical or horizontal distance * between two component edges. * The edges can belong to * any child of the container, * or to the container itself. --- 32,50 ---- import java.awt.LayoutManager2; import java.awt.Rectangle; import java.util.*; /** ! * A {@code SpringLayout} lays out the children of its associated container * according to a set of constraints. * See <a href="http://docs.oracle.com/javase/tutorial/uiswing/layout/spring.html">How to Use SpringLayout</a> * in <em>The Java Tutorial</em> for examples of using ! * {@code SpringLayout}. * * <p> * Each constraint, ! * represented by a {@code Spring} object, * controls the vertical or horizontal distance * between two component edges. * The edges can belong to * any child of the container, * or to the container itself.
*** 57,132 **** * can be expressed by constraining the distance between * the north (top) edge of the component * and the north edge of its container. * * <P> ! * Every child of a <code>SpringLayout</code>-controlled container, * as well as the container itself, * has exactly one set of constraints * associated with it. * These constraints are represented by ! * a <code>SpringLayout.Constraints</code> object. * By default, ! * <code>SpringLayout</code> creates constraints * that make their associated component * have the minimum, preferred, and maximum sizes * returned by the component's * {@link java.awt.Component#getMinimumSize}, * {@link java.awt.Component#getPreferredSize}, and * {@link java.awt.Component#getMaximumSize} * methods. The <em>x</em> and <em>y</em> positions are initially not ! * constrained, so that until you constrain them the <code>Component</code> ! * will be positioned at 0,0 relative to the <code>Insets</code> of the ! * parent <code>Container</code>. * * <p> * You can change * a component's constraints in several ways. * You can * use one of the * {@link #putConstraint putConstraint} * methods * to establish a spring * linking the edges of two components within the same container. ! * Or you can get the appropriate <code>SpringLayout.Constraints</code> * object using * {@link #getConstraints getConstraints} * and then modify one or more of its springs. * Or you can get the spring for a particular edge of a component * using {@link #getConstraint getConstraint}, * and modify it. * You can also associate ! * your own <code>SpringLayout.Constraints</code> object * with a component by specifying the constraints object * when you add the component to its container * (using * {@link Container#add(Component, Object)}). * * <p> ! * The <code>Spring</code> object representing each constraint * has a minimum, preferred, maximum, and current value. * The current value of the spring * is somewhere between the minimum and maximum values, * according to the formula given in the * {@link Spring#sum} method description. * When the minimum, preferred, and maximum values are the same, * the current value is always equal to them; * this inflexible spring is called a <em>strut</em>. * You can create struts using the factory method * {@link Spring#constant(int)}. ! * The <code>Spring</code> class also provides factory methods * for creating other kinds of springs, * including springs that depend on other springs. * * <p> ! * In a <code>SpringLayout</code>, the position of each edge is dependent on * the position of just one other edge. If a constraint is subsequently added * to create a new binding for an edge, the previous binding is discarded * and the edge remains dependent on a single edge. * Springs should only be attached * between edges of the container and its immediate children; the behavior ! * of the <code>SpringLayout</code> when presented with constraints linking * the edges of components from different containers (either internal or * external) is undefined. * * <h3> * SpringLayout vs. Other Layout Managers --- 57,132 ---- * can be expressed by constraining the distance between * the north (top) edge of the component * and the north edge of its container. * * <P> ! * Every child of a {@code SpringLayout}-controlled container, * as well as the container itself, * has exactly one set of constraints * associated with it. * These constraints are represented by ! * a {@code SpringLayout.Constraints} object. * By default, ! * {@code SpringLayout} creates constraints * that make their associated component * have the minimum, preferred, and maximum sizes * returned by the component's * {@link java.awt.Component#getMinimumSize}, * {@link java.awt.Component#getPreferredSize}, and * {@link java.awt.Component#getMaximumSize} * methods. The <em>x</em> and <em>y</em> positions are initially not ! * constrained, so that until you constrain them the {@code Component} ! * will be positioned at 0,0 relative to the {@code Insets} of the ! * parent {@code Container}. * * <p> * You can change * a component's constraints in several ways. * You can * use one of the * {@link #putConstraint putConstraint} * methods * to establish a spring * linking the edges of two components within the same container. ! * Or you can get the appropriate {@code SpringLayout.Constraints} * object using * {@link #getConstraints getConstraints} * and then modify one or more of its springs. * Or you can get the spring for a particular edge of a component * using {@link #getConstraint getConstraint}, * and modify it. * You can also associate ! * your own {@code SpringLayout.Constraints} object * with a component by specifying the constraints object * when you add the component to its container * (using * {@link Container#add(Component, Object)}). * * <p> ! * The {@code Spring} object representing each constraint * has a minimum, preferred, maximum, and current value. * The current value of the spring * is somewhere between the minimum and maximum values, * according to the formula given in the * {@link Spring#sum} method description. * When the minimum, preferred, and maximum values are the same, * the current value is always equal to them; * this inflexible spring is called a <em>strut</em>. * You can create struts using the factory method * {@link Spring#constant(int)}. ! * The {@code Spring} class also provides factory methods * for creating other kinds of springs, * including springs that depend on other springs. * * <p> ! * In a {@code SpringLayout}, the position of each edge is dependent on * the position of just one other edge. If a constraint is subsequently added * to create a new binding for an edge, the previous binding is discarded * and the edge remains dependent on a single edge. * Springs should only be attached * between edges of the container and its immediate children; the behavior ! * of the {@code SpringLayout} when presented with constraints linking * the edges of components from different containers (either internal or * external) is undefined. * * <h3> * SpringLayout vs. Other Layout Managers
*** 134,181 **** * * <blockquote> * <hr> * <strong>Note:</strong> * Unlike many layout managers, ! * <code>SpringLayout</code> doesn't automatically set the location of * the components it manages. ! * If you hand-code a GUI that uses <code>SpringLayout</code>, * remember to initialize component locations by constraining the west/east * and north/south locations. * <p> * Depending on the constraints you use, * you may also need to set the size of the container explicitly. * <hr> * </blockquote> * * <p> ! * Despite the simplicity of <code>SpringLayout</code>, * it can emulate the behavior of most other layout managers. * For some features, ! * such as the line breaking provided by <code>FlowLayout</code>, * you'll need to ! * create a special-purpose subclass of the <code>Spring</code> class. * * <p> ! * <code>SpringLayout</code> also provides a way to solve * many of the difficult layout * problems that cannot be solved by nesting combinations ! * of <code>Box</code>es. That said, <code>SpringLayout</code> honors the ! * <code>LayoutManager2</code> contract correctly and so can be nested with * other layout managers -- a technique that can be preferable to * creating the constraints implied by the other layout managers. * <p> ! * The asymptotic complexity of the layout operation of a <code>SpringLayout</code> * is linear in the number of constraints (and/or components). * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @see Spring * @see SpringLayout.Constraints * --- 134,181 ---- * * <blockquote> * <hr> * <strong>Note:</strong> * Unlike many layout managers, ! * {@code SpringLayout} doesn't automatically set the location of * the components it manages. ! * If you hand-code a GUI that uses {@code SpringLayout}, * remember to initialize component locations by constraining the west/east * and north/south locations. * <p> * Depending on the constraints you use, * you may also need to set the size of the container explicitly. * <hr> * </blockquote> * * <p> ! * Despite the simplicity of {@code SpringLayout}, * it can emulate the behavior of most other layout managers. * For some features, ! * such as the line breaking provided by {@code FlowLayout}, * you'll need to ! * create a special-purpose subclass of the {@code Spring} class. * * <p> ! * {@code SpringLayout} also provides a way to solve * many of the difficult layout * problems that cannot be solved by nesting combinations ! * of {@code Box}es. That said, {@code SpringLayout} honors the ! * {@code LayoutManager2} contract correctly and so can be nested with * other layout managers -- a technique that can be preferable to * creating the constraints implied by the other layout managers. * <p> ! * The asymptotic complexity of the layout operation of a {@code SpringLayout} * is linear in the number of constraints (and/or components). * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. * * @see Spring * @see SpringLayout.Constraints *
*** 251,279 **** private static String[] ALL_HORIZONTAL = {WEST, WIDTH, EAST, HORIZONTAL_CENTER}; private static String[] ALL_VERTICAL = {NORTH, HEIGHT, SOUTH, VERTICAL_CENTER, BASELINE}; /** ! * A <code>Constraints</code> object holds the * constraints that govern the way a component's size and position ! * change in a container controlled by a <code>SpringLayout</code>. ! * A <code>Constraints</code> object is ! * like a <code>Rectangle</code>, in that it ! * has <code>x</code>, <code>y</code>, ! * <code>width</code>, and <code>height</code> properties. ! * In the <code>Constraints</code> object, however, * these properties have ! * <code>Spring</code> values instead of integers. * In addition, ! * a <code>Constraints</code> object * can be manipulated as four edges * -- north, south, east, and west -- ! * using the <code>constraint</code> property. * * <p> * The following formulas are always true ! * for a <code>Constraints</code> object (here WEST and <code>x</code> are synonyms, as are and NORTH and <code>y</code>): * * <pre> * EAST = WEST + WIDTH * SOUTH = NORTH + HEIGHT * HORIZONTAL_CENTER = WEST + WIDTH/2 --- 251,279 ---- private static String[] ALL_HORIZONTAL = {WEST, WIDTH, EAST, HORIZONTAL_CENTER}; private static String[] ALL_VERTICAL = {NORTH, HEIGHT, SOUTH, VERTICAL_CENTER, BASELINE}; /** ! * A {@code Constraints} object holds the * constraints that govern the way a component's size and position ! * change in a container controlled by a {@code SpringLayout}. ! * A {@code Constraints} object is ! * like a {@code Rectangle}, in that it ! * has {@code x}, {@code y}, ! * {@code width}, and {@code height} properties. ! * In the {@code Constraints} object, however, * these properties have ! * {@code Spring} values instead of integers. * In addition, ! * a {@code Constraints} object * can be manipulated as four edges * -- north, south, east, and west -- ! * using the {@code constraint} property. * * <p> * The following formulas are always true ! * for a {@code Constraints} object (here WEST and {@code x} are synonyms, as are and NORTH and {@code y}): * * <pre> * EAST = WEST + WIDTH * SOUTH = NORTH + HEIGHT * HORIZONTAL_CENTER = WEST + WIDTH/2
*** 290,319 **** * the SpringLayout.Constraints(Component) constructor is called or when * a constraints object is registered with a SpringLayout object.] * <p> * <b>Note</b>: In this document, * operators represent methods ! * in the <code>Spring</code> class. * For example, "a + b" is equal to ! * <code>Spring.sum(a, b)</code>, * and "a - b" is equal to ! * <code>Spring.sum(a, Spring.minus(b))</code>. * See the * {@link Spring Spring API documentation} * for further details * of spring arithmetic. * * <p> * ! * Because a <code>Constraints</code> object's properties -- * representing its edges, size, and location -- can all be set * independently and yet are interrelated, ! * a <code>Constraints</code> object can become <em>over-constrained</em>. ! * For example, if the <code>WEST</code>, <code>WIDTH</code> and ! * <code>EAST</code> edges are all set, steps must be taken to ensure that * the first of the formulas above holds. To do this, the ! * <code>Constraints</code> * object throws away the <em>least recently set</em> * constraint so as to make the formulas hold. * @since 1.4 */ public static class Constraints { --- 290,319 ---- * the SpringLayout.Constraints(Component) constructor is called or when * a constraints object is registered with a SpringLayout object.] * <p> * <b>Note</b>: In this document, * operators represent methods ! * in the {@code Spring} class. * For example, "a + b" is equal to ! * {@code Spring.sum(a, b)}, * and "a - b" is equal to ! * {@code Spring.sum(a, Spring.minus(b))}. * See the * {@link Spring Spring API documentation} * for further details * of spring arithmetic. * * <p> * ! * Because a {@code Constraints} object's properties -- * representing its edges, size, and location -- can all be set * independently and yet are interrelated, ! * a {@code Constraints} object can become <em>over-constrained</em>. ! * For example, if the {@code WEST}, {@code WIDTH} and ! * {@code EAST} edges are all set, steps must be taken to ensure that * the first of the formulas above holds. To do this, the ! * {@code Constraints} * object throws away the <em>least recently set</em> * constraint so as to make the formulas hold. * @since 1.4 */ public static class Constraints {
*** 332,397 **** // Used for baseline calculations private Component c; /** ! * Creates an empty <code>Constraints</code> object. */ public Constraints() { } /** ! * Creates a <code>Constraints</code> object with the * specified values for its ! * <code>x</code> and <code>y</code> properties. ! * The <code>height</code> and <code>width</code> springs ! * have <code>null</code> values. * * @param x the spring controlling the component's <em>x</em> value * @param y the spring controlling the component's <em>y</em> value */ public Constraints(Spring x, Spring y) { setX(x); setY(y); } /** ! * Creates a <code>Constraints</code> object with the * specified values for its ! * <code>x</code>, <code>y</code>, <code>width</code>, ! * and <code>height</code> properties. ! * Note: If the <code>SpringLayout</code> class ! * encounters <code>null</code> values in the ! * <code>Constraints</code> object of a given component, * it replaces them with suitable defaults. * ! * @param x the spring value for the <code>x</code> property ! * @param y the spring value for the <code>y</code> property ! * @param width the spring value for the <code>width</code> property ! * @param height the spring value for the <code>height</code> property */ public Constraints(Spring x, Spring y, Spring width, Spring height) { setX(x); setY(y); setWidth(width); setHeight(height); } /** ! * Creates a <code>Constraints</code> object with ! * suitable <code>x</code>, <code>y</code>, <code>width</code> and ! * <code>height</code> springs for component, <code>c</code>. ! * The <code>x</code> and <code>y</code> springs are constant * springs initialised with the component's location at ! * the time this method is called. The <code>width</code> and ! * <code>height</code> springs are special springs, created by ! * the <code>Spring.width()</code> and <code>Spring.height()</code> * methods, which track the size characteristics of the component * when they change. * * @param c the component whose characteristics will be reflected by this Constraints object ! * @throws NullPointerException if <code>c</code> is null. * @since 1.5 */ public Constraints(Component c) { this.c = c; setX(Spring.constant(c.getX())); --- 332,397 ---- // Used for baseline calculations private Component c; /** ! * Creates an empty {@code Constraints} object. */ public Constraints() { } /** ! * Creates a {@code Constraints} object with the * specified values for its ! * {@code x} and {@code y} properties. ! * The {@code height} and {@code width} springs ! * have {@code null} values. * * @param x the spring controlling the component's <em>x</em> value * @param y the spring controlling the component's <em>y</em> value */ public Constraints(Spring x, Spring y) { setX(x); setY(y); } /** ! * Creates a {@code Constraints} object with the * specified values for its ! * {@code x}, {@code y}, {@code width}, ! * and {@code height} properties. ! * Note: If the {@code SpringLayout} class ! * encounters {@code null} values in the ! * {@code Constraints} object of a given component, * it replaces them with suitable defaults. * ! * @param x the spring value for the {@code x} property ! * @param y the spring value for the {@code y} property ! * @param width the spring value for the {@code width} property ! * @param height the spring value for the {@code height} property */ public Constraints(Spring x, Spring y, Spring width, Spring height) { setX(x); setY(y); setWidth(width); setHeight(height); } /** ! * Creates a {@code Constraints} object with ! * suitable {@code x}, {@code y}, {@code width} and ! * {@code height} springs for component, {@code c}. ! * The {@code x} and {@code y} springs are constant * springs initialised with the component's location at ! * the time this method is called. The {@code width} and ! * {@code height} springs are special springs, created by ! * the {@code Spring.width()} and {@code Spring.height()} * methods, which track the size characteristics of the component * when they change. * * @param c the component whose characteristics will be reflected by this Constraints object ! * @throws NullPointerException if {@code c} is null. * @since 1.5 */ public Constraints(Component c) { this.c = c; setX(Spring.constant(c.getX()));
*** 498,512 **** private boolean defined(List<?> history, String s1, String s2) { return history.contains(s1) && history.contains(s2); } /** ! * 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 */ --- 498,512 ---- private boolean defined(List<?> history, String s1, String s2) { return history.contains(s1) && history.contains(s2); } /** ! * Sets the {@code x} property, ! * which controls the {@code x} value * of a component's location. * ! * @param x the spring controlling the {@code x} value * of a component's location * * @see #getX * @see SpringLayout.Constraints */
*** 514,526 **** 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 */ --- 514,526 ---- this.x = x; pushConstraint(WEST, x, true); } /** ! * Returns the value of the {@code x} property. * ! * @return the spring controlling the {@code x} value * of a component's location * * @see #setX * @see SpringLayout.Constraints */
*** 536,550 **** } 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 */ --- 536,550 ---- } return x; } /** ! * Sets the {@code y} property, ! * which controls the {@code y} value * of a component's location. * ! * @param y the spring controlling the {@code y} value * of a component's location * * @see #getY * @see SpringLayout.Constraints */
*** 552,564 **** 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 */ --- 552,564 ---- this.y = y; pushConstraint(NORTH, y, false); } /** ! * Returns the value of the {@code y} property. * ! * @return the spring controlling the {@code y} value * of a component's location * * @see #setY * @see SpringLayout.Constraints */
*** 582,607 **** } 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 --- 582,607 ---- } return y; } /** ! * Sets the {@code width} property, * which controls the width of a component. * * @param width the spring controlling the width of this ! * {@code Constraints} 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} property. * * @return the spring controlling the width of a component * * @see #setWidth * @see SpringLayout.Constraints
*** 616,629 **** } 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 */ --- 616,629 ---- } return width; } /** ! * Sets the {@code height} property, * which controls the height of a component. * ! * @param height the spring controlling the height of this {@code Constraints} * object * * @see #getHeight * @see SpringLayout.Constraints */
*** 631,641 **** 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 --- 631,641 ---- this.height = height; pushConstraint(HEIGHT, height, false); } /** ! * Returns the value of the {@code height} property. * * @return the spring controlling the height of a component * * @see #setHeight * @see SpringLayout.Constraints
*** 714,743 **** } /** * 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 --- 714,743 ---- } /** * Sets the spring controlling the specified edge. * The edge must have one of the following values: ! * {@code SpringLayout.NORTH}, ! * {@code SpringLayout.SOUTH}, ! * {@code SpringLayout.EAST}, ! * {@code SpringLayout.WEST}, ! * {@code SpringLayout.HORIZONTAL_CENTER}, ! * {@code SpringLayout.VERTICAL_CENTER}, ! * {@code SpringLayout.BASELINE}, ! * {@code SpringLayout.WIDTH} or ! * {@code SpringLayout.HEIGHT}. ! * For any other {@code String} value passed as the edge, ! * no action is taken. For a {@code null} edge, a ! * {@code NullPointerException} 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} is {@code null} * * @see #getConstraint * @see #NORTH * @see #SOUTH * @see #EAST
*** 772,802 **** } } /** * 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 --- 772,802 ---- } } /** * Returns the value of the specified edge, which may be ! * a derived value, or even {@code null}. * The edge must have one of the following values: ! * {@code SpringLayout.NORTH}, ! * {@code SpringLayout.SOUTH}, ! * {@code SpringLayout.EAST}, ! * {@code SpringLayout.WEST}, ! * {@code SpringLayout.HORIZONTAL_CENTER}, ! * {@code SpringLayout.VERTICAL_CENTER}, ! * {@code SpringLayout.BASELINE}, ! * {@code SpringLayout.WIDTH} or ! * {@code SpringLayout.HEIGHT}. ! * For any other {@code String} value passed as the edge, ! * {@code null} will be returned. Throws ! * {@code NullPointerException} for a {@code null} edge. * * @param edgeName the edge whose value * is to be returned * ! * @return the spring controlling the specified edge, may be {@code null} * ! * @throws NullPointerException if {@code edgeName} is {@code null} * * @see #setConstraint * @see #NORTH * @see #SOUTH * @see #EAST
*** 876,886 **** return "SpringProxy for " + edgeName + " edge of " + c.getName() + "."; } } /** ! * Constructs a new <code>SpringLayout</code>. */ public SpringLayout() {} private void resetCyclicStatuses() { cyclicSprings = new HashSet<Spring>(); --- 876,886 ---- return "SpringProxy for " + edgeName + " edge of " + c.getName() + "."; } } /** ! * Constructs a new {@code SpringLayout}. */ public SpringLayout() {} private void resetCyclicStatuses() { cyclicSprings = new HashSet<Spring>();
*** 986,997 **** abandonCycles(pc.getHeight()).getMaximumValue(), parent); } /** ! * If <code>constraints</code> is an instance of ! * <code>SpringLayout.Constraints</code>, * associates the constraints with the specified component. * * @param component the component being added * @param constraints the component's constraints * --- 986,997 ---- abandonCycles(pc.getHeight()).getMaximumValue(), parent); } /** ! * If {@code constraints} is an instance of ! * {@code SpringLayout.Constraints}, * associates the constraints with the specified component. * * @param component the component being added * @param constraints the component's constraints *
*** 1020,1031 **** public void invalidateLayout(Container p) {} // End of LayoutManger2 methods /** ! * Links edge <code>e1</code> of component <code>c1</code> to ! * edge <code>e2</code> of component <code>c2</code>, * with a fixed distance between the edges. This * constraint will cause the assignment * <pre> * value(e1, c1) = value(e2, c2) + pad</pre> * to take place during all subsequent layout operations. --- 1020,1031 ---- public void invalidateLayout(Container p) {} // End of LayoutManger2 methods /** ! * Links edge {@code e1} of component {@code c1} to ! * edge {@code e2} of component {@code c2}, * with a fixed distance between the edges. This * constraint will cause the assignment * <pre> * value(e1, c1) = value(e2, c2) + pad</pre> * to take place during all subsequent layout operations.
*** 1041,1063 **** public void putConstraint(String e1, Component c1, int pad, String e2, Component c2) { putConstraint(e1, c1, Spring.constant(pad), e2, c2); } /** ! * Links edge <code>e1</code> of component <code>c1</code> to ! * edge <code>e2</code> of component <code>c2</code>. As edge ! * <code>(e2, c2)</code> changes value, edge <code>(e1, c1)</code> will ! * be calculated by taking the (spring) sum of <code>(e2, c2)</code> ! * and <code>s</code>. * Each 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.VERTICAL_CENTER</code>, ! * <code>SpringLayout.HORIZONTAL_CENTER</code> or ! * <code>SpringLayout.BASELINE</code>. * * @param e1 the edge of the dependent * @param c1 the component of the dependent * @param s the spring linking dependent and anchor * @param e2 the edge of the anchor --- 1041,1063 ---- public void putConstraint(String e1, Component c1, int pad, String e2, Component c2) { putConstraint(e1, c1, Spring.constant(pad), e2, c2); } /** ! * Links edge {@code e1} of component {@code c1} to ! * edge {@code e2} of component {@code c2}. As edge ! * {@code (e2, c2)} changes value, edge {@code (e1, c1)} will ! * be calculated by taking the (spring) sum of {@code (e2, c2)} ! * and {@code s}. * Each edge must have one of the following values: ! * {@code SpringLayout.NORTH}, ! * {@code SpringLayout.SOUTH}, ! * {@code SpringLayout.EAST}, ! * {@code SpringLayout.WEST}, ! * {@code SpringLayout.VERTICAL_CENTER}, ! * {@code SpringLayout.HORIZONTAL_CENTER} or ! * {@code SpringLayout.BASELINE}. * * @param e1 the edge of the dependent * @param c1 the component of the dependent * @param s the spring linking dependent and anchor * @param e2 the edge of the anchor
*** 1125,1136 **** } /** * Returns the constraints for the specified component. * Note that, ! * unlike the <code>GridBagLayout</code> ! * <code>getConstraints</code> method, * this method does not clone constraints. * If no constraints * have been associated with this component, * this method * returns a default constraints object positioned at --- 1125,1136 ---- } /** * Returns the constraints for the specified component. * Note that, ! * unlike the {@code GridBagLayout} ! * {@code getConstraints} method, * this method does not clone constraints. * If no constraints * have been associated with this component, * this method * returns a default constraints object positioned at
*** 1171,1191 **** * Proxies are intended to be used in builder environments * where it is useful to allow the user to define the * constraints for a layout in any order. Proxies do, however, * provide the means to create cyclic dependencies amongst * the constraints of a layout. Such cycles are detected ! * internally by <code>SpringLayout</code> so that * the layout operation always terminates. * * @param edgeName must be one of ! * <code>SpringLayout.NORTH</code>, ! * <code>SpringLayout.SOUTH</code>, ! * <code>SpringLayout.EAST</code>, ! * <code>SpringLayout.WEST</code>, ! * <code>SpringLayout.VERTICAL_CENTER</code>, ! * <code>SpringLayout.HORIZONTAL_CENTER</code> or ! * <code>SpringLayout.BASELINE</code> * @param c the component whose edge spring is desired * * @return a proxy for the spring controlling the distance between the * specified edge and the top or left edge of its parent * --- 1171,1191 ---- * Proxies are intended to be used in builder environments * where it is useful to allow the user to define the * constraints for a layout in any order. Proxies do, however, * provide the means to create cyclic dependencies amongst * the constraints of a layout. Such cycles are detected ! * internally by {@code SpringLayout} so that * the layout operation always terminates. * * @param edgeName must be one of ! * {@code SpringLayout.NORTH}, ! * {@code SpringLayout.SOUTH}, ! * {@code SpringLayout.EAST}, ! * {@code SpringLayout.WEST}, ! * {@code SpringLayout.VERTICAL_CENTER}, ! * {@code SpringLayout.HORIZONTAL_CENTER} or ! * {@code SpringLayout.BASELINE} * @param c the component whose edge spring is desired * * @return a proxy for the spring controlling the distance between the * specified edge and the top or left edge of its parent *
< prev index next >