1 | package de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.views; |
2 | |
3 | import de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.reportitems.AbstractPlotReportItem; |
4 | import de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.reportitems.IReportRenderingVisitor; |
5 | import de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.reportitems.RCommandRReportItem; |
6 | import de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.reportitems.StaticTextReportItem; |
7 | |
8 | /**Visitor that generates HTML code for the report items of a report. |
9 | * @author groenda |
10 | */ |
11 | public class HTMLVisitor implements IReportRenderingVisitor { |
12 | |
13 | /** The content of the HTML body. */ |
14 | private String content = ""; |
15 | |
16 | /**Returns the generated HTML code for a report. |
17 | * @return a valid HTML page. |
18 | */ |
19 | public String getHTML() { |
20 | return "<html><body>" + content + "</body></html>"; |
21 | } |
22 | |
23 | /** {@inheritDoc} |
24 | */ |
25 | public void visitStaticTextReportItem( |
26 | final StaticTextReportItem staticReportItem) { |
27 | if (staticReportItem.isHeading()) { |
28 | content += "<h2>"; |
29 | } |
30 | content += staticReportItem.getText(); |
31 | if (staticReportItem.isHeading()) { |
32 | content += "</h2>"; |
33 | } |
34 | } |
35 | |
36 | /** {@inheritDoc} |
37 | */ |
38 | public void visitGeneratedTextReportItem( |
39 | final RCommandRReportItem rCommandReportItem) { |
40 | content += "<b>" + rCommandReportItem.getDescription() + ":</b> "; |
41 | content += rCommandReportItem.getText() + "<br/>"; |
42 | } |
43 | |
44 | /** {@inheritDoc} |
45 | */ |
46 | public void visitGraphicReportItem( |
47 | final AbstractPlotReportItem plotReportItem) { |
48 | // include generated graphics |
49 | if (plotReportItem.getTemporaryRasterGraphicFilename() != null) { |
50 | content += "<a href=\"file:///" |
51 | + plotReportItem.getTemporaryVectorGraphicFilename() + "\">" |
52 | + "<img src=\"file:///" |
53 | + plotReportItem.getTemporaryRasterGraphicFilename() + "\"/>" |
54 | + "</a><br/>"; |
55 | } |
56 | } |
57 | |
58 | } |