return gridUnits;
}
- public GridUnit getGridUnit(int index) {
- if (index >= 0 && index < gridUnits.size()) {
- return (GridUnit)gridUnits.get(index);
+ /**
+ * Returns the grid unit at a given position.
+ * @param column index of the grid unit in the row (zero based)
+ * @return the requested grid unit.
+ */
+ public GridUnit getGridUnit(int column) {
+ return (GridUnit)gridUnits.get(column);
+ }
+
+ /**
+ * Returns the grid unit at a given position. In contrast to getGridUnit() this
+ * method returns null if there's no grid unit at the given position. The number of
+ * grid units for row x can be smaller than the number of grid units for row x-1.
+ * @param column index of the grid unit in the row (zero based)
+ * @return the requested grid unit or null if there's no grid unit at this position.
+ */
+ public GridUnit safelyGetGridUnit(int column) {
+ if (column < gridUnits.size()) {
+ return (GridUnit)gridUnits.get(column);
} else {
return null;
}
//Add areas for row
//addRowBackgroundArea(rowFO, lastRowHeight, layoutContext.getRefIPD(), yoffset);
for (int i = 0; i < gridUnits.length; i++) {
- GridUnit currentGU = lastRow.getGridUnit(i);
+ GridUnit currentGU = lastRow.safelyGetGridUnit(i);
if ((gridUnits[i] != null)
&& (forcedFlush || (end[i] == gridUnits[i].getElements().size() - 1))
&& (currentGU == null || currentGU.isLastGridUnitRowSpan())) {
+ //the last line in the "if" above is to avoid a premature end of an
+ //row-spanned cell because no GridUnitParts are generated after a cell is
+ //finished with its content. currentGU can be null if there's no grid unit
+ //at this place in the current row (empty cell and no borders to process)
if (log.isDebugEnabled()) {
log.debug((forcedFlush ? "FORCED " : "") + "flushing..." + i + " "
+ start[i] + "-" + end[i]);