public abstract class FormSpec
extends java.lang.Object
implements java.io.Serializable
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.
ColumnSpec,
RowSpec,
FormLayout,
CellConstraints,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
static class |
FormSpec.DefaultAlignment
An ordinal-based serializable typesafe enumeration for the
column and row default alignment types.
|
| Modifier and Type | Field and Description |
|---|---|
(package private) static FormSpec.DefaultAlignment |
BOTTOM_ALIGN
By default put the components in the bottom.
|
private static java.util.regex.Pattern |
BOUNDS_SEPARATOR_PATTERN |
(package private) static FormSpec.DefaultAlignment |
CENTER_ALIGN
By default put the components in the center.
|
static double |
DEFAULT_GROW
The default resize weight.
|
private FormSpec.DefaultAlignment |
defaultAlignment
Holds the default alignment that will be used if a cell does not
override this default.
|
private boolean |
defaultAlignmentExplicitlySet
Describes whether the default alignment has been explictly set.
|
(package private) static FormSpec.DefaultAlignment |
FILL_ALIGN
By default fill the column or row.
|
(package private) static FormSpec.DefaultAlignment |
LEFT_ALIGN
By default put components in the left.
|
(package private) static FormSpec.DefaultAlignment |
NO_ALIGN
A special alignment intended for table columns only,
where some cell renderers are not aligned.
|
static double |
NO_GROW
Gives a column or row a fixed size.
|
private double |
resizeWeight
Holds the resize weight; is 0 if not used.
|
(package private) static FormSpec.DefaultAlignment |
RIGHT_ALIGN
By default put components in the right.
|
private Size |
size
Holds the size that describes how to size this column or row.
|
private static java.util.regex.Pattern |
TOKEN_SEPARATOR_PATTERN |
(package private) static FormSpec.DefaultAlignment |
TOP_ALIGN
By default put the components in the top.
|
private static FormSpec.DefaultAlignment[] |
VALUES
An array of all enumeration values used to canonicalize
deserialized default alignments.
|
| Modifier | Constructor and Description |
|---|---|
protected |
FormSpec(FormSpec.DefaultAlignment defaultAlignment,
Size size,
double resizeWeight)
Constructs a
FormSpec for the given default alignment,
size, and resize weight. |
protected |
FormSpec(FormSpec.DefaultAlignment defaultAlignment,
java.lang.String encodedDescription)
Constructs a FormSpec from the specified encoded description.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) boolean |
canGrow()
Checks and answers whether this spec can grow or not.
|
java.lang.String |
encode()
Returns a short and parseable string representation of this
form specification.
|
FormSpec.DefaultAlignment |
getDefaultAlignment()
Returns the default alignment.
|
boolean |
getDefaultAlignmentExplictlySet()
Returns whether the default alignment has been explicitly set or not.
|
double |
getResizeWeight()
Returns the current resize weight.
|
Size |
getSize()
Returns the size.
|
private static boolean |
isConstant(Size aSize) |
(package private) abstract boolean |
isHorizontal()
Returns if this is a horizontal specification (vs.
|
(package private) int |
maximumSize(java.awt.Container container,
java.util.List components,
FormLayout.Measure minMeasure,
FormLayout.Measure prefMeasure,
FormLayout.Measure defaultMeasure)
Computes the maximum size for the given list of components, using
this form spec and the specified measure.
|
private void |
parseAndInitValues(java.lang.String encodedDescription)
Parses an encoded form specification and initializes all required fields.
|
private Size |
parseAtomicSize(java.lang.String token)
Decodes and returns an atomic size that is either a constant size or a
component size.
|
private Size |
parseBoundedSize(java.lang.String token) |
private Size |
parseOldBoundedSize(java.lang.String token,
boolean setMax)
Parses an encoded compound size and sets the size fields.
|
private static double |
parseResizeWeight(java.lang.String token)
Decodes an encoded resize mode and resize weight and answers
the resize weight.
|
private Size |
parseSize(java.lang.String token)
Parses an encoded size spec and returns the size.
|
(package private) void |
setDefaultAlignment(FormSpec.DefaultAlignment defaultAlignment) |
(package private) void |
setResizeWeight(double resizeWeight) |
(package private) void |
setSize(Size 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.
|
static final FormSpec.DefaultAlignment LEFT_ALIGN
static final FormSpec.DefaultAlignment RIGHT_ALIGN
static final FormSpec.DefaultAlignment TOP_ALIGN
static final FormSpec.DefaultAlignment BOTTOM_ALIGN
static final FormSpec.DefaultAlignment CENTER_ALIGN
static final FormSpec.DefaultAlignment FILL_ALIGN
static final FormSpec.DefaultAlignment NO_ALIGN
private static final FormSpec.DefaultAlignment[] VALUES
public static final double NO_GROW
public static final double DEFAULT_GROW
private static final java.util.regex.Pattern TOKEN_SEPARATOR_PATTERN
private static final java.util.regex.Pattern BOUNDS_SEPARATOR_PATTERN
private FormSpec.DefaultAlignment defaultAlignment
private boolean defaultAlignmentExplicitlySet
getDefaultAlignmentExplictlySet()private Size size
private double resizeWeight
protected FormSpec(FormSpec.DefaultAlignment defaultAlignment, Size size, double resizeWeight)
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.defaultAlignment - the spec's default alignmentsize - a constant, component or bounded sizeresizeWeight - the spec resize weightjava.lang.NullPointerException - if the size is nulljava.lang.IllegalArgumentException - if the resizeWeight is negativeprotected FormSpec(FormSpec.DefaultAlignment defaultAlignment, java.lang.String encodedDescription)
defaultAlignment - the default alignmentencodedDescription - the encoded descriptionpublic final FormSpec.DefaultAlignment getDefaultAlignment()
public final boolean getDefaultAlignmentExplictlySet()
true if the default alignment has been provided
during the parse process, false if the default alignment
has been set by the constructor at the instance creation timepublic final Size getSize()
public final double getResizeWeight()
final boolean canGrow()
NO_GROW.abstract boolean isHorizontal()
void setDefaultAlignment(FormSpec.DefaultAlignment defaultAlignment)
void setSize(Size size)
void setResizeWeight(double resizeWeight)
private void parseAndInitValues(java.lang.String encodedDescription)
encodedDescription - the FormSpec in an encoded formatjava.lang.NullPointerException - if encodedDescription is nulljava.lang.IllegalArgumentException - if encodedDescription
is empty, whitespace, has no size, or is otherwise invalidprivate Size parseSize(java.lang.String token)
token - a token that represents a size, either bounded or plainprivate Size parseBoundedSize(java.lang.String token)
private Size parseOldBoundedSize(java.lang.String token, boolean setMax)
token - a token for a bounded size, e.g. "max(50dlu; pref)"setMax - if true we set a maximum size, otherwise a minimum sizeprivate Size parseAtomicSize(java.lang.String token)
token - the encoded sizeprivate static double parseResizeWeight(java.lang.String token)
token - the encoded resize weightjava.lang.IllegalArgumentException - if the string description is an
invalid string representationprivate static boolean isConstant(Size aSize)
public final java.lang.String toString()
This method does not return an encoded version of this object; the contrary is the case. Many instances will return a string that cannot be parsed.
Note: The string representation may change at any time.
For parsing use encode() instead.
toString in class java.lang.Objectpublic final java.lang.String toShortString()
This method does not return an encoded version of this object; the contrary is the case. Many instances will return a string that cannot be parsed.
Note: The string representation may change at any time.
For parsing use encode() instead.
public final java.lang.String encode()
for a more verbose string representationfinal int maximumSize(java.awt.Container container,
java.util.List components,
FormLayout.Measure minMeasure,
FormLayout.Measure prefMeasure,
FormLayout.Measure defaultMeasure)
Invoked by FormLayout to determine the size of one of my elements
container - the layout containercomponents - the list of components to measureminMeasure - the measure used to determine the minimum sizeprefMeasure - the measure used to determine the preferred sizedefaultMeasure - the measure used to determine the default size