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

COVERAGE SUMMARY FOR SOURCE FILE [JFVisualisation.java]

nameclass, %method, %block, %line, %
JFVisualisation.java0%   (0/1)0%   (0/5)0%   (0/323)0%   (0/70)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JFVisualisation0%   (0/1)0%   (0/5)0%   (0/323)0%   (0/70)
JFVisualisation (double): void 0%   (0/1)0%   (0/17)0%   (0/5)
addPMF (ManagedPMF, String): void 0%   (0/1)0%   (0/40)0%   (0/8)
addSamplePDF (ISamplePDF, String): void 0%   (0/1)0%   (0/70)0%   (0/15)
visualize (): void 0%   (0/1)0%   (0/90)0%   (0/19)
visualizeOverlay (): void 0%   (0/1)0%   (0/106)0%   (0/23)

1package de.uka.ipd.sdq.pcmsolver.visualisation;
2 
3import java.awt.BorderLayout;
4import java.awt.Color;
5import java.awt.Toolkit;
6import java.io.BufferedWriter;
7import java.io.FileWriter;
8import java.io.IOException;
9import java.util.List;
10 
11import javax.swing.JFrame;
12 
13import org.jfree.chart.ChartFactory;
14import org.jfree.chart.ChartPanel;
15import org.jfree.chart.JFreeChart;
16import org.jfree.chart.plot.PlotOrientation;
17import org.jfree.chart.plot.XYPlot;
18import org.jfree.data.xy.DefaultTableXYDataset;
19import org.jfree.data.xy.XYSeries;
20 
21import de.uka.ipd.sdq.probfunction.math.IProbabilityMassFunction;
22import de.uka.ipd.sdq.probfunction.math.ISample;
23import de.uka.ipd.sdq.probfunction.math.ISamplePDF;
24import de.uka.ipd.sdq.probfunction.math.ManagedPMF;
25import de.uka.ipd.sdq.probfunction.math.exception.ProbabilityFunctionException;
26 
27public class JFVisualisation {
28 
29        protected JFrame graphFrame;
30 
31        protected JFreeChart myChart;
32 
33        protected ChartPanel chartPanel;
34 
35        protected DefaultTableXYDataset dataset;
36 
37        protected double distance;
38 
39        public JFVisualisation(double distance) {
40                dataset = new DefaultTableXYDataset();
41                graphFrame = new JFrame("Execution Time");
42                this.distance = distance;
43        }
44 
45        public void addSamplePDF(ISamplePDF samplePDF, String name)
46                        throws ProbabilityFunctionException {
47                //ISamplePDF samplePDF = pdf.getSamplePdfTimeDomain();
48 
49                
50                XYSeries series = new XYSeries(name, true, false);
51 
52                samplePDF = samplePDF.getFunctionWithNewDistance(distance);
53                List<Double> points = samplePDF.getValuesAsDouble();
54                
55 
56                
57                try {
58                        BufferedWriter out = new BufferedWriter(new FileWriter("test.csv"));
59                
60                        int i = 0;
61                        for (Double point : points) {
62                                series.add(i, point);
63                                out.write(i/10.0+";"+point);
64                                out.newLine();
65                                i++;
66                        }
67 
68                out.close();
69                
70                } catch (IOException e) {
71                        // TODO Auto-generated catch block
72                        e.printStackTrace();
73                }
74        
75 
76 
77                dataset.addSeries(series);
78        }
79 
80        public void visualize() {
81                dataset.setIntervalWidth(distance);
82                myChart = ChartFactory.createHistogram(
83                                "Measured Execution Time Histogram", "Time ["+distance+" s]",
84                                "Probability", dataset, PlotOrientation.VERTICAL, true, true,
85                                true);
86                XYPlot plot = (XYPlot) myChart.getPlot();
87                plot.getRangeAxis().setRange(0, 1.1d);
88                
89                graphFrame.setSize(800, 600);
90                graphFrame
91                                .setLocation(
92                                                (Toolkit.getDefaultToolkit().getScreenSize().width - graphFrame
93                                                                .getSize().width) / 2,
94                                                (Toolkit.getDefaultToolkit().getScreenSize().height - graphFrame
95                                                                .getSize().height) / 2);
96                graphFrame.getContentPane().setLayout(new BorderLayout());
97                chartPanel = new ChartPanel(myChart);
98                graphFrame.getContentPane().add(chartPanel, BorderLayout.CENTER);
99                graphFrame.setVisible(true);
100 
101        }
102 
103        public void visualizeOverlay() {
104                dataset.setIntervalWidth(1);
105                myChart = ChartFactory.createHistogram("", "Time ["+distance+" ms]", // x Axis label
106                                "Probability", // y Axis label
107                                dataset, PlotOrientation.VERTICAL, true, // legend
108                                true, // tooltips
109                                true); // url
110 
111                XYPlot plot = (XYPlot) myChart.getPlot();
112 
113                plot.getRenderer().setSeriesPaint(0, Color.BLUE.brighter());
114                //plot.getRenderer().setSeriesPaint(0, Color.RED); // Foreground Series
115                plot.getRenderer().setSeriesPaint(1, Color.BLUE.brighter()); // Background Series
116                plot.setForegroundAlpha(0.8f); // for transparency
117                //plot.getRangeAxis().setRange(0, 0.5d);
118                plot.getRangeAxis().setAutoRange(true);
119                plot.setBackgroundPaint(Color.white);
120 
121                graphFrame.setSize(800, 600);
122                graphFrame.setLocation(
123                                                (Toolkit.getDefaultToolkit().getScreenSize().width - graphFrame
124                                                                .getSize().width) / 2,
125                                                (Toolkit.getDefaultToolkit().getScreenSize().height - graphFrame
126                                                                .getSize().height) / 2);
127                graphFrame.getContentPane().setLayout(new BorderLayout());
128                chartPanel = new ChartPanel(myChart);
129                graphFrame.getContentPane().add(chartPanel, BorderLayout.CENTER);
130                //graphFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
131                graphFrame.setVisible(true);
132                
133 
134//                File testFile = new File("examplePMF2.png");
135//                try {
136//                        ChartUtilities.saveChartAsPNG(testFile, myChart, 600, 400);
137//                } catch (IOException e) {
138//                        e.printStackTrace();
139//                }
140 
141        }
142 
143        public void addPMF(ManagedPMF managedPMF, String name) {
144                IProbabilityMassFunction pmf = managedPMF.getPmfTimeDomain();
145 
146                XYSeries series = new XYSeries(name, true, false);
147 
148                List<ISample> points = pmf.getSamples();
149 
150                for (ISample sample : points) {
151                        double value = (Integer) sample.getValue();
152                        series.add(value, sample.getProbability());
153                }
154                dataset.addSeries(series);
155        }
156}

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