public final class PercentData extends Object implements Serializable
A constraints class used by PercentLayout
.
This class is used to define data needed by the percent layout manager when new components are added to the managed container. The main data stored in instances of this class is information about where in the logic grid maintained by the layout manager the new component should be placed, i.e. the coordinates of the cell and the number of cells in X and Y direction that are spanned.
It is also possible to associate a PercentData
object with row
and column constraints. If these constraints are defined, they override the
constraints set for the occupied column and row. This makes it possible e.g.
to set a different alignment for a certain component, while the other
components in this row or column use the default alignment.
Another information stored in instances of this class is the so-called target cell. This information is evaluated only if multiple columns or rows are occupied. In this case the target column determines to which column the size of the associated component should be assigned. This is optional; if no target column is set, the associated component's width will not be taken into account when the minimum layout width is calculated. The same applies for the target row.
Instances of this class are immutable and thus thread-safe. They are not
created directly, but the nested Builder
class is used for this
purpose. A typical sequence for creating PercentData
objects could
look as follows:
PercentData.Builder b = new PercentData.Builder(); PercentData pd1 = b.xy(1, 2).create(); PercentData pd2 = b.xy(1, 3).spanX(2).withColumnConstraints(columnConstr).create();
CellConstraints
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
PercentData.Builder
A builder implementation for creating instances of
PercentData . |
Modifier and Type | Field and Description |
---|---|
static int |
POS_UNDEF
Constant for an undefined cell position.
|
Modifier and Type | Method and Description |
---|---|
void |
buildString(StringBuilder buf)
Appends a string representation of this object to the specified string
buffer.
|
boolean |
equals(Object obj)
Compares this object with another one.
|
int |
getColumn()
Returns the number of the column, in which the corresponding component is
to be placed.
|
CellConstraints |
getColumnConstraints()
Returns the associated constraints object for the column.
|
CellConstraints |
getConstraints(boolean vert)
A convenience method for determining the cell constraints object for the
specified orientation.
|
int |
getRow()
Returns the number of the row, in which the corresponding component it to
be placed.
|
CellConstraints |
getRowConstraints()
Returns the associated constraints object for the row.
|
int |
getSpanX()
Returns the number of occupied columns.
|
int |
getSpanY()
Returns the number of occupied rows.
|
int |
getTargetColumn()
Returns the target column.
|
int |
getTargetRow()
Returns the target row.
|
int |
hashCode()
Returns a hash code for this object.
|
String |
toString()
Returns a string representation of this object.
|
public static final int POS_UNDEF
public int getColumn()
public int getRow()
public int getSpanX()
public int getSpanY()
public int getTargetColumn()
public int getTargetRow()
public CellConstraints getColumnConstraints()
public CellConstraints getRowConstraints()
public CellConstraints getConstraints(boolean vert)
PercentLayoutBase
that can operate either on columns or on
rows.vert
- the orientation flag (true for vertical, false
for horizontal)public void buildString(StringBuilder buf)
buf
- the target buffer (must not be null)IllegalArgumentException
- if the buffer is nullpublic String toString()
public boolean equals(Object obj)
PercentData
are considered equal if all of their properties are equal.Copyright © 2016 The JGUIraffe Team. All rights reserved.