Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/ECJClient/src/ec/display/StatisticsChartPane.java @ 6152

Last change on this file since 6152 was 6152, checked in by bfarka, 13 years ago

added ecj and custom statistics to communicate with the okb services #1441

File size: 2.7 KB
Line 
1/*
2  Copyright 2006 by Sean Paus
3  Licensed under the Academic Free License version 3.0
4  See the file "LICENSE" for more information
5*/
6
7
8/*
9 * Created on Apr 17, 2005 11:20:52 AM
10 *
11 * By: spaus
12 */
13package ec.display;
14
15import java.awt.Color;
16
17import javax.swing.JTabbedPane;
18
19
20import org.jfree.chart.ChartPanel;
21import org.jfree.chart.JFreeChart;
22
23import ec.EvolutionState;
24import ec.Setup;
25import ec.Statistics;
26import ec.display.chart.ChartableStatistics;
27import ec.display.chart.StatisticsChartPaneTab;
28import ec.util.Parameter;
29
30/**
31 * @author spaus
32 */
33public class StatisticsChartPane
34    extends JTabbedPane
35    implements Setup
36    {
37    public int numCharts;
38   
39    /**
40     *
41     */
42    public StatisticsChartPane()
43        {
44        super();
45        initialize();
46        }
47   
48    /**
49     * @param tabPlacement
50     */
51    public StatisticsChartPane(int tabPlacement)
52        {
53        super(tabPlacement);
54        initialize();
55        }
56   
57    /**
58     * @param tabPlacement
59     * @param tabLayoutPolicy
60     */
61    public StatisticsChartPane(int tabPlacement, int tabLayoutPolicy)
62        {
63        super(tabPlacement, tabLayoutPolicy);
64        initialize();
65        }
66   
67    private void createCharts(Statistics statistics)
68        {
69        if (statistics instanceof ChartableStatistics)
70            {
71            ChartableStatistics chartStats = (ChartableStatistics)statistics;
72           
73            JFreeChart chart = chartStats.makeChart();
74
75            chart.setBackgroundPaint(Color.white);
76            ChartPanel chartPanel = new ChartPanel(chart);
77            StatisticsChartPaneTab chartPaneTab = new StatisticsChartPaneTab(chartPanel);
78            this.addTab("Chart "+(numCharts++),chartPaneTab);
79            }
80       
81        if (statistics.children != null)
82            {
83            for (int i = 0; i < statistics.children.length; ++i)
84                createCharts(statistics.children[i]);
85            }
86        }
87   
88    /* (non-Javadoc)
89     * @see ec.Setup#setup(ec.EvolutionState, ec.util.Parameter)
90     */
91    public void setup(EvolutionState state, Parameter base)
92        {
93        numCharts = 0;
94        createCharts(state.statistics);
95        }
96   
97    /**
98     * This method initializes this
99     *
100     * @return void
101     */
102    private  void initialize()
103        {
104        this.setSize(300,200);
105        this.addContainerListener(new java.awt.event.ContainerAdapter()
106            {
107            public void componentRemoved(java.awt.event.ContainerEvent e)
108                {   
109                StatisticsChartPane pane = (StatisticsChartPane)e.getSource();
110                if (pane.getTabCount() < 1)
111                    {
112                    pane.getParent().remove(pane);
113                    }
114                }
115            });
116        }
117    }
Note: See TracBrowser for help on using the repository browser.