javax.swing
Class Spring
Calculates the space between component edges, that are layed out by
SpringLayout
.
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
getValue()
is
called. So, when Spring A or Spring B changes, this is reflected in
Spring C.
static int | UNSET - Indicates a not-set value.
|
Spring() - Creates a new Spring object.
|
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.
|
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.
|
static Spring | width(Component component) - Return a new Spring which takes its values from the specified
Component.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
UNSET
public static final int UNSET
Indicates a not-set value. *
Spring
protected Spring()
Creates a new Spring object. This constructor is used by the static
methods which create Springs.
constant
public static Spring constant(int val)
Creates a Spring which min, pref and max values are all the same.
These kind of Springs are 'struts'.
val
- the constant for min, pref and max values.
- a Spring object with constant values for min, pref and max.
constant
public static Spring constant(int min,
int pref,
int max)
Creates a Spring which min, pref and max values are constants.
min
- the constant for the minimum value.pref
- the constant for the preferred value.max
- the constant for the maximum value.
- a Spring object with constant values for min, pref and max.
getMaximumValue
public abstract int getMaximumValue()
Returns the maximum value of the Spring.
getMinimumValue
public abstract int getMinimumValue()
Returns the minimum value of this Spring.
getPreferredValue
public abstract int getPreferredValue()
Return the preferred value of this Spring.
getValue
public abstract int getValue()
Return the actual value of this Spring.
- the actual value of this Spring.
height
public static Spring height(Component component)
Return a new Spring which takes its values from the specified
Component. In particular, the maximum value is taken from
the maximumSize, the minimum value is taken from the minimumSize,
the preferred value is taken from the preferredSize, and the
value is taken from the component's current size. These values
change as the component changes size.
component
- the component
- a new Spring which tracks the component's height
max
public 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).
s1
- the first summand of the max Spring.s2
- the second summand of the max Spring.
- a Spring which is max(s1, s2).
minus
public 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.
s
- the Spring to be negated.
scale
public 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. If the
factor is negative, the minimum and maximum values of
the argument spring will be interchanged.
spring
- the spring to trackfactor
- the factor by which to scale
- a new multiplicative Spring
setValue
public abstract void setValue(int value)
Sets the actual value. If value
is out of the (min, max)
bounds, then the value is adjusted, so that is inside these bounds.
value
- the value to be set.
sum
public 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.
s1
- the 1st summand of the sum Spring.s2
- the 2nd summand of the sum Spring.
width
public static Spring width(Component component)
Return a new Spring which takes its values from the specified
Component. In particular, the maximum value is taken from
the maximumSize, the minimum value is taken from the minimumSize,
the preferred value is taken from the preferredSize, and the
value is taken from the component's current size. These values
change as the component changes size.
component
- the component
- a new Spring which tracks the component's width
Spring.java --
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.