01: package org.krysalis.jcharts.chartData.processors;
02:
03: import org.krysalis.jcharts.chartData.interfaces.IRadarChartDataSet;
04:
05: /**
06: * Utility class to process the RadarChartDataSet
07: *
08: * @author Rami Hansenne
09: */
10: final public class RadarChartDataProcessor {
11: private IRadarChartDataSet iRadarChartDataSet;
12:
13: private double minValue = Double.MAX_VALUE;
14: private double maxValue = Double.MIN_VALUE;
15:
16: /******************************************************************************************
17: * Constructor
18: *
19: * @param iRadarChartDataSet
20: *******************************************************************************************/
21: public RadarChartDataProcessor(IRadarChartDataSet iRadarChartDataSet) {
22: this .iRadarChartDataSet = iRadarChartDataSet;
23: }
24:
25: /*******************************************************************************************
26: * This method should do a single pass through the data set and calculate all needed values,
27: * such as: min, max, sum, etc... so that we can do this in one pass through the data.
28: * Rather than once for each.
29: *
30: ********************************************************************************************/
31: public void processData() {
32: for (int i = 0; i < iRadarChartDataSet.getNumberOfDataSets(); i++) {
33: for (int j = 0; j < iRadarChartDataSet.getDataSetSize(); j++) {
34: double value = iRadarChartDataSet.getValue(i, j);
35: if (value > maxValue)
36: maxValue = value;
37: if (value < minValue)
38: minValue = value;
39: }
40: }
41: }
42:
43: public double getMinValue() {
44: return minValue;
45: }
46:
47: public double getMaxValue() {
48: return maxValue;
49: }
50:
51: }
|