com.jgoodies.forms.layout

Class FormSpec

Implemented Interfaces:
Serializable
Known Direct Subclasses:
ColumnSpec, RowSpec

public abstract class FormSpec
extends Object
implements Serializable

An abstract class that specifies columns and rows in FormLayout by their default alignment, start size and resizing behavior. API users will use the subclasses ColumnSpec and RowSpec.

Also implements the parser for encoded column and row specifications and provides parser convenience behavior for its subclasses ColumnSpec and RowSpec.

TODO: Consider extracting the parser role to a separate class.

Version:
$Revision: 1.20 $
Author:
Karsten Lentzsch
See Also:
ColumnSpec, RowSpec, FormLayout, CellConstraints

Nested Class Summary

static class
FormSpec.DefaultAlignment
An ordinal-based serializable typesafe enumeration for the column and row default alignment types.

Field Summary

static double
DEFAULT_GROW
The default resize weight.
static double
NO_GROW
Gives a column or row a fixed size.

Constructor Summary

FormSpec(FormSpec.DefaultAlignment defaultAlignment, String encodedDescription)
Constructs a FormSpec from the specified encoded description.
FormSpec(FormSpec.DefaultAlignment defaultAlignment, Size size, double resizeWeight)
Constructs a FormSpec for the given default alignment, size, and resize weight.

Method Summary

String
encode()
Returns a short and parseable string representation of this form specification.
FormSpec.DefaultAlignment
getDefaultAlignment()
Returns the default alignment.
double
getResizeWeight()
Returns the current resize weight.
Size
getSize()
Returns the size.
String
toShortString()
Returns a string representation of this form specification.
String
toString()
Returns a string representation of this form specification.

Field Details

DEFAULT_GROW

public static final double DEFAULT_GROW
The default resize weight.
Field Value:
1.0

NO_GROW

public static final double NO_GROW
Gives a column or row a fixed size.
Field Value:
0.0

Constructor Details

FormSpec

protected FormSpec(FormSpec.DefaultAlignment defaultAlignment,
                   String encodedDescription)
Constructs a FormSpec from the specified encoded description. The description will be parsed to set initial values.
Parameters:
defaultAlignment - the default alignment
encodedDescription - the encoded description

FormSpec

protected FormSpec(FormSpec.DefaultAlignment defaultAlignment,
                   Size size,
                   double resizeWeight)
Constructs a FormSpec for the given default alignment, size, and resize weight. The resize weight must be a non-negative double; you can use NONE as a convenience value for no resize.
Parameters:
defaultAlignment - the spec's default alignment
size - a constant, component or bounded size
resizeWeight - the spec resize weight

Method Details

encode

public final String encode()
Returns a short and parseable string representation of this form specification. The string will omit the alignment and resize specifications if these are the default values.

Returns:
a string representation of the form specification.
Since:
1.2

getDefaultAlignment

public final FormSpec.DefaultAlignment getDefaultAlignment()
Returns the default alignment.
Returns:
the default alignment

getResizeWeight

public final double getResizeWeight()
Returns the current resize weight.
Returns:
the resize weight.

getSize

public final Size getSize()
Returns the size.
Returns:
the size

toShortString

public final String toShortString()
Returns:
a string representation of the form specification.

toString

public final String toString()
Returns:
a string representation of the form specification.

Copyright © 2002-2008 JGoodies Karsten Lentzsch. All Rights Reserved.