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 19 public class Designer extends JFrame 20 { 21 22 public static final String 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 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 ); 55 56 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 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 96 public static void main( String [] args ) throws ChartDataException 97 { 98 Designer designer = new Designer(); 99 100 118 } 119 } | Popular Tags |