1 39 40 package org.krysalis.jcharts.chartData; 41 42 43 import org.krysalis.jcharts.chartData.interfaces.IPieChartDataSet; 44 import org.krysalis.jcharts.properties.PieChart2DProperties; 45 46 import java.awt.*; 47 48 49 53 final public class PieChartDataSet extends DataSet implements IPieChartDataSet 54 { 55 private String chartTitle; 56 57 58 68 public PieChartDataSet( String chartTitle, 69 double[] data, 70 String [] legendLabels, 71 Paint[] paints, 72 PieChart2DProperties pieChart2DProperties ) throws ChartDataException 73 { 74 super( new double[][]{data}, legendLabels, paints, pieChart2DProperties ); 75 76 this.chartTitle=chartTitle; 77 78 this.validateData( data, legendLabels, paints ); 79 } 80 81 82 91 private void validateData( double[] data, String [] legendLabels, Paint[] paints ) throws ChartDataException 92 { 93 if( legendLabels != null && ( data.length != legendLabels.length ) ) 94 { 95 throw new ChartDataException( "There is not an one to one mapping of 'legend labels' to 'data items'." ); 96 } 97 98 if( data.length != paints.length ) 99 { 100 throw new ChartDataException( "There is not an one to one mapping of 'Paint' Implementations to 'data items'." ); 101 } 102 } 103 104 105 110 public String getChartTitle() 111 { 112 return this.chartTitle; 113 } 114 115 116 123 public double getValue( int index ) throws ArrayIndexOutOfBoundsException 124 { 125 return super.data[ 0 ][ index ]; 126 } 127 } 128 | Popular Tags |