com.jrefinery.report.targets.table
Class TableGridLayout.Element

java.lang.Object
  |
  +--com.jrefinery.report.targets.table.TableGridLayout.Element
Enclosing class:
TableGridLayout

public static class TableGridLayout.Element
extends java.lang.Object

The Element class encapsulates all TableCellData-object within a single grid cell. When the report is badly designed, cells may overlay. This will cause trouble when the table is printed later, so we do not accept multiple non-background TableCellData objects.

TableCellData backgrounds can be combined to create complex background structures. Usually, the cell backgrounds must be merged before the cellbackground can be applied to the generated table. As this is dependent on the table implementation, we do not assume anything here, and just collect all backgrounds in the list.

See Also:
TableCellData.isBackground()

Constructor Summary
TableGridLayout.Element()
          Creates a new element.
 
Method Summary
 void add(TableGridPosition pos)
          Adds a new TableGridPosition to the element.
 java.util.List getBackground()
          Returns the list of backgrounds of this element.
 TableGridPosition getRoot()
          Returns the data cell for this element.
 java.lang.String toString()
          Creates a string representation of this Element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableGridLayout.Element

public TableGridLayout.Element()
Creates a new element. The element has no initial background or cell data.

Method Detail

add

public void add(TableGridPosition pos)
Adds a new TableGridPosition to the element.

If the new position contains a data cell:
if no data cell has been set so far, the cell is added as new data element. if there is a data cell already set, the new cell data is ignored.

If the new position contains a background information:
if no data cell has been set so far, the cell is added to the list of available backgrounds. When a new data cell is added, the backgrounds are validated. A cell background is valid, if it fully contains the data cell area.
If there is a data cell already set, the background is validated imediatly and added if valid.

Invalid backgrounds or duplicate data cells are discarded.

Parameters:
pos - the new TableGridPosition to be added to this element.
Throws:
java.lang.NullPointerException - if the given position is null

getBackground

public java.util.List getBackground()
Returns the list of backgrounds of this element.

Returns:
the collected backgrounds of the element.

getRoot

public TableGridPosition getRoot()
Returns the data cell for this element. This can be null if no data cell has been defined.

Returns:
the data cell or null, if this element does not have any data defined.

toString

public java.lang.String toString()
Creates a string representation of this Element.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the element for debugging purposes.