document.add(new Chunk("\n"));
PdfPTable mapInfo = new PdfPTable(1);
{
mapInfo.getDefaultCell().setBorderWidth(0);
Paragraph header = new Paragraph("Información resultado\n\n", new Font(Font.HELVETICA, 14, Font.BOLDITALIC));
PdfPCell cell = new PdfPCell(header);
cell.setColspan(1);
cell.setBorderWidth(0);
mapInfo.addCell(cell);
PdfPTable subTable = new PdfPTable(1);
subTable.getDefaultCell().setBorderWidth(0);
Paragraph p = new Paragraph();
Font f = new Font(Font.COURIER, 12);
Iterator iterator = params.keySet().iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
String name = key + ":";
while (name.length() < 23) {
name += " ";
}
p.add(new Chunk(" " + name + params.get(key) + "\n", f));
}
subTable.addCell(p);
mapInfo.addCell(subTable);
mapInfo.setWidthPercentage(100);
document.add(mapInfo);
}
//add system information
PdfPTable systemInfo = new PdfPTable(1);
{
systemInfo.getDefaultCell().setBorderWidth(0);
Paragraph header = new Paragraph("\n\nInformación Sistema\n\n", new Font(Font.HELVETICA, 14, Font.BOLDITALIC));
PdfPCell cell = new PdfPCell(header);
cell.setColspan(1);
cell.setBorderWidth(0);
systemInfo.addCell(cell);
PdfPTable subTable = new PdfPTable(1);
subTable.getDefaultCell().setBorderWidth(0);
Paragraph p = new Paragraph();
Font f = new Font(Font.COURIER, 12);
Iterator iterator = systemProperties.keySet().iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
String name = key + ":";
while (name.length() < 23) {
name += " ";
}
p.add(new Chunk(" " + name + systemProperties.get(key) + "\n", f));
}
subTable.addCell(p);
systemInfo.addCell(subTable);
systemInfo.setWidthPercentage(100);
document.add(systemInfo);
}
document.setMargins(40, 40, 30, 30);
document.setPageSize(PageSize.A4.rotate());
document.newPage();
if (image != null) {
Image img = Image.getInstance(image, null);
img.setAlignment(Element.ALIGN_CENTER);
document.add(img);
}
document.setMargins(40,40,170,60);
document.setPageSize(PageSize.A4);
document.newPage();
//list table with the path through the cities and distances between them
document.add(new Paragraph("Rutas del Problema\n\n",new Font(Font.HELVETICA, 14, Font.BOLDITALIC)));
//create font for header and cities.
//TODO: how to create unicode font without having to transfer .ttf file ?
Font tableHeaderFont=new Font(BaseFont.createFont(
BaseFont.HELVETICA,
BaseFont.CP1250,
BaseFont.EMBEDDED),
12, Font.BOLD);
//create tabe and set properties
PdfPTable datatable = new PdfPTable(6);
int headerwidths[] = { 5, 31, 16, 16, 16, 16}; // percentage
datatable.setWidths(headerwidths);
datatable.setWidthPercentage(100); // percentage
datatable.getDefaultCell().setPadding(2);
datatable.getDefaultCell().setBorderWidth(1);
datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
//header row
PdfPCell c1=new PdfPCell(new Phrase("Barrio",tableHeaderFont));
c1.setColspan(2);
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
c1.setVerticalAlignment(Element.ALIGN_CENTER);
datatable.addCell(c1);
datatable.addCell(new Phrase("X\n",tableHeaderFont));
datatable.addCell(new Phrase("Y\n",tableHeaderFont));
datatable.addCell(new Phrase("Distancia\n[m]",tableHeaderFont));
datatable.addCell(new Phrase("Total\n[m]",tableHeaderFont));
datatable.setHeaderRows(1); // this is the end of the table header
//create fixed with font for numbers
Font numberFont=new Font(Font.COURIER, 11);
//compute the distance between two cities and total distance
double totalDistance=0;
for (int i = 0; i < localidades.length; i++) {