footer.setAlignment(Element.ALIGN_RIGHT);
doc.setHeader(header);
doc.setFooter(footer);
// retriving data
Data data = view.getDocumentData();
// printing the title
boolean toNewPage = false;
String title = data.getTitle();
if ((title!=null)&&(title.length()!=0)) {
Paragraph titlePar = new Paragraph(title, fntRomanTitle);
// hard-code the leading, the same size of fntRomanTitle
titlePar.setLeading(32);
doc.add(titlePar);
toNewPage = true;
//System.out.println("title|"+title+"|");
}
// some vspace...
doc.add(new Paragraph(" "));
// retrive and print the stan-document description
String description = data.getDescription();
if ((description!=null)&&(description.length()!=0)) {
doc.add(new Paragraph(description, fntRomanDescription));
toNewPage = true;
//System.out.println("descritpion|"+description+"|");
}
// dealing with areas... at a new page
if (toNewPage) doc.newPage();
// some vspace...
// doc.add(new Paragraph(" "));
// doc.add(new Paragraph("AREAS", fntRomanDescription));
Collection<AreaData> areas = data.getAreas();
Iterator<AreaData> i = areas.iterator();
int j = 1;
while (i.hasNext()){
// working with a single area
AreaData area = i.next();
String nameArea = area.getTitle();
String areaPrefix = "Area: ";
Paragraph areaPar = new Paragraph(areaPrefix + nameArea,fntRomanArea);
areaPar.setSpacingAfter(12);
doc.add(areaPar);
String areaDescription = area.getDescription();
if ((areaDescription!=null)&&(areaDescription.length()!=0)) {
Paragraph areaDescriptionPar = new Paragraph(areaDescription,fntRomanAreaDescription);
areaDescriptionPar.setSpacingAfter(12);
doc.add(areaDescriptionPar);
}
// dealing with area's'option
Collection<OptionData> options = area.getOptions();
Iterator<OptionData> iOptions = options.iterator();
// create an itemize
List itemize = new List(false,20);
Paragraph optionsPar = new Paragraph("OPTIONS",fntRomanOption);
optionsPar.setSpacingAfter(12);
doc.add(optionsPar);
// create the table for actor/option wedges
// rows
int actorsNumber = data.getColumns().size();
// columns
int optionsNumber = options.size();
Iterator<ColumnData> iActors = data.getColumns().iterator();
Table table = new Table(optionsNumber+1, actorsNumber+1);
table.setWidth(100);
table.setBorderWidth(1);
//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);