1 34 35 36 package org.krysalis.jcharts.designer.charts; 37 38 39 import org.krysalis.jcharts.nonAxisChart.PieChart2D; 40 import org.krysalis.jcharts.properties.PieChart2DProperties; 41 import org.krysalis.jcharts.chartData.PieChartDataSet; 42 import org.krysalis.jcharts.chartData.ChartDataException; 43 44 import java.awt.*; 45 46 47 52 public class DesignerPieChart extends DesignerChart 53 { 54 private PieChart2D pieChart2D; 55 private PieChart2DProperties pieChart2DProperties; 56 private PieChartDataSet pieChartDataSet; 57 58 59 65 public DesignerPieChart( int width, int height ) throws ChartDataException 66 { 67 super( width, height ); 68 69 this.pieChart2DProperties = new PieChart2DProperties(); 70 71 super.setTitle( "Cars that Own" ); 72 super.setLegendLabels( new String []{"BMW", "Audi", "Lexus"} ); 73 super.setPaints( new Paint[]{ Color.blue, Color.gray, Color.red } ); 74 super.setData( new double[][]{ {50d, 30d, 20d} } ); 75 76 this.updateChart(); 77 } 78 79 80 85 public void updateChart() throws ChartDataException 86 { 87 this.pieChartDataSet = new PieChartDataSet( super.getTitle(), 88 super.getData()[ 0 ], 89 super.getLegendLabels(), 90 super.getPaints(), 91 this.pieChart2DProperties ); 92 93 this.pieChart2D= new PieChart2D( pieChartDataSet, 94 super.getLegendProperties(), 95 super.getChartProperties(), 96 super.getWidth(), 97 super.getHeight() ); 98 } 99 100 101 public PieChart2D getPieChart2D() 102 { 103 return this.pieChart2D; 104 } 105 106 107 public PieChart2DProperties getPieChart2DProperties() 108 { 109 return pieChart2DProperties; 110 } 111 } 112 | Popular Tags |