Class CellConstraints
java.lang.Object
com.vaadin.featurepack.desktop.layouts.form.CellConstraints
- All Implemented Interfaces:
Serializable,Cloneable
Defines constraints for placing components inside the
FormLayout.
Constraints describe the components display area: gridX, gridY, grid width
(column span), and grid height (row span). Cell constraints need to be set
using FormLayout.setConstraints(Component, Object).
Most methods return this object to enable method chaining. Note,
FormLayout implicitly clones the cell constraints instance when
applying it to specific components.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAn ordinal-based serializable type-safe enumeration for component alignment types as used by theFormLayout. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CellConstraints.AlignmentPut the component in the bottom.static final CellConstraints.AlignmentPut the component in the center.static final CellConstraints.AlignmentUse the column's or row's default alignment.static final CellConstraints.AlignmentFill the cell either horizontally or vertically.intDescribes the component's vertical grid extent (number of cells).intDescribes the component's horizontal grid extend (number of cells).intDescribes the component's horizontal grid origin (starts at 1).intDescribes the component's vertical grid origin (starts at 1).Describes the component's horizontal alignment.static final CellConstraints.AlignmentPut the component in the left.static final CellConstraints.AlignmentPut the component in the right.static final CellConstraints.AlignmentPut the component in the top.Describes the component's vertical alignment. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a default instance ofCellConstraints.CellConstraints(int gridX, int gridY) Constructs an instance ofCellConstraintsfor the given cell position.CellConstraints(int gridX, int gridY, int gridWidth, int gridHeight) Constructs an instance ofCellConstraintsfor the given cell position and size.CellConstraints(int gridX, int gridY, int gridWidth, int gridHeight, CellConstraints.Alignment hAlign, CellConstraints.Alignment vAlign) Constructs an instance ofCellConstraintsfor the given cell position, size and alignment.CellConstraints(int gridX, int gridY, CellConstraints.Alignment hAlign, CellConstraints.Alignment vAlign) Constructs an instance ofCellConstraintsfor the given cell position and alignment.CellConstraints(String encodedConstraints) Constructs an instance ofCellConstraintsfrom the given encoded string properties. -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a copy of this cell constraints object.xy(int col, int row) Sets column and row origins; sets width and height to 1.xy(int col, int row, CellConstraints.Alignment colAlign, CellConstraints.Alignment rowAlign) Sets the column and row origins; sets width and height to 1; set horizontal and vertical alignment using the specified objects.Sets column and row origins; sets width and height to 1; decodes horizontal and vertical alignments from the given string.xyw(int col, int row, int colSpan) Sets the column, row, and width; uses a height (row span) of 1.xyw(int col, int row, int colSpan, CellConstraints.Alignment colAlign, CellConstraints.Alignment rowAlign) Sets the column, row, width, and height; sets the horizontal and vertical alignment using the specified objects.Sets the column, row, width, and height; decodes the horizontal and vertical alignments from the given string.xywh(int col, int row, int colSpan, int rowSpan) Sets the column, row, width, and height.xywh(int col, int row, int colSpan, int rowSpan, CellConstraints.Alignment colAlign, CellConstraints.Alignment rowAlign) Sets the column, row, width, and height; sets the horizontal and vertical alignment using the specified alignment objects.Sets the column, row, width, and height; decodes the horizontal and vertical alignments from the given string.
-
Field Details
-
DEFAULT
Use the column's or row's default alignment. -
FILL
Fill the cell either horizontally or vertically. -
LEFT
Put the component in the left. -
RIGHT
Put the component in the right. -
CENTER
Put the component in the center. -
TOP
Put the component in the top. -
BOTTOM
Put the component in the bottom. -
gridX
public int gridXDescribes the component's horizontal grid origin (starts at 1). -
gridY
public int gridYDescribes the component's vertical grid origin (starts at 1). -
gridWidth
public int gridWidthDescribes the component's horizontal grid extend (number of cells). -
gridHeight
public int gridHeightDescribes the component's vertical grid extent (number of cells). -
hAlign
Describes the component's horizontal alignment. -
vAlign
Describes the component's vertical alignment.
-
-
Constructor Details
-
CellConstraints
public CellConstraints()Constructs a default instance ofCellConstraints. -
CellConstraints
public CellConstraints(int gridX, int gridY) Constructs an instance ofCellConstraintsfor the given cell position.- Parameters:
gridX- the component's horizontal grid origingridY- the component's vertical grid origin
-
CellConstraints
public CellConstraints(int gridX, int gridY, CellConstraints.Alignment hAlign, CellConstraints.Alignment vAlign) Constructs an instance ofCellConstraintsfor the given cell position and alignment.- Parameters:
gridX- the component's horizontal grid origingridY- the component's vertical grid originhAlign- the component's horizontal alignmentvAlign- the component's vertical alignment
-
CellConstraints
public CellConstraints(int gridX, int gridY, int gridWidth, int gridHeight) Constructs an instance ofCellConstraintsfor the given cell position and size.- Parameters:
gridX- the component's horizontal grid origingridY- the component's vertical grid origingridWidth- the component's horizontal extentgridHeight- the component's vertical extent
-
CellConstraints
public CellConstraints(int gridX, int gridY, int gridWidth, int gridHeight, CellConstraints.Alignment hAlign, CellConstraints.Alignment vAlign) Constructs an instance ofCellConstraintsfor the given cell position, size and alignment.- Parameters:
gridX- the component's horizontal grid origingridY- the component's vertical grid origingridWidth- the component's horizontal extentgridHeight- the component's vertical extenthAlign- the component's horizontal alignmentvAlign- the component's vertical alignment- Throws:
IndexOutOfBoundsException- if the grid origin or extent is negativeNullPointerException- if the horizontal or vertical alignment is nullIllegalArgumentException- if an alignment orientation is invalid
-
CellConstraints
Constructs an instance ofCellConstraintsfrom the given encoded string properties.Examples:
new CellConstraints("1, 3"); new CellConstraints("1, 3, left, bottom"); new CellConstraints("1, 3, 2, 1, left, bottom"); new CellConstraints("1, 3, 2, 1, l, b");- Parameters:
encodedConstraints- the constraints encoded as string
-
-
Method Details
-
xy
Sets column and row origins; sets width and height to 1.- Parameters:
col- the new column indexrow- the new row index- Returns:
- this
-
xy
Sets column and row origins; sets width and height to 1; decodes horizontal and vertical alignments from the given string.- Parameters:
col- the new column indexrow- the new row indexencodedAlignments- describes the horizontal and vertical alignments- Returns:
- this
- Throws:
IllegalArgumentException- if an alignment orientation is invalid
-
xy
public CellConstraints xy(int col, int row, CellConstraints.Alignment colAlign, CellConstraints.Alignment rowAlign) Sets the column and row origins; sets width and height to 1; set horizontal and vertical alignment using the specified objects.- Parameters:
col- the new column indexrow- the new row indexcolAlign- horizontal component alignmentrowAlign- vertical component alignment- Returns:
- this
-
xyw
Sets the column, row, and width; uses a height (row span) of 1.- Parameters:
col- the new column indexrow- the new row indexcolSpan- the column span or grid width- Returns:
- this
-
xyw
Sets the column, row, width, and height; decodes the horizontal and vertical alignments from the given string. Uses a height (row span) of 1.Examples:
cc.xyw(1, 3, 7, "left, bottom"); cc.xyw(1, 3, 7, "l, b"); cc.xyw(1, 3, 2, "center, fill"); cc.xyw(1, 3, 2, "c, f");
- Parameters:
col- the new column indexrow- the new row indexcolSpan- the column span or grid widthencodedAlignments- describes the horizontal and vertical alignments- Returns:
- this
- Throws:
IllegalArgumentException- if an alignment orientation is invalid
-
xyw
public CellConstraints xyw(int col, int row, int colSpan, CellConstraints.Alignment colAlign, CellConstraints.Alignment rowAlign) Sets the column, row, width, and height; sets the horizontal and vertical alignment using the specified objects. Uses a height (row span) of 1.Examples:
cc.xyw(1, 3, 2, CellConstraints.LEFT, CellConstraints.BOTTOM); cc.xyw(1, 3, 7, CellConstraints.CENTER, CellConstraints.FILL);
- Parameters:
col- the new column indexrow- the new row indexcolSpan- the column span or grid widthcolAlign- horizontal component alignmentrowAlign- vertical component alignment- Returns:
- this
- Throws:
IllegalArgumentException- if an alignment orientation is invalid
-
xywh
Sets the column, row, width, and height.- Parameters:
col- the new column indexrow- the new row indexcolSpan- the column span or grid widthrowSpan- the row span or grid height- Returns:
- this
-
xywh
Sets the column, row, width, and height; decodes the horizontal and vertical alignments from the given string.- Parameters:
col- the new column indexrow- the new row indexcolSpan- the column span or grid widthrowSpan- the row span or grid heightencodedAlignments- describes the horizontal and vertical alignments- Returns:
- this
- Throws:
IllegalArgumentException- if an alignment orientation is invalid
-
xywh
public CellConstraints xywh(int col, int row, int colSpan, int rowSpan, CellConstraints.Alignment colAlign, CellConstraints.Alignment rowAlign) Sets the column, row, width, and height; sets the horizontal and vertical alignment using the specified alignment objects.- Parameters:
col- the new column indexrow- the new row indexcolSpan- the column span or grid widthrowSpan- the row span or grid heightcolAlign- horizontal component alignmentrowAlign- vertical component alignment- Returns:
- this
- Throws:
IllegalArgumentException- if an alignment orientation is invalid
-
clone
Creates a copy of this cell constraints object.
-