/** * Adds a <CODE>Cell</CODE> to the <CODE>Table</CODE>. * <P> * This is a shortcut for <CODE>addCell(Cell cell)</CODE>. * The <CODE>Phrase</CODE> will be converted to a <CODE>Cell</CODE>. * * @param content a <CODE>Phrase</CODE> * @throws BadElementException this should never happen */ public void addCell(Phrase content) throws BadElementException { addCell(content, curPosition); }
/** * Initialize the main info holder table. * @throws BadElementException for errors during table initialization */ protected void initTable() throws BadElementException { tablePDF = new Table(this.model.getNumberOfColumns()); tablePDF.setDefaultVerticalAlignment(Element.ALIGN_TOP); tablePDF.setCellsFitPage(true); tablePDF.setWidth(100); tablePDF.setPadding(2); tablePDF.setSpacing(0); smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL, new Color(0, 0, 0)); }
this.tableWidthPercent = table.getWidth(); this.proportionalWidths = table.getProportionalWidths(); this.cellPadding = (float) (table.getPadding() * TWIPS_FACTOR); this.cellSpacing = (float) (table.getSpacing() * TWIPS_FACTOR); this.borders = new RtfBorderGroup(this.document, RtfBorder.ROW_BORDER, table.getBorder(), table.getBorderWidth(), table.getBorderColor()); this.alignment = table.getAlignment(); Iterator rowIterator = table.iterator(); while(rowIterator.hasNext()) { this.rows.add(new RtfRow(this.document, this, (Row) rowIterator.next(), i)); ((RtfRow) this.rows.get(i)).cleanRow(); this.headerRows = table.getLastHeaderRow(); this.cellsFitToPage = table.isCellsFitPage(); this.tableFitToPage = table.isTableFitsPage(); if(!Float.isNaN(table.getOffset())) { this.offset = (int) (table.getOffset() * 2);
/** * Initialize the main info holder table, like the appropriate number of columns. * @param model The table being represented as iText. * @see org.displaytag.render.TableWriterTemplate#writeTableOpener(org.displaytag.model.TableModel) */ 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(); }
/** * Updates the table row additions in the underlying table object and deletes all table rows, * in order to preserve memory and detect future row additions. * <p><b>Pre-requisite</b>: the object must have been built with the parameter <code>supportUpdateRowAdditions</code> equals to true. */ void updateRowAdditions() { table.complete(); updateRowAdditionsInternal(); table.deleteAllRows(); }
table = new Table(values.size()); float[] widths = new float[table.getColumns()]; for (int i = 0; i < values.size(); i++) { value = (String) values.get(i); widths[i] = Float.parseFloat(value + "f"); table.setWidths(widths); } else { value = attributes.getProperty(ElementTags.COLUMNS); try { table = new Table(Integer.parseInt(value)); } catch (Exception e) { table = new Table(1); table.setBorder(Table.BOX); table.setBorderWidth(1); table.getDefaultCell().setBorder(Table.BOX); table.setLastHeaderRow(Integer.parseInt(value)); table.setAlignment(value); table.setSpacing(Float.parseFloat(value + "f")); table.setPadding(Float.parseFloat(value + "f")); table.setOffset(Float.parseFloat(value + "f")); table.setWidth(Float.parseFloat(value.substring(0, value
table.complete(); os.write(EQUALS); os.write(QUOTE); write(String.valueOf(table.getWidth())); if (!table.isLocked()){ write("%"); String alignment = HtmlEncoder.getAlignment(table.getAlignment()); if (!"".equals(alignment)) { write(HtmlTags.ALIGN, alignment); write(HtmlTags.CELLPADDING, String.valueOf(table.getPadding())); write(HtmlTags.CELLSPACING, String.valueOf(table.getSpacing())); if (table.getBorderWidth() != Rectangle.UNDEFINED) { write(HtmlTags.BORDERWIDTH, String.valueOf(table.getBorderWidth())); if (table.getBorderColor() != null) { write(HtmlTags.BORDERCOLOR, HtmlEncoder.encode(table.getBorderColor())); if (table.getBackgroundColor() != null) { write(HtmlTags.BACKGROUNDCOLOR, HtmlEncoder.encode(table.getBackgroundColor())); for (Iterator iterator = table.iterator(); iterator.hasNext(); ) { row = (Row) iterator.next(); write(row, indent + 1);
/** * This method creates a report group for the error message on the report * * @throws DocumentException */ private void generateErrorColumnHeaders() throws DocumentException { try { int headerwidths[] = { 60 }; Table aTable = new Table(1, 1); // 2 columns, 1 rows. aTable.setAutoFillEmptyCells(true); aTable.setPadding(3); aTable.setWidths(headerwidths); aTable.setWidth(100); Cell cell; Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL); cell = new Cell(new Phrase("Error(s)", font)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setGrayFill(0.9f); aTable.addCell(cell); this.document.add(aTable); } catch (Exception e) { throw new RuntimeException("DepreciationReport.generateErrorColumnHeaders() - Error: " + e.getMessage()); } }
Table table = new Table(columns); table.setAlignment(alignment); table.setSpacing(cellspacing); table.setPadding(cellpadding); table.cloneNonPositionParameters(this); int pos; for (Iterator rows = content.iterator(); rows.hasNext(); ) { for (Iterator cells = row.getContent().iterator(); cells.hasNext(); ) { cell = (SimpleCell)cells.next(); table.addCell(cell.createCell(row)); if (cell.getColspan() == 1) { if (cell.getWidth() > 0) widths[pos] = cell.getWidth(); table.setWidth(sumWidths); table.setLocked(true); table.setWidths(widths); table.setWidths(widthpercentages); table.setWidth(width); table.setLocked(true); table.setWidth(widthpercentage);
Cell tmp = new Cell(element); tmp.setBorder(NO_BORDER); tmp.setColspan(table.getColumns()); table.addCell(tmp); return; return; case Element.TABLE: Table table = new Table(3); float[] widths = new float[3]; widths[1] = ((Table)element).getWidth(); switch(((Table)element).getAlignment()) { case Element.ALIGN_LEFT: widths[0] = 0f; table.setWidths(widths); Cell tmp; if (arrayList.isEmpty()) { table.addCell(getDummyCell()); table.addCell(tmp); table.addCell(tmp); table.insertTable((Table)element); tmp = new Cell(); tmp.setBorder(NO_BORDER); table.addCell(tmp); table.addCell(getDummyCell()); clear();
Table table = new Table(2); table.setTableFitsPage(true); table.setCellsFitPage(true); table.setBorderWidth(1); table.setBorderColor(new java.awt.Color(0, 0, 0)); table.setPadding(4); table.setSpacing(4); Cell cell = new Cell("Discrepancy note id: "+discBean.getId()); cell.setHeader(true); cell.setColspan(2); table.addCell(cell); table.endHeaders(); table.addCell(cell); cell = new Cell("CRF name: "+discBean.getCrfName()); table.addCell(cell); cell = new Cell("Description: "+discBean.getDescription()); table.addCell(cell); if(discBean.getDisType() != null) { cell = new Cell("Discrepancy note type: "+discBean.getDisType().getName()); table.addCell(cell); table.addCell(cell); cell = new Cell("Parent note ID: "+(discBean.getParentDnId()>0? discBean.getParentDnId():"")); table.addCell(cell); cell = new Cell("Resolution status: "+ new DiscrepancyNoteUtil().getResolutionStatusName(discBean.getResolutionStatusId())); table.addCell(cell); cell = new Cell("Detailed notes: "+discBean.getDetailedNotes());
if (table.getColumns() < columns) { table.addColumns(columns - table.getColumns()); table.addCell(cell); float widths[] = table.getProportionalWidths(); if (widths.length == columns) { float left = 0.0f; table.setWidths(cellWidths);
p = new Table(1); p.setPadding(TABLE_PADDING); p.setBorderWidth(TABLE_BORDERWIDTH); p.setWidth(TABLE_WIDTH); p.disableBorderSide(Rectangle.LEFT); p.disableBorderSide(Rectangle.RIGHT); p.endHeaders(); Cell c = new Cell(); c.disableBorderSide(Rectangle.LEFT); p.addCell(c); } catch (BadElementException bee) { bee.printStackTrace();
throw new BadElementException("No error, just an old style table"); setAutoFillEmptyCells(true); complete(); PdfPTable pdfptable = new PdfPTable(widths); pdfptable.setComplete(complete); if (isNotAddedYet()) pdfptable.setSkipFirstHeader(true); SimpleTable t_evt = new SimpleTable(); for (Iterator iterator = iterator(); iterator.hasNext(); ) { row = (Row) iterator.next(); Element cell; if ((cell = (Element)row.getCell(i)) != null) { if (cell instanceof Table) { pcell = new PdfPCell(((Table)cell).createPdfPTable());
t = new Table(colnum); t.setPadding(TABLE_PADDING); t.setBorderWidth(TABLE_BORDERWIDTH); t.setWidth(TABLE_WIDTH); t.setCellsFitPage(true); t.setOffset(10f);
Table t = new Table(startIndex == 0 ? subCols : subCols + 2, rows); t.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); t.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); t.setPadding(4); t.setBorderWidth(1); c2 = new Cell(new Chunk(studentInfo.get(rowDataIndex).get(1), getBoldFont())); t.addCell(c1); t.addCell(c2); }else{ t.addCell(c);
int groupNumber = 0; boolean groupChange; int firstDataRow = table.getLastHeaderRow() + 1; Cell cell; PdfCell currentCell; ArrayList newCells = new ArrayList(); int rows = table.size() + 1; float[] offsets = new float[rows]; for (int i = 0; i < rows; i++) { for (Iterator rowIterator = table.iterator(); rowIterator.hasNext(); ) { groupChange = false; row = (Row) rowIterator.next(); currentCell.setHeader(); headercells.add(currentCell); if (!table.isNotAddedYet()) continue;
float widths[] = table.getProportionalWidths(); for (int i = 0; i < widths.length; i++) { if (widths[i] == 0) { table.setWidths(widths); } catch (BadElementException bee) {
/** * Constructs a <CODE>PdfTable</CODE>-object. * * @param table a <CODE>Table</CODE> * @param left the left border on the page * @param right the right border on the page * @param top the start position of the top of the table * @since a parameter of this method has been removed in iText 2.0.8 */ PdfTable(Table table, float left, float right, float top) { // constructs a Rectangle (the bottom value will be changed afterwards) super(left, top, right, top); this.table = table; table.complete(); // copying the attributes from class Table cloneNonPositionParameters(table); this.columns = table.getColumns(); positions = table.getWidths(left, right - left); // initialization of some parameters setLeft(positions[0]); setRight(positions[positions.length - 1]); headercells = new ArrayList(); cells = new ArrayList(); updateRowAdditionsInternal(); }
/** * Write the table's header columns to an iText document. * @see org.displaytag.render.TableWriterTemplate#writeTableHeader(org.displaytag.model.TableModel) * @throws BadElementException if an error occurs while writing header. */ 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(); }