| 1 | package de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.reportitems; |
| 2 | |
| 3 | |
| 4 | /**Report item that displays probability distribution functions. |
| 5 | * @author groenda |
| 6 | */ |
| 7 | public class PdfReportItem extends AbstractPlotReportItem { |
| 8 | /** Default label for the x axis. */ |
| 9 | public static final String DEFAULT_X_AXIS_LABEL = ""; |
| 10 | |
| 11 | /** Label of the x axis. */ |
| 12 | private String xAxisLabel = DEFAULT_X_AXIS_LABEL; |
| 13 | |
| 14 | /**Constructs a new report item containing a plotted pdf graphic. |
| 15 | * The graphic is stored in a temporary file. This is accessible via the |
| 16 | * getFilename method. |
| 17 | * @param title Title of the plotted graphic. |
| 18 | * @param xAxisLabel Label for the x axis. |
| 19 | */ |
| 20 | public PdfReportItem(final String title, final String xAxisLabel) { |
| 21 | super(title); |
| 22 | this.xAxisLabel = xAxisLabel; |
| 23 | } |
| 24 | |
| 25 | /**Constructs a new report item containing a plotted pdf graphic. |
| 26 | * The graphic is stored in a temporary file. This is accessible via the |
| 27 | * getFilename method. |
| 28 | * @param title Title of the plotted graphic. |
| 29 | * @param height height of the plotted graphic. |
| 30 | * @param width width of the plotted graphics. |
| 31 | * @param fontSize the default pointsize of plotted text, interpreted at |
| 32 | * 72 dpi, so one point is approximately one pixel. |
| 33 | * @param xAxisLabel Label for the x axis. |
| 34 | */ |
| 35 | public PdfReportItem(final String title, final int height, |
| 36 | final int width, final int fontSize, final String xAxisLabel) { |
| 37 | super(title, height, width, fontSize); |
| 38 | this.xAxisLabel = DEFAULT_X_AXIS_LABEL; |
| 39 | } |
| 40 | |
| 41 | /** {@inheritDoc} |
| 42 | */ |
| 43 | @Override |
| 44 | protected String generatePlotCommand() { |
| 45 | int pos = 0; |
| 46 | String rCommand = ""; |
| 47 | |
| 48 | for (String id : getDataSeries()) { |
| 49 | String data = getDataCommand(id); |
| 50 | if (pos == 0) { |
| 51 | rCommand += "plot(density(" + data + "), " |
| 52 | + "do.points=FALSE, " + "verticals=TRUE, " |
| 53 | + "main=\"" + getDescription() + "\", " |
| 54 | + "xlab=\"" + xAxisLabel + "\")\n"; //, " + "ylab=\"f(t)\")\n"; |
| 55 | } else { |
| 56 | rCommand += "lines(density(" + data + "),type=\"s\", lty=" |
| 57 | + (pos + 1) + ")\n"; |
| 58 | } |
| 59 | pos++; |
| 60 | } |
| 61 | rCommand += generateLinesLegend(); |
| 62 | return rCommand; |
| 63 | } |
| 64 | |
| 65 | } |