com.jgoodies.forms.layout
Class ColumnSpec

java.lang.Object
  extended by com.jgoodies.forms.layout.ColumnSpec

public class ColumnSpec
extends java.lang.Object

Specifies columns in FormLayout by their default orientation, start size and resizing behavior.

Examples:
The following examples specify a column with FILL alignment, a size of 10 dlu that won't grow.

 new ColumnSpec(Sizes.dluX(10));
 new ColumnSpec(ColumnSpec.FILL, Sizes.dluX(10), 0.0);
 new ColumnSpec(ColumnSpec.FILL, Sizes.dluX(10), ColumnSpec.NO_GROW);
 new ColumnSpec("10dlu");
 new ColumnSpec("10dlu:0");
 new ColumnSpec("fill:10dlu:0");
 

The FormFactory provides predefined frequently used ColumnSpec instances.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
FormFactory

Nested Class Summary
static class FormSpec.DefaultAlignment
          A typesafe enumeration for the column and row default alignment types.
 
Field Summary
static FormSpec.DefaultAlignment CENTER
          By default put the components in the center.
static FormSpec.DefaultAlignment DEFAULT
          Unless overridden the default alignment for a column is FILL.
static double DEFAULT_GROW
          The default resize weight.
static FormSpec.DefaultAlignment FILL
          By default fill the component into the column.
static FormSpec.DefaultAlignment LEFT
          By default put components in the left.
static FormSpec.DefaultAlignment MIDDLE
          By default put components in the middle.
static double NO_GROW
          Gives a column or row a fixed size.
static FormSpec.DefaultAlignment RIGHT
          By default put components in the right.
 
Constructor Summary
ColumnSpec(FormSpec.DefaultAlignment defaultAlignment, Size size, double resizeWeight)
          Constructs a ColumnSpec for the given default alignment, size and resize weight.
ColumnSpec(Size size)
          Constructs a ColumnSpec for the given size using the default alignment, and no resizing.
ColumnSpec(java.lang.String encodedDescription)
          Constructs a ColumnSpec from the specified encoded description.
 
Method Summary
 ColumnSpec asUnmodifyable()
          Creates and answers an unmodifyable version of this ColumnSpec.
 FormSpec.DefaultAlignment getDefaultAlignment()
          Answers the default alignment.
 double getResizeWeight()
          Answers the current resize weight.
 Size getSize()
          Returns the size.
 void setDefaultAlignment(FormSpec.DefaultAlignment newDefaultAlignment)
          Sets the default alignment.
 void setResizeWeight(double weight)
          Sets a new resize weight.
 void setSize(Size size)
          Sets the size.
 java.lang.String toShortString()
          Returns a string representation of this form specification.
 java.lang.String toString()
          Returns a string representation of this form specification.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEFT

public static final FormSpec.DefaultAlignment LEFT
By default put components in the left.


CENTER

public static final FormSpec.DefaultAlignment CENTER
By default put the components in the center.


MIDDLE

public static final FormSpec.DefaultAlignment MIDDLE
By default put components in the middle.


RIGHT

public static final FormSpec.DefaultAlignment RIGHT
By default put components in the right.


FILL

public static final FormSpec.DefaultAlignment FILL
By default fill the component into the column.


DEFAULT

public static final FormSpec.DefaultAlignment DEFAULT
Unless overridden the default alignment for a column is FILL.


NO_GROW

public static final double NO_GROW
Gives a column or row a fixed size.

See Also:
Constant Field Values

DEFAULT_GROW

public static final double DEFAULT_GROW
The default resize weight.

See Also:
Constant Field Values
Constructor Detail

ColumnSpec

public ColumnSpec(FormSpec.DefaultAlignment defaultAlignment,
                  Size size,
                  double resizeWeight)
Constructs a ColumnSpec for the given default alignment, size and resize weight.

The resize weight must be a non-negative double; you can use NO_GROW as a convenience value for no resize.

Parameters:
defaultAlignment - the spec's default alignment
size - constant, component size or bounded size
resizeWeight - the spec resize weight
Throws:
java.lang.IllegalArgumentException - if the resize weight is negative

ColumnSpec

public ColumnSpec(Size size)
Constructs a ColumnSpec for the given size using the default alignment, and no resizing.

Parameters:
size - constant size, component size, or bounded size
Throws:
java.lang.IllegalArgumentException - if the pixel size is invalid or the resize weight is negative

ColumnSpec

public ColumnSpec(java.lang.String encodedDescription)
Constructs a ColumnSpec from the specified encoded description. The description will be parsed to set initial values.

Parameters:
encodedDescription - the encoded description
Method Detail

asUnmodifyable

public ColumnSpec asUnmodifyable()
Creates and answers an unmodifyable version of this ColumnSpec.

Returns:
an unmodifyable version of this ColumnSpec

getDefaultAlignment

public final FormSpec.DefaultAlignment getDefaultAlignment()
Answers the default alignment.


setDefaultAlignment

public void setDefaultAlignment(FormSpec.DefaultAlignment newDefaultAlignment)
Sets the default alignment.

Parameters:
newDefaultAlignment - the new default alignment

getSize

public final Size getSize()
Returns the size.

Returns:
the size

setSize

public void setSize(Size size)
Sets the size.

Parameters:
size - the new size

getResizeWeight

public final double getResizeWeight()
Answers the current resize weight.

Returns:
the resize weight.

setResizeWeight

public void setResizeWeight(double weight)
Sets a new resize weight.

Parameters:
weight - the new resize weight

toString

public final java.lang.String toString()
Returns a string representation of this form specification. The string representation consists of three elements separated by a colon (":"), first the alignment, second the size, and third the resize spec.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the form specification.

toShortString

public final java.lang.String toShortString()
Returns a string representation of this form specification. The string representation consists of three elements separated by a colon (":"), first the alignment, second the size, and third the resize spec.

Returns:
a string representation of the form specification.