KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > krysalis > jcharts > chartData > processors > RadarChartDataProcessor


1
2 package org.krysalis.jcharts.chartData.processors;
3
4 import org.krysalis.jcharts.chartData.interfaces.IRadarChartDataSet;
5
6
7
8
9 /**
10  * Utility class to process the RadarChartDataSet
11  *
12  * @author Rami Hansenne
13  */

14 final public class RadarChartDataProcessor
15 {
16         private IRadarChartDataSet iRadarChartDataSet;
17
18         private double minValue = Double.MAX_VALUE;
19         private double maxValue = Double.MIN_VALUE;
20
21         /******************************************************************************************
22          * Constructor
23          *
24          * @param iRadarChartDataSet
25          *******************************************************************************************/

26         public RadarChartDataProcessor( IRadarChartDataSet iRadarChartDataSet )
27         {
28                 this.iRadarChartDataSet = iRadarChartDataSet;
29         }
30
31
32         /*******************************************************************************************
33          * This method should do a single pass through the data set and calculate all needed values,
34          * such as: min, max, sum, etc... so that we can do this in one pass through the data.
35          * Rather than once for each.
36          *
37          ********************************************************************************************/

38         public void processData()
39         {
40                 for( int i = 0; i < iRadarChartDataSet.getNumberOfDataSets(); i++ )
41                 {
42                   for( int j = 0; j < iRadarChartDataSet.getDataSetSize(); j++ )
43                   {
44                     double value = iRadarChartDataSet.getValue(i,j);
45                     if (value>maxValue) maxValue = value;
46                     if (value<minValue) minValue = value;
47                   }
48                 }
49         }
50
51
52         public double getMinValue()
53         {
54                 return minValue;
55         }
56
57         public double getMaxValue()
58         {
59                 return maxValue;
60         }
61
62 }
63
Popular Tags