01: package org.jahia.sqlprofiler.gui;
02:
03: import javax.swing.JPanel;
04:
05: import javax.swing.*;
06: import java.awt.*;
07: import java.awt.event.WindowEvent;
08: import org.jCharts.chartData.ChartDataException;
09: import org.jCharts.properties.PropertyException;
10: import org.jCharts.properties.PieChart2DProperties;
11: import org.jCharts.properties.LegendProperties;
12: import org.jCharts.properties.ChartProperties;
13: import org.jCharts.chartData.PieChartDataSet;
14: import org.jCharts.nonAxisChart.PieChart2D;
15: import org.jCharts.axisChart.AxisChart;
16: import org.jCharts.test.TestDataGenerator;
17: import org.jCharts.properties.LineChartProperties;
18: import org.jCharts.properties.PointChartProperties;
19: import org.jCharts.chartData.AxisChartDataSet;
20: import org.jCharts.types.ChartType;
21: import org.jCharts.properties.AxisProperties;
22: import org.jCharts.chartData.DataSeries;
23: import java.util.Date;
24: import java.text.SimpleDateFormat;
25: import java.util.ArrayList;
26: import java.util.Iterator;
27: import org.jahia.sqlprofiler.QueryEntry;
28: import org.jCharts.Chart;
29: import org.apache.log4j.Category;
30:
31: /**
32: * <p>Title: </p>
33: * <p>Description: </p>
34: * <p>Copyright: Copyright (c) 2003</p>
35: * <p>Company: Jahia Ltd</p>
36: * @author not attributable
37: * @version 1.0
38: */
39:
40: public class ChartPanel extends JPanel implements ChartModelListener {
41:
42: /** used to log messages **/
43: private static final Category LOG = Category
44: .getInstance(ChartPanel.class);
45:
46: private Chart chart;
47: private ChartModel chartModel;
48:
49: public ChartPanel(ChartModel chartModel) throws ChartDataException,
50: PropertyException {
51: chartModel.addChartModelListener(this );
52: this .chartModel = chartModel;
53: }
54:
55: public void paint(Graphics graphics) {
56:
57: chart = chartModel.getChart(this .getSize());
58:
59: if (chart != null) {
60: try {
61: chart.setGraphics2D((Graphics2D) graphics);
62: chart.render();
63: } catch (PropertyException pe) {
64: pe.printStackTrace();
65: } catch (ChartDataException cde) {
66: cde.printStackTrace();
67: }
68: }
69: }
70:
71: public void chartDataChanged(ChartModelEvent e) {
72: ChartModel chartModel = (ChartModel) e.getSource();
73: this .chartModel = chartModel; // in case it changed !
74: this.repaint();
75: }
76:
77: }
|