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 [LoadCSVHistogram.java]

nameclass, %method, %block, %line, %
LoadCSVHistogram.java0%   (0/1)0%   (0/4)0%   (0/145)0%   (0/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class LoadCSVHistogram0%   (0/1)0%   (0/4)0%   (0/145)0%   (0/25)
LoadCSVHistogram (IHistogramAccepter): void 0%   (0/1)0%   (0/12)0%   (0/5)
getHistogram (): Histogram 0%   (0/1)0%   (0/3)0%   (0/1)
importHistogram (String): Histogram 0%   (0/1)0%   (0/95)0%   (0/13)
run (): void 0%   (0/1)0%   (0/35)0%   (0/6)

1package de.uka.ipd.sdq.sensorframework.visualisation.jfreechartvisualisation;
2 
3import java.io.BufferedReader;
4import java.io.File;
5import java.io.FileReader;
6 
7import org.eclipse.jface.action.Action;
8import org.eclipse.swt.widgets.FileDialog;
9import org.eclipse.ui.PlatformUI;
10 
11import de.uka.ipd.sdq.codegen.simudatavisualisation.datatypes.Histogram;
12import de.uka.ipd.sdq.codegen.simudatavisualisation.datatypes.HistogramBucketInformation;
13 
14public class LoadCSVHistogram extends Action {
15        private Histogram histogram = null;
16        private IHistogramAccepter viewer;
17        
18        public Histogram getHistogram() {
19                return histogram;
20        }
21 
22        public LoadCSVHistogram(IHistogramAccepter freeChartHistogramViewer) {
23                super();
24                setText("Load CSV...");
25                this.viewer = freeChartHistogramViewer;
26        }
27        
28        @Override
29        public void run() {
30                FileDialog dialog = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
31                dialog.open();
32                if (dialog.getFileName() != null){
33                        this.histogram = importHistogram(dialog.getFilterPath()+File.separator+dialog.getFileName());
34                }
35                viewer.addHistogram(histogram);
36        }
37 
38        private Histogram importHistogram(String fileName) {
39                Histogram h = new Histogram("Measurements");
40                FileReader fileReader;
41                BufferedReader bufferedReader;
42                try {
43                        String row;
44                        fileReader = new FileReader(fileName);
45                        bufferedReader = new BufferedReader(fileReader);
46                        while((row=bufferedReader.readLine()) != null)
47                        {
48                                String[] parts = row.split(";");
49                                double x = Double.parseDouble(parts[0].replace(',','.'));
50                                double y = Double.parseDouble(parts[1].replace(',','.'));
51                                h.addEntity(new HistogramBucketInformation(y, x));
52                        }
53                } catch(Exception e) {
54                        return null;
55                        // TODO: Error Message Box
56                }
57                for (HistogramBucketInformation e:h.getBucketInformation())
58                        System.out.print("runif("+Math.round(e.getProbability()*100000)+","+(e.getValue()-5)+","+(e.getValue()+5)+"),");
59                return h;
60        }
61}

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