01: /***************************************************************************************
02: * File Info: $Id: ChartPanel.java,v 1.1 2003/08/09 16:57:29 nathaniel_auvil Exp $
03: *
04: * Description:
05: *
06: * Last Reviewed: NEVER
07: * Maintainer: Nathaniel Auvil
08: * Copyright: <copyright.icore>
09: ***************************************************************************************/package org.krysalis.jcharts.designer;
10:
11: import org.krysalis.jcharts.Chart;
12: import org.krysalis.jcharts.properties.PropertyException;
13: import org.krysalis.jcharts.chartData.ChartDataException;
14:
15: import javax.swing.*;
16: import java.awt.*;
17:
18: public class ChartPanel extends JPanel {
19:
20: private Designer designer;
21: private Chart chart;
22:
23: /***********************************************************************************
24: *
25: * @param designer
26: **********************************************************************************/
27: public ChartPanel(Designer designer) {
28: super ();
29:
30: super .setMinimumSize(new Dimension(400, 400));
31: super .setVisible(true);
32:
33: this .designer = designer;
34: }
35:
36: /**********************************************************************************
37: *
38: * @param chart
39: * @param width
40: * @param height
41: **********************************************************************************/
42: public void setChart(Chart chart, int width, int height) {
43: this .chart = chart;
44: super .setSize(width, height);
45: //todo this does not set the size correctly
46: }
47:
48: /***********************************************************************************
49: *
50: * @param graphics
51: **********************************************************************************/
52: public void paint(Graphics graphics) {
53: super .paint(graphics);
54:
55: if (this .chart != null) {
56: try {
57: this .chart.setGraphics2D((Graphics2D) graphics);
58: this .chart.render();
59: } catch (ChartDataException chartDataException) {
60: chartDataException.printStackTrace();
61: } catch (PropertyException propertyException) {
62: propertyException.printStackTrace();
63: }
64: }
65: }
66:
67: }
|