KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > krysalis > jcharts > demo > samples > Pie3DSamples


1 package org.krysalis.jcharts.demo.samples;
2
3
4 import java.awt.Color JavaDoc;
5 import java.awt.Paint JavaDoc;
6
7 import org.krysalis.jcharts.chartData.ChartDataException;
8 import org.krysalis.jcharts.chartData.PieChartDataSet;
9 import org.krysalis.jcharts.nonAxisChart.PieChart3D;
10 import org.krysalis.jcharts.properties.ChartProperties;
11 import org.krysalis.jcharts.properties.LegendProperties;
12 import org.krysalis.jcharts.properties.PieChart3DProperties;
13 import org.krysalis.jcharts.properties.util.ChartStroke;
14 import org.krysalis.jcharts.types.PieLabelType;
15
16
17 /*************************************************************************************
18  *
19  * @author Nathaniel Auvil
20  * @version $Id: Pie3DSamples.java,v 1.2 2003/09/02 08:48:19 nicolaken Exp $
21  ************************************************************************************/

22 public class Pie3DSamples extends Sample
23 {
24
25     protected String JavaDoc getSubdir()
26     {
27         return "pie3d/";
28     }
29
30
31     public void render() throws ChartDataException
32     {
33         double[] data = {45.00d, 90.00d, 45.00d, 180d};
34         String JavaDoc[] labels = {"Equities", "Bonds", "Money Market", "Alternative Investments"};
35
36       Paint JavaDoc[] paints = { new Color JavaDoc( 200, 0, 0, 20 ),
37                                  new Color JavaDoc( 0, 200, 0, 20 ),
38                                  new Color JavaDoc( 0, 0, 200, 20 ),
39                                  new Color JavaDoc( 200, 200, 0, 20 ) };
40
41
42         PieChart3DProperties pieChart3DProperties = new PieChart3DProperties();
43         pieChart3DProperties.setPieLabelType( PieLabelType.LEGEND_LABELS );
44         pieChart3DProperties.setTickLength( 5 );
45
46         pieChart3DProperties.setZeroDegreeOffset( 60 );
47
48         pieChart3DProperties.setDepth( 15 );
49
50
51         LegendProperties legendProperties = null;
52 /*
53         LegendProperties legendProperties = new LegendProperties();
54         legendProperties.setPlacement( LegendAreaProperties.RIGHT );
55         legendProperties.setNumColumns( 1 );
56 */

57
58         PieChartDataSet pieChartDataSet = new PieChartDataSet( "Investment Categories", data, labels, paints, pieChart3DProperties );
59
60         ChartProperties chartProperties = new ChartProperties();
61         chartProperties.setBorderStroke( ChartStroke.DEFAULT_CHART_OUTLINE );
62
63         PieChart3D pieChart = new PieChart3D( pieChartDataSet, legendProperties, chartProperties, 500, 400 );
64
65
66         super.encode( pieChart, "pie3d" );
67     }
68 }
69
Popular Tags