From: <nat...@us...> - 2003-08-16 16:05:18
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/documentation/content/xdocs/userGuide In directory sc8-pr-cvs1:/tmp/cvs-serv18210 Modified Files: exportingImages.xml Log Message: enhanced the code snippet for swing demo code Index: exportingImages.xml =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/documentation/content/xdocs/userGuide/exportingImages.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** exportingImages.xml 21 Jun 2003 16:01:43 -0000 1.2 --- exportingImages.xml 16 Aug 2003 16:04:12 -0000 1.3 *************** *** 99,125 **** this.panel.setSize( 500, 500 ); this.getContentPane().add( this.panel ); - this.setVisible( true ); - - String[] labels = {"BMW", "Audi", "Lexus"}; - String title = "Cars that Own"; - Paint[] paints = {Color.blue, Color.gray, Color.red}; - double[] data = {50d, 30d, 20d}; ! PieChart2DProperties pieChart2DProperties = new PieChart2DProperties(); ! PieChartDataSet pieChartDataSet = ! new PieChartDataSet( title, data, labels, paints, ! pieChart2DProperties ); ! ! PieChart2D pieChart2D = ! new PieChart2D( pieChartDataSet, new LegendProperties(), ! new ChartProperties(), 450, 450 ); ! //***** BEGIN SWING SPECIFIC CODE *********************************** ! //---Here is where you set the Chart Graphics2D Object ! pieChart2D.setGraphics2D( (Graphics2D) this.panel.getGraphics() ); - //---now simply call render on the chart - pieChart2D.render(); - //***** END SWING SPECIFIC CODE ************************************* addWindowListener( new java.awt.event.WindowAdapter() --- 99,109 ---- this.panel.setSize( 500, 500 ); this.getContentPane().add( this.panel ); ! this.pieChart2DProperties = new PieChart2DProperties(); ! this.legendProperties= new LegendProperties(); ! this.chartProperties= new ChartProperties(); ! this.setVisible( true ); addWindowListener( new java.awt.event.WindowAdapter() *************** *** 132,135 **** --- 116,154 ---- ); } + + + /************************************************************************ + * + * @param graphics + ***********************************************************************/ + public void paint( Graphics graphics ) + { + try { + String[] labels = {"BMW", "Audi", "Lexus"}; + String title = "Cars that Own"; + Paint[] paints = {Color.blue, Color.gray, Color.red}; + double[] data = {50d, 30d, 20d}; + PieChartDataSet pieChartDataSet = new PieChartDataSet( title, data, + labels, paints, this.pieChart2DProperties ); + Dimension dimension= this.panel.getSize(); + PieChart2D pieChart2D = new PieChart2D( pieChartDataSet, + this.legendProperties, + this.chartProperties, + (int) dimension.getWidth(), + (int) dimension.getHeight() ); + + //***** BEGIN SWING SPECIFIC CODE ******************************* + pieChart2D.setGraphics2D( (Graphics2D) this.panel.getGraphics() ); + pieChart2D.render(); + //***** END SWING SPECIFIC CODE ********************************* + } + catch( ChartDataException chartDataException ) { + chartDataException.printStackTrace(); + } + catch( PropertyException propertyException ) { + propertyException.printStackTrace(); + } + } + private void exitForm( WindowEvent windowEvent ) |