EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.sensorframework.visualisation.jfreechartvisualisation]

COVERAGE SUMMARY FOR SOURCE FILE [ExportCSV.java]

nameclass, %method, %block, %line, %
ExportCSV.java0%   (0/1)0%   (0/4)0%   (0/100)0%   (0/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ExportCSV0%   (0/1)0%   (0/4)0%   (0/100)0%   (0/21)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/2)
ExportCSV (ISeriesExporter): void 0%   (0/1)0%   (0/9)0%   (0/4)
exportCSV (String, XYSeries): void 0%   (0/1)0%   (0/55)0%   (0/10)
run (): void 0%   (0/1)0%   (0/32)0%   (0/5)

1package de.uka.ipd.sdq.sensorframework.visualisation.jfreechartvisualisation;
2 
3import java.io.BufferedWriter;
4import java.io.File;
5import java.io.FileWriter;
6 
7import org.apache.log4j.Logger;
8import org.eclipse.jface.action.Action;
9import org.eclipse.swt.SWT;
10import org.eclipse.swt.widgets.FileDialog;
11import org.eclipse.ui.PlatformUI;
12import org.jfree.data.xy.XYDataItem;
13import org.jfree.data.xy.XYSeries;
14 
15public class ExportCSV extends Action {
16        /** Logger for this class. */
17        private static final Logger logger = Logger.getLogger(ExportCSV.class);
18 
19        private ISeriesExporter viewer;
20 
21        public ExportCSV(ISeriesExporter freeChartHistogramViewer) {
22                super();
23                setText("Export CSV...");
24                this.viewer = freeChartHistogramViewer;
25        }
26 
27        @Override
28        public void run() {
29                FileDialog dialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.SAVE);
30                dialog.open();
31                if (dialog.getFileName() != null){
32                        exportCSV(dialog.getFilterPath() + File.separatorChar + dialog.getFileName(), viewer.getSeries());
33                }
34        }
35 
36        private void exportCSV(String filename, XYSeries series) {
37                FileWriter fileWriter;
38                BufferedWriter bufferedWriter;
39                try{
40                        fileWriter = new FileWriter(filename);
41                        bufferedWriter = new BufferedWriter(fileWriter);
42                        for(Object item : series.getItems()){
43                                XYDataItem data = (XYDataItem) item;
44                                bufferedWriter.append((data.getX()+";"+data.getY()+"\n").replace(".", ","));
45                        }
46                        bufferedWriter.close();
47                        fileWriter.close();
48                } catch(Exception e) {
49                        logger.error("Error writing CSV file.", e);
50                }
51        }
52}

[all classes][de.uka.ipd.sdq.sensorframework.visualisation.jfreechartvisualisation]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov