]> gerrit.simantics Code Review - simantics/platform.git/blob
d724b088543dffc41a11d6892a452f30ab33d061
[simantics/platform.git] /
1 package org.simantics.document.linking.report.pdf;
2
3 import java.util.List;
4
5 import org.simantics.document.linking.report.DocumentLine;
6 import org.simantics.document.linking.report.DocumentTitlePage;
7 import org.simantics.document.linking.report.Table;
8 import org.simantics.document.linking.report.Document.TextSize;
9 import org.simantics.document.linking.report.TableColumn.Alignment;
10
11
12 public class PDFTitlePage extends DocumentTitlePage implements PDFElement {
13         
14         PDFDocument document;
15         PDFPage page;
16         public PDFTitlePage(PDFDocument writer) {
17                 this.document = writer;
18         }
19         
20         @Override
21         public PDFPage getPage() {
22                 return page;
23         }
24         
25         @Override
26         public void writeTitle(List<DocumentLine> titleLines) throws Exception {
27                 Alignment alignment = (Alignment)titleLines.get(0).getHints().get(Alignment.class);
28                 if (alignment == null)
29                         alignment = Alignment.CENTER;
30                 TextSize textSize = (TextSize)titleLines.get(0).getHints().get(TextSize.class);
31                 if (textSize == null)
32                         textSize = TextSize.HUGE;
33                 
34                 document.nextPage();
35                 this.page = document.contentStream.getCurrentPage();
36                 Table table = document.newElement(Table.class);
37                 table.addColumn("Names", 1.0).setAlignment(alignment);
38                 table.setLinesVisible(false);
39                 table.setHeaderVisible(false);
40                 table.setTextSize(textSize);
41                 int lines = (document.contentStream.getAvailableLines()-3)/2;
42                 for (int i = 0; i < lines; i++)
43                         table.writeRow("");
44                 for (DocumentLine line : titleLines) {
45                         TextSize s = (TextSize)line.getHints().get(TextSize.class);
46                         if (s != null)
47                                 textSize = s;
48                         table.setTextSize(textSize);
49                         table.writeRow(line.getLine());
50                 }
51                 table.setTextSize(TextSize.SMALL);
52                 table.setLinesVisible(true);
53                 table.setHeaderVisible(true);
54                 document.nextPage();
55                 
56         }
57         
58         
59
60 }