Method from com.lowagie.text.Row Detail: |
int addElement(Object element) {
return addElement(element, currentColumn);
}
|
int addElement(Object element,
int column) {
if (element == null) throw new NullPointerException("addCell - null argument");
if ((column < 0) || (column > columns)) throw new IndexOutOfBoundsException("addCell - illegal column argument");
if ( !((getObjectID(element) == CELL) || (getObjectID(element) == TABLE)) ) throw new IllegalArgumentException("addCell - only Cells or Tables allowed");
int lColspan = ( (Cell.class.isInstance(element)) ? ((Cell) element).getColspan() : 1);
if (!reserve(column, lColspan)) {
return -1;
}
cells[column] = element;
currentColumn += lColspan - 1;
return column;
}
Adds an element to the Row at the position given. |
void deleteColumn(int column) {
if ((column >= columns) || (column < 0)) {
throw new IndexOutOfBoundsException("getCell at illegal index : " + column);
}
columns--;
boolean newReserved[] = new boolean[columns];
Object newCells[] = new Cell[columns];
for (int i = 0; i < column; i++) {
newReserved[i] = reserved[i];
newCells[i] = cells[i];
if (newCells[i] != null && (i + ((Cell) newCells[i]).getColspan() > column)) {
((Cell) newCells[i]).setColspan(((Cell) cells[i]).getColspan() - 1);
}
}
for (int i = column; i < columns; i++) {
newReserved[i] = reserved[i + 1];
newCells[i] = cells[i + 1];
}
if (cells[column] != null && ((Cell) cells[column]).getColspan() > 1) {
newCells[column] = cells[column];
((Cell) newCells[column]).setColspan(((Cell) newCells[column]).getColspan() - 1);
}
reserved = newReserved;
cells = newCells;
}
Returns a Row that is a copy of this Row
in which a certain column has been deleted. |
public Object getCell(int column) {
if ((column < 0) || (column > columns)) {
throw new IndexOutOfBoundsException("getCell at illegal index :" + column + " max is " + columns);
}
return cells[column];
}
Gets a Cell or Table from a certain column. |
public ArrayList getChunks() {
return new ArrayList();
}
Gets all the chunks in this element. |
public int getColumns() {
return columns;
}
Gets the number of columns. |
int getElementID(int column) {
if (cells[column] == null) return NULL;
else if (Cell.class.isInstance(cells[column])) return CELL;
else if (Table.class.isInstance(cells[column])) return TABLE;
return -1;
}
Returns the type-id of the element in a Row. |
public int getHorizontalAlignment() {
return horizontalAlignment;
}
Gets the horizontal alignment. |
int getObjectID(Object element) {
if (element == null) return NULL;
else if (Cell.class.isInstance(element)) return CELL;
else if (Table.class.isInstance(element)) return TABLE;
return -1;
}
Returns the type-id of an Object. |
public boolean isContent() {
return true;
}
|
public boolean isEmpty() {
for (int i = 0; i < columns; i++) {
if (cells[i] != null) {
return false;
}
}
return true;
}
Checks if the row is empty. |
public boolean isNestable() {
return false;
}
|
boolean isReserved(int column) {
return reserved[column];
}
Returns true/false when this position in the Row has been reserved, either filled or through a colspan of an Element. |
public boolean process(ElementListener listener) {
try {
return listener.add(this);
}
catch(DocumentException de) {
return false;
}
}
Processes the element by adding it (or the different parts) to a
ElementListener . |
boolean reserve(int column) {
return reserve(column, 1);
}
Reserves a Cell in the Row . |
boolean reserve(int column,
int size) {
if ((column < 0) || ((column + size) > columns)) throw new IndexOutOfBoundsException("reserve - incorrect column/size");
for(int i=column; i < column + size; i++)
{
if (reserved[i]) {
// undo reserve
for(int j=i; j >= column; j--) {
reserved[j] = false;
}
return false;
}
reserved[i] = true;
}
return true;
}
Reserves a Cell in the Row . |
void setElement(Object aElement,
int column) {
if (reserved[column]) throw new IllegalArgumentException("setElement - position already taken");
cells[column] = aElement;
if (aElement != null) {
reserved[column] = true;
}
}
Puts Cell to the Row at the position given, doesn't reserve colspan. |
public void setHorizontalAlignment(int value) {
horizontalAlignment = value;
}
Sets the horizontal alignment. |
public int type() {
return Element.ROW;
}
Gets the type of the text element. |