public Table createTable() throws BadElementException {
		if (content.isEmpty()) throw new BadElementException("Trying to create a table without rows.");
		SimpleCell row = (SimpleCell)content.get(0);
		SimpleCell cell;
		int columns = 0;
		for (Iterator i = row.getContent().iterator(); i.hasNext(); ) {
			cell = (SimpleCell)i.next();
			columns += cell.getColspan();
		}
		float[] widths = new float[columns];
		float[] widthpercentages = new float[columns];
		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(); ) {
			row = (SimpleCell)rows.next();
			pos = 0;
			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();
					if (cell.getWidthpercentage() > 0) widthpercentages[pos] = cell.getWidthpercentage();
				}
				pos += cell.getColspan();
			}
		}
		float sumWidths = 0f;
		for(int i = 0; i < columns; i++) {
			if (widths[i] == 0) {
				sumWidths = 0;
				break;
			}
			sumWidths += widths[i];
		}
		if (sumWidths > 0) {
			table.setWidth(sumWidths);
			table.setLocked(true);
			table.setWidths(widths);
		}
		else {
			for(int i = 0; i < columns; i++) {
				if (widthpercentages[i] == 0) {
					sumWidths = 0;
					break;
				}
				sumWidths += widthpercentages[i];
			}
			if (sumWidths > 0) {
				table.setWidths(widthpercentages);
			}
		}
		if (width > 0) {
			table.setWidth(width);
			table.setLocked(true);
		}
		else if (widthpercentage > 0) {
			table.setWidth(widthpercentage);
		}
		return table;
	}
public Table createTable ( ) throws BadElementException { if ( content . isEmpty ( ) ) throw new BadElementException ( "Trying to create a table without rows." ) ; SimpleCell row = ( SimpleCell ) content . get ( 0 ) ; SimpleCell cell ; int columns = 0 ; for ( Iterator i = row . getContent ( ) . iterator ( ) ; i . hasNext ( ) ; ) { cell = ( SimpleCell ) i . next ( ) ; columns += cell . getColspan ( ) ; } float [ ] widths = new float [ columns ] ; float [ ] widthpercentages = new float [ columns ] ; 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 ( ) ; ) { row = ( SimpleCell ) rows . next ( ) ; pos = 0 ; 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 ( ) ; if ( cell . getWidthpercentage ( ) > 0 ) widthpercentages [ pos ] = cell . getWidthpercentage ( ) ; } pos += cell . getColspan ( ) ; } } float sumWidths = 0f ; for ( int i = 0 ; i < columns ; i ++ ) { if ( widths [ i ] == 0 ) { sumWidths = 0 ; break ; } sumWidths += widths [ i ] ; } if ( sumWidths > 0 ) { table . setWidth ( sumWidths ) ; table . setLocked ( true ) ; table . setWidths ( widths ) ; } else { for ( int i = 0 ; i < columns ; i ++ ) { if ( widthpercentages [ i ] == 0 ) { sumWidths = 0 ; break ; } sumWidths += widthpercentages [ i ] ; } if ( sumWidths > 0 ) { table . setWidths ( widthpercentages ) ; } } if ( width > 0 ) { table . setWidth ( width ) ; table . setLocked ( true ) ; } else if ( widthpercentage > 0 ) { table . setWidth ( widthpercentage ) ; } return table ; }
Creates a Table object based on this TableAttributes object.
@return a com.lowagie.text.Table object
@throws BadElementException