javax.swing
public abstract class Spring extends Object
A Spring defines a minimum, preferred and maximum distance for each edge (north, east, south, west) of a component.
However, springs are not static, their actual values are computed at runtime. That means, if a Spring C is defined as the sum of Spring A and Spring B, then the values (min, pref and max) are not calculated at creation of Spring C, but instead always when {@link #getValue} is called. So, when Spring A or Spring B changes, this is reflected in Spring C.Field Summary | |
---|---|
static int | UNSET Indicates a not-set value. |
Constructor Summary | |
---|---|
protected | Spring()
Creates a new Spring object. |
Method Summary | |
---|---|
static Spring | constant(int val)
Creates a Spring which min, pref and max values are all the same.
|
static Spring | constant(int min, int pref, int max) Creates a Spring which min, pref and max values are constants. |
abstract int | getMaximumValue()
Returns the maximum value of the Spring.
|
abstract int | getMinimumValue()
Returns the minimum value of this Spring.
|
abstract int | getPreferredValue()
Return the preferred value of this Spring.
|
abstract int | getValue()
Return the actual value of this Spring.
|
static Spring | height(Component component)
Return a new Spring which takes its values from the specified
Component. |
static Spring | max(Spring s1, Spring s2)
Creates and returns a Spring, which always has the maximum values
min = max(min_s1, min_s2), pref = max(pref_s1, pref_s2), max =
max(max_s1, max_s2).
|
static Spring | minus(Spring s)
Creates and returns a Spring, which is always the negation of s.
min = -min_s, pref = -pref_s, max = -max_pref.
|
static Spring | scale(Spring spring, float factor)
Return a new Spring which computes its values by scaling
the values of another spring by a constant factor. |
abstract void | setValue(int value)
Sets the actual value. |
static Spring | sum(Spring s1, Spring s2)
Creates and returns a Spring, which is always the sum of s1 and s2.
min_sum = min_s1 + min_s2, pref_sum = pref_s1 + pref_s2, max_sum =
max_s1 + max_s2.
|
static Spring | width(Component component)
Return a new Spring which takes its values from the specified
Component. |
Parameters: val the constant for min, pref and max values.
Returns: a Spring object with constant values for min, pref and max.
Parameters: min the constant for the minimum value. pref the constant for the preferred value. max the constant for the maximum value.
Returns: a Spring object with constant values for min, pref and max.
Returns: the maximum value.
Returns: the minimum value.
Returns: the preferred value.
Returns: the actual value of this Spring.
Parameters: component the component
Returns: a new Spring which tracks the component's height
Since: 1.5
Parameters: s1 the first summand of the max Spring. s2 the second summand of the max Spring.
Returns: a Spring which is max(s1, s2).
Parameters: s the Spring to be negated.
Returns: the negative of s
.
Parameters: spring the spring to track factor the factor by which to scale
Returns: a new multiplicative Spring
Since: 1.5
value
is out of the (min, max)
bounds, then the value is adjusted, so that is inside these bounds.
Parameters: value the value to be set.
Parameters: s1 the 1st summand of the sum Spring. s2 the 2nd summand of the sum Spring.
Returns: a sum which is s1 + s2
.
Parameters: component the component
Returns: a new Spring which tracks the component's width
Since: 1.5