public static final class CellConstraints.Builder extends Object
A builder class for creating instances of CellConstraints.
With the different withXXXX() methods the properties of the new
CellConstraints object are defined. Then, with the create() method, the instance is actually created. Alternatively, with
the parse() method a CellConstraints instance for a
string representation can be requested.
This class is not thread-safe. It maintains an internal (unsynchronized)
cache of the CellConstraints instances that have already been
created. If instances with equal properties are requested, the same
instance is returned.
More information including a usage example of this class can be found in
the documentation for CellConstraints.
| Constructor and Description |
|---|
Builder()
Creates a new instance of
Builder. |
| Modifier and Type | Method and Description |
|---|---|
CellConstraints |
create()
Returns a
CellConstraints instance for the properties defined
so far. |
CellConstraints.Builder |
defaultColumn()
Initializes the properties of the
CellConstraints instance to
be created with default values for a column. |
CellConstraints.Builder |
defaultRow()
Initializes the properties of the
CellConstraints instance to
be created with default values for a row. |
CellConstraints |
fromString(String spec)
Parses a string with the specification of a
CellConstraints
object and returns a corresponding instance. |
CellAlignment |
getDefaultAlignment()
Returns the default
CellAlignment used by this builder. |
void |
reset()
Resets all properties set so far.
|
void |
setDefaultAlignment(CellAlignment defaultAlignment)
Sets the default
CellAlignment used by this builder. |
CellConstraints.Builder |
withCellAlignment(CellAlignment align)
Sets the
alignment property of the CellConstraints
instance to be created. |
CellConstraints.Builder |
withCellSize(CellSize sz)
Sets the
size property of the CellConstraints
instance to be created. |
CellConstraints.Builder |
withMinimumSize(NumberWithUnit minSize)
Sets the
minimumSize property of the CellConstraints
instance to be created. |
CellConstraints.Builder |
withWeight(int factor)
Sets the
weight property of the CellConstraints
instance to be created. |
public CellAlignment getDefaultAlignment()
CellAlignment used by this builder.CellAlignmentpublic void setDefaultAlignment(CellAlignment defaultAlignment)
CellAlignment used by this builder. This
alignment is set by the reset() method. Note: after calling
this method reset() must be called to apply the new default
alignment.defaultAlignment - the new default alignment (must not be
null)IllegalArgumentException - if the parameter is nullpublic CellConstraints.Builder withCellSize(CellSize sz)
size property of the CellConstraints
instance to be created.sz - the size of the cell (must not be null)IllegalArgumentException - if the CellSize object is
nullpublic CellConstraints.Builder withMinimumSize(NumberWithUnit minSize)
minimumSize property of the CellConstraints
instance to be created.minSize - the minimum size of the cell (can be null, then
a minimum size of 0 pixels is assumed)IllegalArgumentException - if the value of the minimum size is
negativepublic CellConstraints.Builder withCellAlignment(CellAlignment align)
alignment property of the CellConstraints
instance to be created.align - the alignment of the cell (must not be null)IllegalArgumentException - if the alignment is nullpublic CellConstraints.Builder withWeight(int factor)
weight property of the CellConstraints
instance to be created. This must be a positive number.factor - the weight factorIllegalArgumentException - if the number is less than 0public CellConstraints.Builder defaultColumn()
CellConstraints instance to
be created with default values for a column. This means:
FULLPREFERREDwithXXXX() methods specific values can be
set.public CellConstraints.Builder defaultRow()
CellConstraints instance to
be created with default values for a row. This means:
CENTERPREFERREDwithXXXX() methods specific values can be
set.public CellConstraints create()
CellConstraints instance for the properties defined
so far. After that all properties are reset, so that properties for a
new instance can be specified.CellConstraints instance corresponding to the
properties set so farIllegalStateException - if required properties are missingpublic void reset()
withXXXX() methods since the last instance was created.public CellConstraints fromString(String spec)
CellConstraints
object and returns a corresponding instance.spec - the specification of the CellConstraints instanceCellConstraints instanceIllegalArgumentException - if the string cannot be parsedCopyright © 2016 The JGUIraffe Team. All rights reserved.