1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.jstats.charts.boxAndWhisker;
11
12 import java.awt.Color;
13 import java.awt.Container;
14 import java.awt.Dimension;
15 import java.awt.Font;
16 import java.awt.GradientPaint;
17
18 import nl.tudelft.simulation.jstats.Swingable;
19 import nl.tudelft.simulation.jstats.statistics.Tally;
20
21 import org.jfree.chart.ChartPanel;
22 import org.jfree.chart.JFreeChart;
23 import org.jfree.chart.plot.Plot;
24
25 /***
26 * The summaryuChart specifies a summaryChart. <br>
27 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
28 * University of Technology </a>, the Netherlands. <br>
29 * See for project information <a href="http://www.simulation.tudelft.nl">
30 * www.simulation.tudelft.nl </a> <br>
31 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
32 * License (GPL) </a>, no warranty <br>
33 *
34 * @version 2.0 21.09.2003 <br>
35 * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
36 * Jacobs </a>, <a
37 * href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">
38 * Alexander Verbraeck </a>
39 */
40 public class BoxAndWhiskerChart implements Swingable
41 {
42 /*** TITLE_FONT refers to the font to be used for the title of the plot */
43 public static final Font TITLE_FONT = new Font("SansSerif", Font.BOLD, 18);
44
45 /*** chart refers to the actual chart */
46 private JFreeChart chart = null;
47
48 /***
49 * constructs a new BoxAndWhiskerChart
50 *
51 * @param title the title of the chart
52 */
53 public BoxAndWhiskerChart(final String title)
54 {
55 Plot plot = new BoxAndWhiskerPlot();
56 this.chart = new JFreeChart(title, TITLE_FONT, plot, true);
57 this.chart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F,
58 Color.white, 1000F, 0.0F, Color.blue));
59 }
60
61 /***
62 * adds a tally to the chart
63 *
64 * @param tally the tally to be added
65 */
66 public void add(final Tally tally)
67 {
68 ((BoxAndWhiskerPlot) this.chart.getPlot()).add(tally);
69 }
70
71 /***
72 * returns the chart
73 *
74 * @return JFreeChart
75 */
76 public JFreeChart getChart()
77 {
78 return this.chart;
79 }
80
81 /***
82 * returns the swing panel of this chart
83 *
84 * @return Container the swing panel
85 */
86 public Container getSwingPanel()
87 {
88 ChartPanel result = new ChartPanel(this.chart);
89 result.setMouseZoomable(true, false);
90 result.setPreferredSize(new Dimension(800, 600));
91 return result;
92 }
93 }