1 | package de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.reportitems; |
2 | |
3 | import org.eclipse.core.runtime.IStatus; |
4 | |
5 | import de.uka.ipd.sdq.sensorframework.visualisation.rvisualisation.RVisualisationPlugin; |
6 | |
7 | public class TimeSeriesReportItem extends AbstractPlotReportItem { |
8 | |
9 | /** Default label for the x axis. */ |
10 | public static final String DEFAULT_X_AXIS_LABEL = ""; |
11 | |
12 | /** Label of the x axis. */ |
13 | private String xAxisLabel = DEFAULT_X_AXIS_LABEL; |
14 | |
15 | public TimeSeriesReportItem(String title, final String xAxisLabel) { |
16 | super(title); |
17 | this.xAxisLabel = xAxisLabel; |
18 | } |
19 | |
20 | public TimeSeriesReportItem(final String title, final int height, |
21 | final int width, final int fontSize, final String xAxisLabel) { |
22 | super(title, height, width, fontSize); |
23 | this.xAxisLabel = xAxisLabel; |
24 | } |
25 | |
26 | /** |
27 | * Plots the first data set against the second. Expects to find |
28 | * the measured values in the first set and the |
29 | * measurements number or event time in the second. |
30 | */ |
31 | @Override |
32 | protected String generatePlotCommand() { |
33 | String rCommand = ""; |
34 | |
35 | String[] dataSeries = getDataSeries(); |
36 | |
37 | if (dataSeries.length > 1){ |
38 | |
39 | String xDataId = dataSeries[1]; |
40 | String yDataId = dataSeries[0]; |
41 | |
42 | String xDataName = getDataCommand(xDataId); |
43 | String yDataName = getDataCommand(yDataId); |
44 | |
45 | rCommand = "plot("+xDataName +", "+yDataName+ ", main=\"" + getDescription() + "\", " |
46 | + "title=\"Histogram\", " |
47 | + "xlab=\"" + xAxisLabel + "\", " + "ylab=\"Value\")\n"; |
48 | |
49 | } else { |
50 | RVisualisationPlugin.log(IStatus.ERROR,"Internal Error: Less than two measurements in data for time series."); |
51 | } |
52 | |
53 | return rCommand; |
54 | } |
55 | |
56 | } |