Class PercentData
- java.lang.Object
-
- net.sf.jguiraffe.gui.layout.PercentData
-
- All Implemented Interfaces:
Serializable
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 creatingPercentData
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();
- Version:
- $Id: PercentData.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
- See Also:
CellConstraints
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PercentData.Builder
A builder implementation for creating instances ofPercentData
.
-
Field Summary
Fields Modifier and Type Field Description static int
POS_UNDEF
Constant for an undefined cell position.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Field Detail
-
POS_UNDEF
public static final int POS_UNDEF
Constant for an undefined cell position.- See Also:
- Constant Field Values
-
-
Method Detail
-
getColumn
public int getColumn()
Returns the number of the column, in which the corresponding component is to be placed.- Returns:
- the column number
-
getRow
public int getRow()
Returns the number of the row, in which the corresponding component it to be placed.- Returns:
- the row number
-
getSpanX
public int getSpanX()
Returns the number of occupied columns.- Returns:
- the number of occupied columns
-
getSpanY
public int getSpanY()
Returns the number of occupied rows.- Returns:
- the number of occupied rows
-
getTargetColumn
public int getTargetColumn()
Returns the target column.- Returns:
- the target column
-
getTargetRow
public int getTargetRow()
Returns the target row.- Returns:
- the target row
-
getColumnConstraints
public CellConstraints getColumnConstraints()
Returns the associated constraints object for the column.- Returns:
- the column constraints object (may be null )
-
getRowConstraints
public CellConstraints getRowConstraints()
Returns the associated constraints object for the row.- Returns:
- the row constraints object (may be null )
-
getConstraints
public CellConstraints getConstraints(boolean vert)
A convenience method for determining the cell constraints object for the specified orientation. This method is useful for some generic methods inPercentLayoutBase
that can operate either on columns or on rows.- Parameters:
vert
- the orientation flag (true for vertical, false for horizontal)- Returns:
- the corresponding constraints object
-
buildString
public void buildString(StringBuilder buf)
Appends a string representation of this object to the specified string buffer. This string contains the properties of this instance with their values. No further information (e.g. the class name) is written.- Parameters:
buf
- the target buffer (must not be null)- Throws:
IllegalArgumentException
- if the buffer is null
-
toString
public String toString()
Returns a string representation of this object.
-
equals
public boolean equals(Object obj)
Compares this object with another one. Two instances ofPercentData
are considered equal if all of their properties are equal.
-
-