001: package org.krysalis.jcharts.designer;
002:
003: import org.krysalis.jcharts.chartData.ChartDataException;
004: import org.krysalis.jcharts.designer.charts.DesignerPieChart;
005: import org.krysalis.jcharts.designer.exceptions.DesignerException;
006: import org.krysalis.jcharts.designer.menuBar.DesignerMenuBar;
007: import org.krysalis.jcharts.designer.tabs.LowerHalfPanel;
008:
009: import javax.swing.*;
010:
011: /*******************************************************************************
012: *
013: * @author Nathaniel Auvil
014: * @version $Id: Designer.java,v 1.2 2004/05/29 13:50:13 nathaniel_auvil Exp $
015: ******************************************************************************/
016: public class Designer extends JFrame {
017:
018: public static final String TITLE = "jCharts Designer - 1.0.0";
019:
020: private ChartPanel chartPanel;
021: private LowerHalfPanel lowerHalfPanel;
022:
023: private DesignerPieChart designerPieChart;
024: private org.krysalis.jcharts.axisChart.AxisChart axisChart;
025:
026: /****************************************************************************
027: *
028: * @throws org.krysalis.jcharts.chartData.ChartDataException
029: ***************************************************************************/
030: public Designer() throws ChartDataException {
031: super (TITLE);
032:
033: this .designerPieChart = new DesignerPieChart(450, 450);
034:
035: super .setJMenuBar(new DesignerMenuBar(this ));
036: super .getContentPane()
037: .setLayout(
038: new BoxLayout(super .getContentPane(),
039: BoxLayout.Y_AXIS));
040:
041: this .chartPanel = new ChartPanel(this );
042: this .chartPanel.setChart(this .designerPieChart.getPieChart2D(),
043: 500, 500);
044:
045: this .lowerHalfPanel = new LowerHalfPanel(this );
046:
047: JScrollPane scrollPane = new JScrollPane(this .chartPanel);
048: JSplitPane jSplitPane = new JSplitPane(
049: JSplitPane.VERTICAL_SPLIT, scrollPane,
050: this .lowerHalfPanel);
051: jSplitPane.setOneTouchExpandable(true);
052:
053: //this.getContentPane().add( jSplitPane, BorderLayout.CENTER );
054: this .getContentPane().add(jSplitPane);
055:
056: //---so when they click on the 'x' in the upper right corner, the
057: // program exits
058: super .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
059:
060: this .pack();
061: this .setVisible(true);
062:
063: super .setBounds(30, 30, 600, 600);
064: }
065:
066: /****************************************************************************
067: *
068: ***************************************************************************/
069: public void refreshChart() {
070: try {
071: this .lowerHalfPanel.getTopLevelTabs()
072: .updateChartProperties(
073: this .designerPieChart.getChartProperties());
074:
075: this .designerPieChart.updateChart();
076: this .chartPanel.repaint();
077: } catch (DesignerException designerException) {
078: designerException.display(this );
079: } catch (ChartDataException chartDataException) {
080: JOptionPane.showMessageDialog(this , chartDataException
081: .getMessage(), "Chart Data Exception",
082: JOptionPane.ERROR_MESSAGE);
083: }
084: }
085:
086: /****************************************************************************
087: *
088: ***************************************************************************/
089: public static void main(String[] args) throws ChartDataException {
090: Designer designer = new Designer();
091:
092: /*
093: * int width= 450; int height= 450;
094: *
095: * try { String[] labels = {"BMW", "Audi", "Lexus"}; String title = "Cars
096: * that Own"; Paint[] paints = {Color.blue, Color.gray, Color.red};
097: * double[] data = {50d, 30d, 20d};
098: *
099: * PieChart2DProperties pieChart2DProperties = new PieChart2DProperties();
100: * PieChartDataSet pieChartDataSet = new PieChartDataSet( title, data,
101: * labels, paints, pieChart2DProperties );
102: *
103: * PieChart2D pieChart2D = new PieChart2D( pieChartDataSet, new
104: * LegendProperties(), new ChartProperties(), width, height );
105: *
106: * designer.chartPanel.setChart( pieChart2D, width, height ); } catch(
107: * ChartDataException chartDataException ) {
108: * chartDataException.printStackTrace(); }
109: */
110: }
111: }
|