1 package org.jahia.sqlprofiler.gui; 2 3 import javax.swing.JPanel ; 4 5 import javax.swing.*; 6 import java.awt.*; 7 import java.awt.event.WindowEvent ; 8 import org.jCharts.chartData.ChartDataException; 9 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 39 40 public class ChartPanel extends JPanel implements ChartModelListener { 41 42 43 private static final Category LOG = 44 Category.getInstance(ChartPanel.class); 45 46 private Chart chart; 47 private ChartModel chartModel; 48 49 public ChartPanel(ChartModel chartModel) throws 50 ChartDataException, 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; this.repaint(); 75 } 76 77 } | Popular Tags |