| 1 | package de.uka.ipd.sdq.sensorframework.visualisation.jfreechartvisualisation.editor; |
| 2 | |
| 3 | |
| 4 | import java.util.ArrayList; |
| 5 | import java.util.Collection; |
| 6 | import java.util.List; |
| 7 | |
| 8 | import org.eclipse.swt.widgets.Composite; |
| 9 | |
| 10 | import de.uka.ipd.sdq.codegen.simudatavisualisation.datatypes.AbstractPie; |
| 11 | import de.uka.ipd.sdq.codegen.simudatavisualisation.datatypes.TimeDeltaPie; |
| 12 | import de.uka.ipd.sdq.sensorframework.adapter.DataAdapter; |
| 13 | import de.uka.ipd.sdq.sensorframework.visualisation.IVisualisation; |
| 14 | import de.uka.ipd.sdq.sensorframework.visualisation.editor.AbstractReportView; |
| 15 | import de.uka.ipd.sdq.sensorframework.visualisation.jfreechartvisualisation.JFreeChartPieViewer; |
| 16 | |
| 17 | public class JFreeChartPieReport extends AbstractReportView implements |
| 18 | IVisualisation<AbstractPie> { |
| 19 | |
| 20 | public static String JFREECHART_PIE_EDITOR_ID = "de.uka.ipd.sdq.simucomframework.visualisation.JFreeChartPieReport"; |
| 21 | |
| 22 | private JFreeChartPieViewer viewer; |
| 23 | |
| 24 | /* (non-Javadoc) |
| 25 | * @see org.eclipse.ui.part.WorkbenchPart#setFocus() |
| 26 | */ |
| 27 | @Override |
| 28 | public void setFocus() { |
| 29 | viewer.setFocus(); |
| 30 | } |
| 31 | |
| 32 | /* (non-Javadoc) |
| 33 | * @see de.uka.ipd.sdq.sensorframework.visualisation.editor.AbstractReportView#createReportControls(org.eclipse.swt.widgets.Composite) |
| 34 | */ |
| 35 | @Override |
| 36 | protected void createReportControls(Composite parent) { |
| 37 | viewer = new JFreeChartPieViewer(parent,0); |
| 38 | } |
| 39 | |
| 40 | /* (non-Javadoc) |
| 41 | * @see de.uka.ipd.sdq.sensorframework.visualisation.IVisualisation#setInput(java.util.Collection) |
| 42 | */ |
| 43 | public void setInput(Collection<AbstractPie> c) { |
| 44 | if (!c.isEmpty()) { |
| 45 | viewer.setData(c); |
| 46 | } else |
| 47 | viewer.setData(new TimeDeltaPie("Empty Datasource")); |
| 48 | } |
| 49 | |
| 50 | /* (non-Javadoc) |
| 51 | * @see de.uka.ipd.sdq.sensorframework.visualisation.editor.AbstractReportView#setInput(java.util.List) |
| 52 | */ |
| 53 | @Override |
| 54 | protected void generateVisualization(List<DataAdapter> list) { |
| 55 | ArrayList<AbstractPie> viewerInput = new ArrayList<AbstractPie>(); |
| 56 | for (DataAdapter a : list) |
| 57 | viewerInput.add((AbstractPie) a.getAdaptedObject()); |
| 58 | this.setInput(viewerInput); |
| 59 | } |
| 60 | |
| 61 | /* (non-Javadoc) |
| 62 | * @see de.uka.ipd.sdq.sensorframework.visualisation.IVisualisation#addInput(java.util.Collection) |
| 63 | */ |
| 64 | public void addInput(Collection<AbstractPie> c) { |
| 65 | // The implementation is not necessary. |
| 66 | |
| 67 | } |
| 68 | |
| 69 | /* (non-Javadoc) |
| 70 | * @see de.uka.ipd.sdq.sensorframework.visualisation.IVisualisation#deleteInput(java.util.Collection) |
| 71 | */ |
| 72 | public void deleteInput(Collection<AbstractPie> c) { |
| 73 | // The implementation is not necessary. |
| 74 | } |
| 75 | } |