0N/A/*
2362N/A * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage javax.swing;
0N/A
0N/Aimport java.awt.Component;
0N/A
0N/A/**
0N/A * An instance of the <code>Spring</code> class holds three properties that
0N/A * characterize its behavior: the <em>minimum</em>, <em>preferred</em>, and
0N/A * <em>maximum</em> values. Each of these properties may be involved in
0N/A * defining its fourth, <em>value</em>, property based on a series of rules.
0N/A * <p>
0N/A * An instance of the <code>Spring</code> class can be visualized as a
0N/A * mechanical spring that provides a corrective force as the spring is compressed
0N/A * or stretched away from its preferred value. This force is modelled
0N/A * as linear function of the distance from the preferred value, but with
0N/A * two different constants -- one for the compressional force and one for the
0N/A * tensional one. Those constants are specified by the minimum and maximum
0N/A * values of the spring such that a spring at its minimum value produces an
0N/A * equal and opposite force to that which is created when it is at its
0N/A * maximum value. The difference between the <em>preferred</em> and
0N/A * <em>minimum</em> values, therefore, represents the ease with which the
0N/A * spring can be compressed and the difference between its <em>maximum</em>
0N/A * and <em>preferred</em> values, indicates the ease with which the
0N/A * <code>Spring</code> can be extended.
0N/A * See the {@link #sum} method for details.
0N/A *
0N/A * <p>
0N/A * By defining simple arithmetic operations on <code>Spring</code>s,
0N/A * the behavior of a collection of <code>Spring</code>s
0N/A * can be reduced to that of an ordinary (non-compound) <code>Spring</code>. We define
0N/A * the "+", "-", <em>max</em>, and <em>min</em> operators on
0N/A * <code>Spring</code>s so that, in each case, the result is a <code>Spring</code>
0N/A * whose characteristics bear a useful mathematical relationship to its constituent
0N/A * springs.
0N/A *
0N/A * <p>
0N/A * A <code>Spring</code> can be treated as a pair of intervals
0N/A * with a single common point: the preferred value.
0N/A * The following rules define some of the
0N/A * arithmetic operators that can be applied to intervals
0N/A * (<code>[a, b]</code> refers to the interval
0N/A * from <code>a</code>
0N/A * to <code>b</code>,
0N/A * where <code>a &lt;= b</code>).
0N/A * <p>
0N/A * <pre>
0N/A * [a1, b1] + [a2, b2] = [a1 + a2, b1 + b2]
0N/A *
0N/A * -[a, b] = [-b, -a]
0N/A *
0N/A * max([a1, b1], [a2, b2]) = [max(a1, a2), max(b1, b2)]
0N/A * </pre>
0N/A * <p>
0N/A *
0N/A * If we denote <code>Spring</code>s as <code>[a, b, c]</code>,
0N/A * where <code>a &lt;= b &lt;= c</code>, we can define the same
0N/A * arithmetic operators on <code>Spring</code>s:
0N/A * <p>
0N/A * <pre>
0N/A * [a1, b1, c1] + [a2, b2, c2] = [a1 + a2, b1 + b2, c1 + c2]
0N/A *
0N/A * -[a, b, c] = [-c, -b, -a]
0N/A *
0N/A * max([a1, b1, c1], [a2, b2, c2]) = [max(a1, a2), max(b1, b2), max(c1, c2)]
0N/A * </pre>
0N/A * <p>
0N/A * With both intervals and <code>Spring</code>s we can define "-" and <em>min</em>
0N/A * in terms of negation:
0N/A * <p>
0N/A * <pre>
0N/A * X - Y = X + (-Y)
0N/A *
0N/A * min(X, Y) = -max(-X, -Y)
0N/A * </pre>
0N/A * <p>
0N/A * For the static methods in this class that embody the arithmetic
0N/A * operators, we do not actually perform the operation in question as
0N/A * that would snapshot the values of the properties of the method's arguments
0N/A * at the time the static method is called. Instead, the static methods
0N/A * create a new <code>Spring</code> instance containing references to
0N/A * the method's arguments so that the characteristics of the new spring track the
0N/A * potentially changing characteristics of the springs from which it
0N/A * was made. This is a little like the idea of a <em>lazy value</em>
0N/A * in a functional language.
0N/A * <p>
0N/A * If you are implementing a <code>SpringLayout</code> you
0N/A * can find further information and examples in
0N/A * <a
0N/A href="http://java.sun.com/docs/books/tutorial/uiswing/layout/spring.html">How to Use SpringLayout</a>,
0N/A * a section in <em>The Java Tutorial.</em>
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is
0N/A * appropriate for short term storage or RMI between applications running
0N/A * the same version of Swing. As of 1.4, support for long term storage
0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup>
0N/A * has been added to the <code>java.beans</code> package.
0N/A * Please see {@link java.beans.XMLEncoder}.
0N/A *
0N/A * @see SpringLayout
0N/A * @see SpringLayout.Constraints
0N/A *
0N/A * @author Philip Milne
0N/A * @since 1.4
0N/A */
0N/Apublic abstract class Spring {
0N/A
0N/A /**
0N/A * An integer value signifying that a property value has not yet been calculated.
0N/A */
0N/A public static final int UNSET = Integer.MIN_VALUE;
0N/A
0N/A /**
0N/A * Used by factory methods to create a <code>Spring</code>.
0N/A *
0N/A * @see #constant(int)
0N/A * @see #constant(int, int, int)
0N/A * @see #max
0N/A * @see #minus
0N/A * @see #sum
0N/A * @see SpringLayout.Constraints
0N/A */
0N/A protected Spring() {}
0N/A
0N/A /**
0N/A * Returns the <em>minimum</em> value of this <code>Spring</code>.
0N/A *
0N/A * @return the <code>minimumValue</code> property of this <code>Spring</code>
0N/A */
0N/A public abstract int getMinimumValue();
0N/A
0N/A /**
0N/A * Returns the <em>preferred</em> value of this <code>Spring</code>.
0N/A *
0N/A * @return the <code>preferredValue</code> of this <code>Spring</code>
0N/A */
0N/A public abstract int getPreferredValue();
0N/A
0N/A /**
0N/A * Returns the <em>maximum</em> value of this <code>Spring</code>.
0N/A *
0N/A * @return the <code>maximumValue</code> property of this <code>Spring</code>
0N/A */
0N/A public abstract int getMaximumValue();
0N/A
0N/A /**
0N/A * Returns the current <em>value</em> of this <code>Spring</code>.
0N/A *
0N/A * @return the <code>value</code> property of this <code>Spring</code>
0N/A *
0N/A * @see #setValue
0N/A */
0N/A public abstract int getValue();
0N/A
0N/A /**
0N/A * Sets the current <em>value</em> of this <code>Spring</code> to <code>value</code>.
0N/A *
0N/A * @param value the new setting of the <code>value</code> property
0N/A *
0N/A * @see #getValue
0N/A */
0N/A public abstract void setValue(int value);
0N/A
0N/A private double range(boolean contract) {
0N/A return contract ? (getPreferredValue() - getMinimumValue()) :
0N/A (getMaximumValue() - getPreferredValue());
0N/A }
0N/A
0N/A /*pp*/ double getStrain() {
0N/A double delta = (getValue() - getPreferredValue());
0N/A return delta/range(getValue() < getPreferredValue());
0N/A }
0N/A
0N/A /*pp*/ void setStrain(double strain) {
0N/A setValue(getPreferredValue() + (int)(strain * range(strain < 0)));
0N/A }
0N/A
0N/A /*pp*/ boolean isCyclic(SpringLayout l) {
0N/A return false;
0N/A }
0N/A
0N/A /*pp*/ static abstract class AbstractSpring extends Spring {
0N/A protected int size = UNSET;
0N/A
0N/A public int getValue() {
0N/A return size != UNSET ? size : getPreferredValue();
0N/A }
0N/A
0N/A public final void setValue(int size) {
0N/A if (this.size == size) {
0N/A return;
0N/A }
0N/A if (size == UNSET) {
0N/A clear();
0N/A } else {
0N/A setNonClearValue(size);
0N/A }
0N/A }
0N/A
0N/A protected void clear() {
0N/A size = UNSET;
0N/A }
0N/A
0N/A protected void setNonClearValue(int size) {
0N/A this.size = size;
0N/A }
0N/A }
0N/A
0N/A private static class StaticSpring extends AbstractSpring {
0N/A protected int min;
0N/A protected int pref;
0N/A protected int max;
0N/A
0N/A public StaticSpring(int pref) {
0N/A this(pref, pref, pref);
0N/A }
0N/A
0N/A public StaticSpring(int min, int pref, int max) {
0N/A this.min = min;
0N/A this.pref = pref;
0N/A this.max = max;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "StaticSpring [" + min + ", " + pref + ", " + max + "]";
0N/A }
0N/A
0N/A public int getMinimumValue() {
0N/A return min;
0N/A }
0N/A
0N/A public int getPreferredValue() {
0N/A return pref;
0N/A }
0N/A
0N/A public int getMaximumValue() {
0N/A return max;
0N/A }
0N/A }
0N/A
0N/A private static class NegativeSpring extends Spring {
0N/A private Spring s;
0N/A
0N/A public NegativeSpring(Spring s) {
0N/A this.s = s;
0N/A }
0N/A
0N/A// Note the use of max value rather than minimum value here.
0N/A// See the opening preamble on arithmetic with springs.
0N/A
0N/A public int getMinimumValue() {
0N/A return -s.getMaximumValue();
0N/A }
0N/A
0N/A public int getPreferredValue() {
0N/A return -s.getPreferredValue();
0N/A }
0N/A
0N/A public int getMaximumValue() {
0N/A return -s.getMinimumValue();
0N/A }
0N/A
0N/A public int getValue() {
0N/A return -s.getValue();
0N/A }
0N/A
0N/A public void setValue(int size) {
0N/A // No need to check for UNSET as
0N/A // Integer.MIN_VALUE == -Integer.MIN_VALUE.
0N/A s.setValue(-size);
0N/A }
0N/A
0N/A /*pp*/ boolean isCyclic(SpringLayout l) {
0N/A return s.isCyclic(l);
0N/A }
0N/A }
0N/A
0N/A private static class ScaleSpring extends Spring {
0N/A private Spring s;
0N/A private float factor;
0N/A
0N/A private ScaleSpring(Spring s, float factor) {
0N/A this.s = s;
0N/A this.factor = factor;
0N/A }
0N/A
0N/A public int getMinimumValue() {
0N/A return Math.round((factor < 0 ? s.getMaximumValue() : s.getMinimumValue()) * factor);
0N/A }
0N/A
0N/A public int getPreferredValue() {
0N/A return Math.round(s.getPreferredValue() * factor);
0N/A }
0N/A
0N/A public int getMaximumValue() {
0N/A return Math.round((factor < 0 ? s.getMinimumValue() : s.getMaximumValue()) * factor);
0N/A }
0N/A
0N/A public int getValue() {
0N/A return Math.round(s.getValue() * factor);
0N/A }
0N/A
0N/A public void setValue(int value) {
0N/A if (value == UNSET) {
0N/A s.setValue(UNSET);
0N/A } else {
0N/A s.setValue(Math.round(value / factor));
0N/A }
0N/A }
0N/A
0N/A /*pp*/ boolean isCyclic(SpringLayout l) {
0N/A return s.isCyclic(l);
0N/A }
0N/A }
0N/A
0N/A /*pp*/ static class WidthSpring extends AbstractSpring {
0N/A /*pp*/ Component c;
0N/A
0N/A public WidthSpring(Component c) {
0N/A this.c = c;
0N/A }
0N/A
0N/A public int getMinimumValue() {
0N/A return c.getMinimumSize().width;
0N/A }
0N/A
0N/A public int getPreferredValue() {
0N/A return c.getPreferredSize().width;
0N/A }
0N/A
0N/A public int getMaximumValue() {
0N/A // We will be doing arithmetic with the results of this call,
0N/A // so if a returned value is Integer.MAX_VALUE we will get
0N/A // arithmetic overflow. Truncate such values.
0N/A return Math.min(Short.MAX_VALUE, c.getMaximumSize().width);
0N/A }
0N/A }
0N/A
0N/A /*pp*/ static class HeightSpring extends AbstractSpring {
0N/A /*pp*/ Component c;
0N/A
0N/A public HeightSpring(Component c) {
0N/A this.c = c;
0N/A }
0N/A
0N/A public int getMinimumValue() {
0N/A return c.getMinimumSize().height;
0N/A }
0N/A
0N/A public int getPreferredValue() {
0N/A return c.getPreferredSize().height;
0N/A }
0N/A
0N/A public int getMaximumValue() {
0N/A return Math.min(Short.MAX_VALUE, c.getMaximumSize().height);
0N/A }
0N/A }
0N/A
0N/A /*pp*/ static abstract class SpringMap extends Spring {
0N/A private Spring s;
0N/A
0N/A public SpringMap(Spring s) {
0N/A this.s = s;
0N/A }
0N/A
0N/A protected abstract int map(int i);
0N/A
0N/A protected abstract int inv(int i);
0N/A
0N/A public int getMinimumValue() {
0N/A return map(s.getMinimumValue());
0N/A }
0N/A
0N/A public int getPreferredValue() {
0N/A return map(s.getPreferredValue());
0N/A }
0N/A
0N/A public int getMaximumValue() {
0N/A return Math.min(Short.MAX_VALUE, map(s.getMaximumValue()));
0N/A }
0N/A
0N/A public int getValue() {
0N/A return map(s.getValue());
0N/A }
0N/A
0N/A public void setValue(int value) {
0N/A if (value == UNSET) {
0N/A s.setValue(UNSET);
0N/A } else {
0N/A s.setValue(inv(value));
0N/A }
0N/A }
0N/A
0N/A /*pp*/ boolean isCyclic(SpringLayout l) {
0N/A return s.isCyclic(l);
0N/A }
0N/A }
0N/A
0N/A// Use the instance variables of the StaticSpring superclass to
0N/A// cache values that have already been calculated.
0N/A /*pp*/ static abstract class CompoundSpring extends StaticSpring {
0N/A protected Spring s1;
0N/A protected Spring s2;
0N/A
0N/A public CompoundSpring(Spring s1, Spring s2) {
0N/A super(UNSET);
0N/A this.s1 = s1;
0N/A this.s2 = s2;
0N/A }
0N/A
0N/A public String toString() {
0N/A return "CompoundSpring of " + s1 + " and " + s2;
0N/A }
0N/A
0N/A protected void clear() {
0N/A super.clear();
0N/A min = pref = max = UNSET;
0N/A s1.setValue(UNSET);
0N/A s2.setValue(UNSET);
0N/A }
0N/A
0N/A protected abstract int op(int x, int y);
0N/A
0N/A public int getMinimumValue() {
0N/A if (min == UNSET) {
0N/A min = op(s1.getMinimumValue(), s2.getMinimumValue());
0N/A }
0N/A return min;
0N/A }
0N/A
0N/A public int getPreferredValue() {
0N/A if (pref == UNSET) {
0N/A pref = op(s1.getPreferredValue(), s2.getPreferredValue());
0N/A }
0N/A return pref;
0N/A }
0N/A
0N/A public int getMaximumValue() {
0N/A if (max == UNSET) {
0N/A max = op(s1.getMaximumValue(), s2.getMaximumValue());
0N/A }
0N/A return max;
0N/A }
0N/A
0N/A public int getValue() {
0N/A if (size == UNSET) {
0N/A size = op(s1.getValue(), s2.getValue());
0N/A }
0N/A return size;
0N/A }
0N/A
0N/A /*pp*/ boolean isCyclic(SpringLayout l) {
0N/A return l.isCyclic(s1) || l.isCyclic(s2);
0N/A }
0N/A };
0N/A
0N/A private static class SumSpring extends CompoundSpring {
0N/A public SumSpring(Spring s1, Spring s2) {
0N/A super(s1, s2);
0N/A }
0N/A
0N/A protected int op(int x, int y) {
0N/A return x + y;
0N/A }
0N/A
0N/A protected void setNonClearValue(int size) {
0N/A super.setNonClearValue(size);
0N/A s1.setStrain(this.getStrain());
0N/A s2.setValue(size - s1.getValue());
0N/A }
0N/A }
0N/A
0N/A private static class MaxSpring extends CompoundSpring {
0N/A
0N/A public MaxSpring(Spring s1, Spring s2) {
0N/A super(s1, s2);
0N/A }
0N/A
0N/A protected int op(int x, int y) {
0N/A return Math.max(x, y);
0N/A }
0N/A
0N/A protected void setNonClearValue(int size) {
0N/A super.setNonClearValue(size);
0N/A s1.setValue(size);
0N/A s2.setValue(size);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Returns a strut -- a spring whose <em>minimum</em>, <em>preferred</em>, and
0N/A * <em>maximum</em> values each have the value <code>pref</code>.
0N/A *
0N/A * @param pref the <em>minimum</em>, <em>preferred</em>, and
0N/A * <em>maximum</em> values of the new spring
0N/A * @return a spring whose <em>minimum</em>, <em>preferred</em>, and
0N/A * <em>maximum</em> values each have the value <code>pref</code>
0N/A *
0N/A * @see Spring
0N/A */
0N/A public static Spring constant(int pref) {
0N/A return constant(pref, pref, pref);
0N/A }
0N/A
0N/A /**
0N/A * Returns a spring whose <em>minimum</em>, <em>preferred</em>, and
0N/A * <em>maximum</em> values have the values: <code>min</code>, <code>pref</code>,
0N/A * and <code>max</code> respectively.
0N/A *
0N/A * @param min the <em>minimum</em> value of the new spring
0N/A * @param pref the <em>preferred</em> value of the new spring
0N/A * @param max the <em>maximum</em> value of the new spring
0N/A * @return a spring whose <em>minimum</em>, <em>preferred</em>, and
0N/A * <em>maximum</em> values have the values: <code>min</code>, <code>pref</code>,
0N/A * and <code>max</code> respectively
0N/A *
0N/A * @see Spring
0N/A */
0N/A public static Spring constant(int min, int pref, int max) {
0N/A return new StaticSpring(min, pref, max);
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Returns <code>-s</code>: a spring running in the opposite direction to <code>s</code>.
0N/A *
0N/A * @return <code>-s</code>: a spring running in the opposite direction to <code>s</code>
0N/A *
0N/A * @see Spring
0N/A */
0N/A public static Spring minus(Spring s) {
0N/A return new NegativeSpring(s);
0N/A }
0N/A
0N/A /**
0N/A * Returns <code>s1+s2</code>: a spring representing <code>s1</code> and <code>s2</code>
0N/A * in series. In a sum, <code>s3</code>, of two springs, <code>s1</code> and <code>s2</code>,
0N/A * the <em>strains</em> of <code>s1</code>, <code>s2</code>, and <code>s3</code> are maintained
0N/A * at the same level (to within the precision implied by their integer <em>value</em>s).
0N/A * The strain of a spring in compression is:
0N/A * <pre>
0N/A * value - pref
0N/A * ------------
0N/A * pref - min
0N/A * </pre>
0N/A * and the strain of a spring in tension is:
0N/A * <pre>
0N/A * value - pref
0N/A * ------------
0N/A * max - pref
0N/A * </pre>
0N/A * When <code>setValue</code> is called on the sum spring, <code>s3</code>, the strain
0N/A * in <code>s3</code> is calculated using one of the formulas above. Once the strain of
0N/A * the sum is known, the <em>value</em>s of <code>s1</code> and <code>s2</code> are
0N/A * then set so that they are have a strain equal to that of the sum. The formulas are
0N/A * evaluated so as to take rounding errors into account and ensure that the sum of
0N/A * the <em>value</em>s of <code>s1</code> and <code>s2</code> is exactly equal to
0N/A * the <em>value</em> of <code>s3</code>.
0N/A *
0N/A * @return <code>s1+s2</code>: a spring representing <code>s1</code> and <code>s2</code> in series
0N/A *
0N/A * @see Spring
0N/A */
0N/A public static Spring sum(Spring s1, Spring s2) {
0N/A return new SumSpring(s1, s2);
0N/A }
0N/A
0N/A /**
0N/A * Returns <code>max(s1, s2)</code>: a spring whose value is always greater than (or equal to)
0N/A * the values of both <code>s1</code> and <code>s2</code>.
0N/A *
0N/A * @return <code>max(s1, s2)</code>: a spring whose value is always greater than (or equal to)
0N/A * the values of both <code>s1</code> and <code>s2</code>
0N/A * @see Spring
0N/A */
0N/A public static Spring max(Spring s1, Spring s2) {
0N/A return new MaxSpring(s1, s2);
0N/A }
0N/A
0N/A // Remove these, they're not used often and can be created using minus -
0N/A // as per these implementations.
0N/A
0N/A /*pp*/ static Spring difference(Spring s1, Spring s2) {
0N/A return sum(s1, minus(s2));
0N/A }
0N/A
0N/A /*
0N/A public static Spring min(Spring s1, Spring s2) {
0N/A return minus(max(minus(s1), minus(s2)));
0N/A }
0N/A */
0N/A
0N/A /**
0N/A * Returns a spring whose <em>minimum</em>, <em>preferred</em>, <em>maximum</em>
0N/A * and <em>value</em> properties are each multiples of the properties of the
0N/A * argument spring, <code>s</code>. Minimum and maximum properties are
0N/A * swapped when <code>factor</code> is negative (in accordance with the
0N/A * rules of interval arithmetic).
0N/A * <p>
0N/A * When factor is, for example, 0.5f the result represents 'the mid-point'
0N/A * of its input - an operation that is useful for centering components in
0N/A * a container.
0N/A *
0N/A * @param s the spring to scale
0N/A * @param factor amount to scale by.
0N/A * @return a spring whose properties are those of the input spring <code>s</code>
0N/A * multiplied by <code>factor</code>
0N/A * @throws NullPointerException if <code>s</code> is null
0N/A * @since 1.5
0N/A */
0N/A public static Spring scale(Spring s, float factor) {
0N/A checkArg(s);
0N/A return new ScaleSpring(s, factor);
0N/A }
0N/A
0N/A /**
0N/A * Returns a spring whose <em>minimum</em>, <em>preferred</em>, <em>maximum</em>
0N/A * and <em>value</em> properties are defined by the widths of the <em>minimumSize</em>,
0N/A * <em>preferredSize</em>, <em>maximumSize</em> and <em>size</em> properties
0N/A * of the supplied component. The returned spring is a 'wrapper' implementation
0N/A * whose methods call the appropriate size methods of the supplied component.
0N/A * The minimum, preferred, maximum and value properties of the returned spring
0N/A * therefore report the current state of the appropriate properties in the
0N/A * component and track them as they change.
0N/A *
0N/A * @param c Component used for calculating size
0N/A * @return a spring whose properties are defined by the horizontal component
0N/A * of the component's size methods.
0N/A * @throws NullPointerException if <code>c</code> is null
0N/A * @since 1.5
0N/A */
0N/A public static Spring width(Component c) {
0N/A checkArg(c);
0N/A return new WidthSpring(c);
0N/A }
0N/A
0N/A /**
0N/A * Returns a spring whose <em>minimum</em>, <em>preferred</em>, <em>maximum</em>
0N/A * and <em>value</em> properties are defined by the heights of the <em>minimumSize</em>,
0N/A * <em>preferredSize</em>, <em>maximumSize</em> and <em>size</em> properties
0N/A * of the supplied component. The returned spring is a 'wrapper' implementation
0N/A * whose methods call the appropriate size methods of the supplied component.
0N/A * The minimum, preferred, maximum and value properties of the returned spring
0N/A * therefore report the current state of the appropriate properties in the
0N/A * component and track them as they change.
0N/A *
0N/A * @param c Component used for calculating size
0N/A * @return a spring whose properties are defined by the vertical component
0N/A * of the component's size methods.
0N/A * @throws NullPointerException if <code>c</code> is null
0N/A * @since 1.5
0N/A */
0N/A public static Spring height(Component c) {
0N/A checkArg(c);
0N/A return new HeightSpring(c);
0N/A }
0N/A
0N/A
0N/A /**
0N/A * If <code>s</code> is null, this throws an NullPointerException.
0N/A */
0N/A private static void checkArg(Object s) {
0N/A if (s == null) {
0N/A throw new NullPointerException("Argument must not be null");
0N/A }
0N/A }
0N/A}