A table writer that formats table as and writes it to an iText document.
| Method from org.displaytag.render.ItextTableWriter Detail: |
protected Font getCaptionFont() {
return FontFactory.getFont(FontFactory.HELVETICA, 17, Font.BOLD, new Color(0x00, 0x00, 0x00));
}
Obtain the caption font; Meant to be overriden if a different style is desired. |
protected int getCaptionHorizontalAlignment() {
return Element.ALIGN_CENTER;
}
Obtain the caption horizontal alignment; Meant to be overriden if a different style is desired. |
protected Color getFooterBackgroundColor() {
return new Color(0xce, 0xcf, 0xce);
}
Obtain the footer background color; Meant to be overriden if a different style is desired. |
protected Font getFooterFont() {
return FontFactory.getFont(FontFactory.HELVETICA, 10);
}
Obtain the footer font; Meant to be overriden if a different style is desired. |
protected Color getFooterFontColor() {
return new Color(0x00, 0x00, 0x00);
}
Obtain the footer font color; Meant to be overriden if a different style is desired. |
protected int getFooterHorizontalAlignment() {
return Element.ALIGN_LEFT;
}
Obtain the footer horizontal alignment; Meant to be overriden if a different style is desired. |
protected Color getHeaderBackgroundColor() {
return new Color(0xee, 0xee, 0xee);
}
Obtain the background color used to render the header; Meant to be overridden if a different header background
color is desired. |
protected Font getHeaderFont() {
return this.defaultFont;
}
Obtain the font used to render the header text; Meant to be overridden if a different header font is desired. |
protected Color getHeaderFontColor() {
return new Color(0x00, 0x00, 0x00);
}
Set the font color used to render the header text; Meant to be overridden if a different header style is desired. |
protected int getHeaderHorizontalAlignment() {
return Element.ALIGN_CENTER;
}
Obtain the horizontal alignment used to render header text; Meant to be overridden if a different alignment is
desired. |
protected Font getTableFont() {
return FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL, new Color(0x00, 0x00, 0x00));
}
Obtain the font used to render text in the table; Meant to be overriden if a different font is desired. |
protected void setFooterFontStyle(Chunk cellContent) {
this.setBoldStyle(cellContent, this.getFooterFontColor());
}
Set the font style used to render the header text; Meant to be overridden if a different header style is desired. |
protected void setHeaderFontStyle(Chunk cellContent) {
setBoldStyle(cellContent, this.getHeaderFontColor());
}
Set the font style used to render the header text; Meant to be overridden if a different header style is desired. |
protected void writeCaption(TableModel model) throws Exception {
this.decorateCaption(model);
}
Write the table's caption to a iText document. |
protected void writeColumnOpener(Column column) throws DecoratorException, ObjectLookupException {
column.initialize(); // has side effect, setting its stringValue, which affects grouping logic.
}
Write a column's opening structure to an iText document. |
protected void writeColumnValue(Object value,
Column column) throws BadElementException {
this.table.addCell(getCell(value));
}
Write a column's value to a iText document. |
protected void writeDecoratedRowFinish(TableModel model) throws Exception {
model.getTableDecorator().finishRow();
}
|
protected void writeDecoratedRowStart(TableModel model) {
TableDecorator decorator = model.getTableDecorator();
if (decorator instanceof ItextDecorator)
{
ItextDecorator idecorator = (ItextDecorator) decorator;
idecorator.setTable(this.table);
idecorator.setFont(this.defaultFont);
}
decorator.startRow();
}
Decorators that help render the table to an iText document must implement ItextDecorator. |
protected void writeDecoratedTableFinish(TableModel model) {
model.getTableDecorator().finish();
}
|
protected void writePostBodyFooter(TableModel model) throws DocumentException {
Chunk cellContent = new Chunk(model.getFooter(), this.getFooterFont());
this.setFooterFontStyle(cellContent);
Cell cell = new Cell(cellContent);
cell.setLeading(8);
cell.setBackgroundColor(this.getFooterBackgroundColor());
cell.setHorizontalAlignment(this.getFooterHorizontalAlignment());
cell.setColspan(model.getNumberOfColumns());
table.addCell(cell);
}
|
protected void writeTableHeader(TableModel model) throws BadElementException {
Iterator iterator = model.getHeaderCellList().iterator();
float[] widths = new float[model.getNumberOfColumns()];
for (int i = 0; iterator.hasNext(); i++)
{
HeaderCell headerCell = (HeaderCell) iterator.next();
widths[i] = this.getCellWidth(headerCell);
String columnHeader = headerCell.getTitle();
if (columnHeader == null)
{
columnHeader = StringUtils.capitalize(headerCell.getBeanPropertyName());
}
Cell hdrCell = this.getHeaderCell(columnHeader);
this.table.addCell(hdrCell);
}
this.table.setWidths(widths);
this.table.endHeaders();
}
Write the table's header columns to an iText document. |
protected void writeTableOpener(TableModel model) {
this.table.setDefaultVerticalAlignment(Element.ALIGN_TOP);
this.table.setCellsFitPage(true);
this.table.setWidth(100);
this.table.setPadding(2);
this.table.setSpacing(0);
this.table.setBorder(Rectangle.NO_BORDER);
this.defaultFont = this.getTableFont();
}
Initialize the main info holder table, like the appropriate number of columns. |