1 39 40 package org.krysalis.jcharts.chartData.processors; 41 42 43 import org.krysalis.jcharts.axisChart.AxisChart; 44 import org.krysalis.jcharts.chartData.interfaces.IScatterPlotDataSeries; 45 import org.krysalis.jcharts.chartData.interfaces.IScatterPlotDataSet; 46 import org.krysalis.jcharts.types.ChartType; 47 48 import java.awt.font.FontRenderContext ; 49 import java.awt.geom.Point2D ; 50 51 52 55 public final class ScatterPlotDataProcessor extends AxisChartDataProcessor 56 { 57 private double yMax; 58 private double yMin; 59 60 61 65 public ScatterPlotDataProcessor() 66 { 67 68 } 69 70 71 76 public void processData( AxisChart axisChart, FontRenderContext fontRenderContext ) 77 { 78 87 88 IScatterPlotDataSeries iScatterPlotDataSeries = (IScatterPlotDataSeries) axisChart.getIAxisDataSeries(); 89 this.processDataSet( iScatterPlotDataSeries ); 90 91 99 } 100 101 102 108 private void processDataSet( IScatterPlotDataSeries iScatterPlotDataSeries ) 109 { 110 IScatterPlotDataSet iScatterPlotDataSet = (IScatterPlotDataSet) iScatterPlotDataSeries.getIAxisPlotDataSet( ChartType.SCATTER_PLOT ); 111 112 Point2D.Double point; 113 114 for( int dataSet = 0; dataSet < iScatterPlotDataSet.getNumberOfDataSets(); dataSet++ ) 115 { 116 for( int index = 0; index < iScatterPlotDataSet.getNumberOfDataItems(); index++ ) 117 { 118 point = iScatterPlotDataSet.getValue( dataSet, index ); 119 120 if( point == null ) 121 { 122 continue; 123 } 124 125 if( point.getX() > super.getMaxValue() ) 126 { 127 super.setMaxValue( point.getX() ); 128 } 129 130 if( point.getX() < super.getMinValue() ) 131 { 132 super.setMinValue( point.getX() ); 133 } 134 135 if( point.getY() > this.getyMax() ) 136 { 137 this.setyMax( point.getY() ); 138 } 139 140 if( point.getY() < this.getyMin() ) 141 { 142 this.setyMin( point.getY() ); 143 } 144 } 145 } 146 147 } 149 150 151 154 public double getyMax() 155 { 156 return yMax; 157 } 158 159 160 163 public void setyMax( double yMax ) 164 { 165 this.yMax = yMax; 166 } 167 168 169 172 public double getyMin() 173 { 174 return yMin; 175 } 176 177 178 181 public void setyMin( double yMin ) 182 { 183 this.yMin = yMin; 184 } 185 186 187 190 public String toString() 191 { 192 StringBuffer s= new StringBuffer ( 60 ); 193 s.append( this.getClass().getName() ); 194 s.append( ": xMin= " + super.getMinValue() ); 195 s.append( " xMax= " + super.getMaxValue() ); 196 s.append( " yMin= " + this.yMin ); 197 s.append( " yMax= " + this.yMax ); 198 return s.toString(); 199 } 200 201 202 221 } 222 | Popular Tags |