|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgoodies.forms.layout.CellConstraints
public final class CellConstraints
Defines constraints for components that are layed out with the FormLayout. Defines the components display area: grid x, grid y, grid width (column span), grid height (row span), horizontal alignment and vertical alignment.
Most methods return this object to enable method chaining.
You can set optional insets in a constructor. This is useful if you need to use a pixel-size insets to align perceived component bounds with pixel data, for example an icon. Anyway, this is rarely used. The insets don't affect the size computation for columns and rows. I consider renaming the insets to offsets to better indicate the motivation for this option.
Examples:
The following cell constraints locate a component in the third
column of the fifth row; column and row span are 1; the component
will be aligned with the column's right-hand side and the row's
bottom.
CellConstraints cc = new CellConstraints(); cc.xy (3, 5); cc.xy (3, 5, CellConstraints.RIGHT, CellConstraints.BOTTOM); cc.xy (3, 5, "right, bottom"); cc.xyw (3, 5, 1); cc.xyw (3, 5, 1, CellConstraints.RIGHT, CellConstraints.BOTTOM); cc.xyw (3, 5, 1, "right, bottom"); cc.xywh(3, 5, 1, 1); cc.xywh(3, 5, 1, 1, CellConstraints.RIGHT, CellConstraints.BOTTOM); cc.xywh(3, 5, 1, 1, "right, bottom");See also the examples in the
FormLayout
class comment.TODO: Consider renaming the inset to offsets.
Nested Class Summary | |
---|---|
static class |
CellConstraints.Alignment
An ordinal-based serializable typesafe enumeration for component alignment types as used by the FormLayout . |
Field Summary | |
---|---|
static CellConstraints.Alignment |
BOTTOM
Put the component in the bottom. |
static CellConstraints.Alignment |
CENTER
Put the component in the center. |
static CellConstraints.Alignment |
DEFAULT
Use the column's or row's default alignment. |
static CellConstraints.Alignment |
FILL
Fill the cell either horizontally or vertically. |
int |
gridHeight
Describes the component's vertical grid extent (number of cells). |
int |
gridWidth
Describes the component's horizontal grid extend (number of cells). |
int |
gridX
Describes the component's horizontal grid origin (starts at 1). |
int |
gridY
Describes the component's vertical grid origin (starts at 1). |
CellConstraints.Alignment |
hAlign
Describes the component's horizontal alignment. |
Insets |
insets
Describes the component's Insets in it's display area. |
static CellConstraints.Alignment |
LEFT
Put the component in the left. |
static CellConstraints.Alignment |
RIGHT
Put the component in the right. |
static CellConstraints.Alignment |
TOP
Put the component in the top. |
CellConstraints.Alignment |
vAlign
Describes the component's vertical alignment. |
Constructor Summary | |
---|---|
CellConstraints()
Constructs a default instance of CellConstraints . |
|
CellConstraints(int gridX,
int gridY)
Constructs an instance of CellConstraints for the given
cell position. |
|
CellConstraints(int gridX,
int gridY,
CellConstraints.Alignment hAlign,
CellConstraints.Alignment vAlign)
Constructs an instance of CellConstraints for the given
cell position, anchor, and fill. |
|
CellConstraints(int gridX,
int gridY,
int gridWidth,
int gridHeight)
Constructs an instance of CellConstraints for the given
cell position and size. |
|
CellConstraints(int gridX,
int gridY,
int gridWidth,
int gridHeight,
CellConstraints.Alignment hAlign,
CellConstraints.Alignment vAlign)
Constructs an instance of CellConstraints for the given
cell position and size, anchor, and fill. |
|
CellConstraints(int gridX,
int gridY,
int gridWidth,
int gridHeight,
CellConstraints.Alignment hAlign,
CellConstraints.Alignment vAlign,
Insets insets)
Constructs an instance of CellConstraints for
the complete set of available properties. |
|
CellConstraints(String encodedConstraints)
Constructs an instance of CellConstraints from
the given encoded string properties. |
Method Summary | |
---|---|
Object |
clone()
Creates a copy of this cell constraints object. |
String |
toShortString()
Returns a short string representation of this constraints object. |
String |
toShortString(FormLayout layout)
Returns a short string representation of this constraints object. |
String |
toString()
Constructs and returns a string representation of this constraints object. |
CellConstraints |
xy(int col,
int row)
Sets row and column origins; sets width and height to 1; uses the default alignments. |
CellConstraints |
xy(int col,
int row,
CellConstraints.Alignment colAlign,
CellConstraints.Alignment rowAlign)
Sets the row and column origins; sets width and height to 1; set horizontal and vertical alignment using the specified objects. |
CellConstraints |
xy(int col,
int row,
String encodedAlignments)
Sets row and column origins; sets width and height to 1; decodes horizontal and vertical alignments from the given string. |
CellConstraints |
xyw(int col,
int row,
int colSpan)
Sets the row, column, width, and height; uses a height (row span) of 1 and the horizontal and vertical default alignments. |
CellConstraints |
xyw(int col,
int row,
int colSpan,
CellConstraints.Alignment colAlign,
CellConstraints.Alignment rowAlign)
Sets the row, column, width, and height; sets the horizontal and vertical aligment using the specified alignment objects. |
CellConstraints |
xyw(int col,
int row,
int colSpan,
String encodedAlignments)
Sets the row, column, width, and height; decodes the horizontal and vertical alignments from the given string. |
CellConstraints |
xywh(int col,
int row,
int colSpan,
int rowSpan)
Sets the row, column, width, and height; uses default alignments. |
CellConstraints |
xywh(int col,
int row,
int colSpan,
int rowSpan,
CellConstraints.Alignment colAlign,
CellConstraints.Alignment rowAlign)
Sets the row, column, width, and height; sets the horizontal and vertical aligment using the specified alignment objects. |
CellConstraints |
xywh(int col,
int row,
int colSpan,
int rowSpan,
String encodedAlignments)
Sets the row, column, width, and height; decodes the horizontal and vertical alignments from the given string. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final CellConstraints.Alignment DEFAULT
public static final CellConstraints.Alignment FILL
public static final CellConstraints.Alignment LEFT
public static final CellConstraints.Alignment RIGHT
public static final CellConstraints.Alignment CENTER
public static final CellConstraints.Alignment TOP
public static final CellConstraints.Alignment BOTTOM
public int gridX
public int gridY
public int gridWidth
public int gridHeight
public CellConstraints.Alignment hAlign
public CellConstraints.Alignment vAlign
public Insets insets
Insets
in it's display area.
Constructor Detail |
---|
public CellConstraints()
CellConstraints
.
public CellConstraints(int gridX, int gridY)
CellConstraints
for the given
cell position.Examples:
new CellConstraints(1, 3); new CellConstraints(1, 3);
gridX
- the component's horizontal grid origingridY
- the component's vertical grid originpublic CellConstraints(int gridX, int gridY, CellConstraints.Alignment hAlign, CellConstraints.Alignment vAlign)
CellConstraints
for the given
cell position, anchor, and fill.Examples:
new CellConstraints(1, 3, CellConstraints.LEFT, CellConstraints.BOTTOM); new CellConstraints(1, 3, CellConstraints.CENTER, CellConstraints.FILL);
gridX
- the component's horizontal grid origingridY
- the component's vertical grid originhAlign
- the component's horizontal alignmentvAlign
- the component's vertical alignmentpublic CellConstraints(int gridX, int gridY, int gridWidth, int gridHeight)
CellConstraints
for the given
cell position and size.Examples:
new CellConstraints(1, 3, 2, 1); new CellConstraints(1, 3, 7, 3);
gridX
- the component's horizontal grid origingridY
- the component's vertical grid origingridWidth
- the component's horizontal extentgridHeight
- the component's vertical extentpublic CellConstraints(int gridX, int gridY, int gridWidth, int gridHeight, CellConstraints.Alignment hAlign, CellConstraints.Alignment vAlign)
CellConstraints
for the given
cell position and size, anchor, and fill.Examples:
new CellConstraints(1, 3, 2, 1, CellConstraints.LEFT, CellConstraints.BOTTOM); new CellConstraints(1, 3, 7, 3, CellConstraints.CENTER, CellConstraints.FILL);
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 alignmentpublic CellConstraints(int gridX, int gridY, int gridWidth, int gridHeight, CellConstraints.Alignment hAlign, CellConstraints.Alignment vAlign, Insets insets)
CellConstraints
for
the complete set of available properties.Examples:
new CellConstraints(1, 3, 2, 1, CellConstraints.LEFT, CellConstraints.BOTTOM, new Insets(0, 1, 0, 3)); new CellConstraints(1, 3, 7, 3, CellConstraints.CENTER, CellConstraints.FILL, new Insets(0, 1, 0, 0));
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 alignmentinsets
- the component's display area Insets
IndexOutOfBoundsException
- if the grid origin or extent is negative
NullPointerException
- if the horizontal or vertical alignment is null
IllegalArgumentException
- if an alignment orientation is invalidpublic CellConstraints(String encodedConstraints)
CellConstraints
from
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");
encodedConstraints
- the constraints encoded as stringMethod Detail |
---|
public CellConstraints xy(int col, int row)
Examples:
cc.xy(1, 1); cc.xy(1, 3);
col
- the new column indexrow
- the new row index
public CellConstraints xy(int col, int row, String encodedAlignments)
Examples:
cc.xy(1, 3, "left, bottom"); cc.xy(1, 3, "l, b"); cc.xy(1, 3, "center, fill"); cc.xy(1, 3, "c, f");
col
- the new column indexrow
- the new row indexencodedAlignments
- describes the horizontal and vertical alignments
IllegalArgumentException
- if an alignment orientation is invalidpublic CellConstraints xy(int col, int row, CellConstraints.Alignment colAlign, CellConstraints.Alignment rowAlign)
Examples:
cc.xy(1, 3, CellConstraints.LEFT, CellConstraints.BOTTOM); cc.xy(1, 3, CellConstraints.CENTER, CellConstraints.FILL);
col
- the new column indexrow
- the new row indexcolAlign
- horizontal component alignmentrowAlign
- vertical component alignment
public CellConstraints xyw(int col, int row, int colSpan)
Examples:
cc.xyw(1, 3, 7); cc.xyw(1, 3, 2);
col
- the new column indexrow
- the new row indexcolSpan
- the column span or grid width
public CellConstraints xyw(int col, int row, int colSpan, String encodedAlignments)
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");
col
- the new column indexrow
- the new row indexcolSpan
- the column span or grid widthencodedAlignments
- describes the horizontal and vertical alignments
IllegalArgumentException
- if an alignment orientation is invalidpublic CellConstraints xyw(int col, int row, int colSpan, CellConstraints.Alignment colAlign, CellConstraints.Alignment rowAlign)
Examples:
cc.xyw(1, 3, 2, CellConstraints.LEFT, CellConstraints.BOTTOM); cc.xyw(1, 3, 7, CellConstraints.CENTER, CellConstraints.FILL);
col
- the new column indexrow
- the new row indexcolSpan
- the column span or grid widthcolAlign
- horizontal component alignmentrowAlign
- vertical component alignment
IllegalArgumentException
- if an alignment orientation is invalidpublic CellConstraints xywh(int col, int row, int colSpan, int rowSpan)
Examples:
cc.xywh(1, 3, 2, 1); cc.xywh(1, 3, 7, 3);
col
- the new column indexrow
- the new row indexcolSpan
- the column span or grid widthrowSpan
- the row span or grid height
public CellConstraints xywh(int col, int row, int colSpan, int rowSpan, String encodedAlignments)
Examples:
cc.xywh(1, 3, 2, 1, "left, bottom"); cc.xywh(1, 3, 2, 1, "l, b"); cc.xywh(1, 3, 7, 3, "center, fill"); cc.xywh(1, 3, 7, 3, "c, f");
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
IllegalArgumentException
- if an alignment orientation is invalidpublic CellConstraints xywh(int col, int row, int colSpan, int rowSpan, CellConstraints.Alignment colAlign, CellConstraints.Alignment rowAlign)
Examples:
cc.xywh(1, 3, 2, 1, CellConstraints.LEFT, CellConstraints.BOTTOM); cc.xywh(1, 3, 7, 3, CellConstraints.CENTER, CellConstraints.FILL);
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
IllegalArgumentException
- if an alignment orientation is invalidpublic Object clone()
clone
in class Object
public String toString()
toString
in class Object
public String toShortString()
public String toShortString(FormLayout layout)
FormLayout
to display extra information how default alignments
are mapped to concrete alignments. Therefore it asks the
related column and row as specified by this constraints object.
layout
- the layout to be presented as a string
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |