KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > krysalis > jcharts > designer > Designer


1
2 package org.krysalis.jcharts.designer;
3
4
5 import org.krysalis.jcharts.chartData.ChartDataException;
6 import org.krysalis.jcharts.designer.charts.DesignerPieChart;
7 import org.krysalis.jcharts.designer.exceptions.DesignerException;
8 import org.krysalis.jcharts.designer.menuBar.DesignerMenuBar;
9 import org.krysalis.jcharts.designer.tabs.LowerHalfPanel;
10
11 import javax.swing.*;
12
13
14 /*******************************************************************************
15  *
16  * @author Nathaniel Auvil
17  * @version $Id: Designer.java,v 1.2 2004/05/29 13:50:13 nathaniel_auvil Exp $
18  ******************************************************************************/

19 public class Designer extends JFrame
20 {
21
22     public static final String JavaDoc TITLE = "jCharts Designer - 1.0.0";
23
24     private ChartPanel chartPanel;
25     private LowerHalfPanel lowerHalfPanel;
26
27     private DesignerPieChart designerPieChart;
28     private org.krysalis.jcharts.axisChart.AxisChart axisChart;
29
30
31     /****************************************************************************
32      *
33      * @throws org.krysalis.jcharts.chartData.ChartDataException
34      ***************************************************************************/

35     public Designer() throws ChartDataException
36     {
37         super( TITLE );
38
39         this.designerPieChart = new DesignerPieChart( 450, 450 );
40
41         super.setJMenuBar( new DesignerMenuBar( this ) );
42         super.getContentPane().setLayout( new BoxLayout( super.getContentPane(), BoxLayout.Y_AXIS ) );
43
44         this.chartPanel = new ChartPanel( this );
45         this.chartPanel.setChart( this.designerPieChart.getPieChart2D(), 500, 500 );
46
47         this.lowerHalfPanel = new LowerHalfPanel( this );
48
49         JScrollPane scrollPane = new JScrollPane( this.chartPanel );
50         JSplitPane jSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, scrollPane, this.lowerHalfPanel );
51         jSplitPane.setOneTouchExpandable( true );
52
53         //this.getContentPane().add( jSplitPane, BorderLayout.CENTER );
54
this.getContentPane().add( jSplitPane );
55
56         //---so when they click on the 'x' in the upper right corner, the
57
// program exits
58
super.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
59
60         this.pack();
61         this.setVisible( true );
62
63         super.setBounds( 30, 30, 600, 600 );
64     }
65
66
67     /****************************************************************************
68      *
69      ***************************************************************************/

70     public void refreshChart()
71     {
72         try
73         {
74             this.lowerHalfPanel.getTopLevelTabs().updateChartProperties( this.designerPieChart.getChartProperties() );
75
76             this.designerPieChart.updateChart();
77             this.chartPanel.repaint();
78         }
79         catch( DesignerException designerException )
80         {
81             designerException.display( this );
82         }
83         catch( ChartDataException chartDataException )
84         {
85             JOptionPane.showMessageDialog( this,
86                                                         chartDataException.getMessage(),
87                                                         "Chart Data Exception",
88                                                         JOptionPane.ERROR_MESSAGE );
89         }
90     }
91
92
93     /****************************************************************************
94      *
95      ***************************************************************************/

96     public static void main( String JavaDoc[] args ) throws ChartDataException
97     {
98         Designer designer = new Designer();
99
100         /*
101          * int width= 450; int height= 450;
102          *
103          * try { String[] labels = {"BMW", "Audi", "Lexus"}; String title = "Cars
104          * that Own"; Paint[] paints = {Color.blue, Color.gray, Color.red};
105          * double[] data = {50d, 30d, 20d};
106          *
107          * PieChart2DProperties pieChart2DProperties = new PieChart2DProperties();
108          * PieChartDataSet pieChartDataSet = new PieChartDataSet( title, data,
109          * labels, paints, pieChart2DProperties );
110          *
111          * PieChart2D pieChart2D = new PieChart2D( pieChartDataSet, new
112          * LegendProperties(), new ChartProperties(), width, height );
113          *
114          * designer.chartPanel.setChart( pieChart2D, width, height ); } catch(
115          * ChartDataException chartDataException ) {
116          * chartDataException.printStackTrace(); }
117          */

118     }
119 }
Popular Tags