//table.setBorderColor(new Color(0, 0, 255));
table.setPadding(4);
table.setSpacing(0);
// first cell has to be void
table.addCell(new Cell("Options/\r\nWedges"),0,0);
int row = 1;
while (iActors.hasNext()){
Cell app = new Cell(iActors.next().getTitle());
//app.setNoWrap(true);
app.setHorizontalAlignment(Element.ALIGN_CENTER);
app.setVerticalAlignment(Element.ALIGN_CENTER);
table.addCell(app,row++,0);
}
row = 1;
int column = 1;
while (iOptions.hasNext()){
// working with a single option
OptionData o = iOptions.next();
String optionName = o.getTitle();
if ((optionName==null)||(optionName.length()==0)) optionName = "No (Option) name provided.";
//Paragraph optionNamePar = new Paragraph(optionName, fntRomanOptionTitle);
Paragraph optionNamePar = new Paragraph(optionName, fntRomanOptionTitle);
ListItem item = new ListItem(optionNamePar);
String optionDescription = o.getDescription();
if ((optionDescription!=null)&&(optionDescription.length()!=0)) {
//Paragraph optionDescriptionPar = new Paragraph("\r\n" + optionDescription, fntRomanOptionDescription);
Paragraph optionDescriptionPar = new Paragraph("\r\n" + optionDescription, fntRomanOptionDescription);
optionDescriptionPar.setSpacingAfter(12);
//optionDescriptionPar.setSpacingBefore(0);
item.add(optionDescriptionPar);
}
itemize.add(item);
// prepare the table
iActors = data.getColumns().iterator();
row = 0;
//System.out.println("option: " + o.getTitle());
Cell optionNameHeader = new Cell(o.getTitle());
//optionNameHeader.rotate();
optionNameHeader.setHeader(true);
//cell.setColspan(3);
table.addCell(optionNameHeader,row++,column);
table.endHeaders();
//table.addCell(new Cell(o.getTitle()),row++,column);
while ((iActors.hasNext())) {
ColumnData cd = iActors.next();
WedgeData wd = cd.getWedge(o);
Cell c;
if(wd == null) {
//c = new Cell("-");
c = new Cell();
} else {
double coeff = wd.getCoefficient();
c = new Cell(new Phrase(Double.toString(coeff),fntRomanTableAllFields));
}
c.setHorizontalAlignment(Element.ALIGN_CENTER);
c.setVerticalAlignment(Element.ALIGN_CENTER);
/*
System.out.println("table: " + table.columns());
System.out.println("x,y: " + row + " " + column);
System.out.println("cell: " + c);
*/
table.addCell(c,row++,column);
}
column++;
}
// areaSec.add(itemize);
doc.add(itemize);
// postprocess on table: to remove at next release...
Iterator iRow = table.iterator();
while (iRow.hasNext()) {
Row r = (Row)iRow.next();
Cell c = (Cell)r.getCell(1);
if (c.isEmpty()) iRow.remove();
}
// deny row split
table.setCellsFitPage(true);
doc.add(table);