public class CellGroup extends Object implements Serializable
A simple helper class to define columns and rows with identical size in
PercentLayout
.
In GUI design it is often desirable that certain columns and rows have exactly the same size, independent from the components they contain. An example would be columns with labels that have a different width. With this class it is possible to define the indices of columns and rows that should have the same size.
This class defines some convenience constructors for dealing with a limited
number of cells. There is also a generic constructor which expects an array
with cell indices. The numeric values passed to the constructors are
interpreted as 0-based indices of columns and rows that have already been
defined in PercentLayout
. It is also possible to set the indices
of the affected cells using a string format. Valid strings simply contain the
numeric indices separated by one or more of the following characters: "
,;/". Examples for valid strings would be:
"1 3 4" "1, 3,4" "1;3/4" etc.
CellGroup
objects are immutable. There are no setter methods for
manipulating instances once they have been created.
Constructor and Description |
---|
CellGroup(int idx1,
int idx2)
Creates a new instance of
CellGroup . |
CellGroup(int idx1,
int idx2,
int idx3)
Creates a new instance of
CellGroup . |
CellGroup(int idx1,
int idx2,
int idx3,
int idx4)
Creates a new instance of
CellGroup . |
Modifier and Type | Method and Description |
---|---|
void |
apply(int[] sizes)
Applies this group object to the given cell sizes.
|
void |
buildString(StringBuilder buf)
Appends a string representation of this object to the given string
buffer.
|
boolean |
equals(Object obj)
Compares this object with another one.
|
static CellGroup |
fromArray(int... idx)
Creates a new instance of
CellGroup and initializes it with
the indices of the affected cells. |
static CellGroup |
fromString(String s)
Creates a new instance of
CellGroup and initializes it from
the passed in string. |
int |
groupSize()
Returns the number of elements contained in this group.
|
int |
hashCode()
Returns a hash code for this object.
|
String |
toString()
Creates a string representation of this object.
|
public CellGroup(int idx1, int idx2)
CellGroup
. The group contains the
two passed in cells.idx1
- the index of the first cellidx2
- the index of the second cellpublic CellGroup(int idx1, int idx2, int idx3)
CellGroup
. The group contains the
three passed in cells.idx1
- the index of the first cellidx2
- the index of the second cellidx3
- the index of the third cellpublic CellGroup(int idx1, int idx2, int idx3, int idx4)
CellGroup
. The group contains the
four passed in cells.idx1
- the index of the first cellidx2
- the index of the second cellidx3
- the index of the third cellidx4
- the index of the fourth cellpublic static CellGroup fromArray(int... idx)
CellGroup
and initializes it with
the indices of the affected cells.idx
- an array with the cell indicesCellGroup
objectpublic static CellGroup fromString(String s)
CellGroup
and initializes it from
the passed in string.s
- a string defining the cell indicesCellGroup
objectpublic int groupSize()
public void apply(int[] sizes)
sizes
- an array with the cell sizes (must not be null)IllegalArgumentException
- if the array with sizes is nullArrayIndexOutOfBoundsException
- if indices in this group are too
bigpublic void buildString(StringBuilder buf)
buf
- the target buffer (must not be null)IllegalArgumentException
- if the target buffer is nullpublic String toString()
public boolean equals(Object obj)
CellGroup
are equal if they contain the same indices (the order does not matter).Copyright © 2016 The JGUIraffe Team. All rights reserved.