krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart RegressionChart.java,1.3,1.4
"Nathaniel G. Auvil" <[email protected]> Thu, 28 Oct 2004 21:03:02 +0000
| Newsgroups | gmane.comp.krysalis.jcharts.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29471/src/java/org/krysalis/jcharts/axisChart
Modified Files:
RegressionChart.java
Log Message:
Index: RegressionChart.java
===================================================================
RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/RegressionChart.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** RegressionChart.java 27 Oct 2004 20:44:13 -0000 1.3
--- RegressionChart.java 28 Oct 2004 21:02:59 -0000 1.4
***************
*** 48,53 ****
/**************************************************************************************
*
! * @author Nathan Feger
* @version $Id$
************************************************************************************/
--- 48,54 ----
/**************************************************************************************
+ * Regression Chart
*
! * @author Nathan Feger, Nathaniel Auvil
* @version $Id$
************************************************************************************/
***************
*** 64,72 ****
double Sxx, Sxy, Syy;
double a, b; //regression coefficients
! ArrayList v = new ArrayList(); //vector of points
! ArrayList residuals = new ArrayList(); //vector of residuals
!
private double figureY( YAxis yAxis, double num )
{
--- 65,78 ----
double Sxx, Sxy, Syy;
double a, b; //regression coefficients
! ArrayList v = new ArrayList();
! ArrayList residuals = new ArrayList();
+ /**************************************************************************************
+ *
+ * @param yAxis
+ * @param num
+ * @return
+ *************************************************************************************/
private double figureY( YAxis yAxis, double num )
{
***************
*** 91,95 ****
//---cache the computed values
! float[][] yAxisCoordinates = new float[iAxisChartDataSet.getNumberOfDataSets()][iAxisChartDataSet.getNumberOfDataItems()];
//---need this for image map calculation
--- 97,101 ----
//---cache the computed values
! float[][] yAxisCoordinates = new float[ iAxisChartDataSet.getNumberOfDataSets() ][ iAxisChartDataSet.getNumberOfDataItems() ];
//---need this for image map calculation
***************
*** 102,111 ****
for( int i = 0; i < yAxisCoordinates.length; i++ )
{
if( iAxisChartDataSet.getValue( i, j ) != Double.NaN )
{
! yAxisCoordinates[i][j] = axisChart.getYAxis().computeAxisCoordinate( axisChart.getYAxis().getOrigin(),
iAxisChartDataSet.getValue( i, j ),
axisChart.getYAxis().getScaleCalculator().getMinValue() );
!
addLoc( new Loc( j, iAxisChartDataSet.getValue( i, j ) ) );
--- 108,118 ----
for( int i = 0; i < yAxisCoordinates.length; i++ )
{
+ //TODO how does this affect things? Need to test Double.NaN
if( iAxisChartDataSet.getValue( i, j ) != Double.NaN )
{
! /* yAxisCoordinates[i][j] = axisChart.getYAxis().computeAxisCoordinate( axisChart.getYAxis().getOrigin(),
iAxisChartDataSet.getValue( i, j ),
axisChart.getYAxis().getScaleCalculator().getMinValue() );
! */
addLoc( new Loc( j, iAxisChartDataSet.getValue( i, j ) ) );
***************
*** 124,131 ****
axisChart.getImageMap().addImageMapArea( new CircleMapArea( xMapCoordinate,
! yAxisCoordinates[i][j],
! iAxisChartDataSet.getValue( i, j ),
! label,
! iAxisChartDataSet.getLegendLabel( i ) ) );
}
}
--- 131,138 ----
axisChart.getImageMap().addImageMapArea( new CircleMapArea( xMapCoordinate,
! yAxisCoordinates[i][j],
! iAxisChartDataSet.getValue( i, j ),
! label,
! iAxisChartDataSet.getLegendLabel( i ) ) );
}
}
***************
*** 139,187 ****
}
- // AffineTransform originalTransform = null;
- // double[] cornerXOffset = null;
- // double[] cornerYOffset = null;
-
//---check if there are any points to display
if( lineChartProperties.getShapes() != null )
{
- //---when centering the shapes on the points, need x and y offset to do this
- // cornerXOffset = new double[iAxisChartDataSet.getNumberOfDataSets()];
- // cornerYOffset = new double[iAxisChartDataSet.getNumberOfDataSets()];
-
- //---get the original transform so can reset it.
- // originalTransform = g2d.getTransform();
-
- // Rectangle2D rectangle;
-
//LOOP
for( int i = 0; i < iAxisChartDataSet.getNumberOfDataSets(); i++ )
{
! // if( lineChartProperties.getShapes()[i] != null )
! {
! // rectangle = lineChartProperties.getShapes()[i].getBounds2D();
! // cornerXOffset[i] = rectangle.getWidth() / 2;
! // cornerYOffset[i] = rectangle.getHeight() / 2;
!
! ArrayList v = regress();
! // round to 5 places
! double yoffset = (Math.round( 1.0E5 * a )) * 1.0E-5;
! double slope = (Math.round( 1.0E5 * b )) * 1.0E-5;
! g2d.setPaint( iAxisChartDataSet.getPaint( i ) );
! //g2d.fill( lineChartProperties.getShapes()[ i ] );
! g2d.setStroke( lineChartProperties.getLineStrokes()[i] );
! Line2D.Double line = new Line2D.Double( axisChart.getXAxis().getTickStart(),
! figureY( axisChart.getYAxis(), (yoffset + slope * 0) ),
! axisChart.getXAxis().getTickStart()
! + axisChart.getXAxis().getScalePixelWidth() * (v.size()-2),
! figureY( axisChart.getYAxis(), (yoffset + slope * v.size()) ) );
! //g2d.fill( line );
! g2d.draw( line );
! // g2d.setTransform( originalTransform );
! }
}
}
--- 146,170 ----
}
//---check if there are any points to display
if( lineChartProperties.getShapes() != null )
{
//LOOP
for( int i = 0; i < iAxisChartDataSet.getNumberOfDataSets(); i++ )
{
! ArrayList v = regress();
! // round to 5 places
! double yoffset = (Math.round( 1.0E5 * a )) * 1.0E-5;
! double slope = (Math.round( 1.0E5 * b )) * 1.0E-5;
! g2d.setPaint( iAxisChartDataSet.getPaint( i ) );
! g2d.setStroke( lineChartProperties.getLineStrokes()[i] );
! Line2D.Double line = new Line2D.Double( axisChart.getXAxis().getTickStart(),
! figureY( axisChart.getYAxis(), yoffset ),
! axisChart.getXAxis().getTickStart() + axisChart.getXAxis().getScalePixelWidth() * (v.size()-1),
! figureY( axisChart.getYAxis(), (yoffset + slope * v.size()) ) );
! g2d.draw( line );
}
}
***************
*** 189,192 ****
--- 172,179 ----
+ /************************************************************************************
+ *
+ * @return
+ ************************************************************************************/
private ArrayList regress()
{
***************
*** 201,204 ****
--- 188,192 ----
a = (sumy - b * sumx) / n;
+ //LOOP
for( int i=0; i < v.size(); i++ )
{
***************
*** 213,216 ****
--- 201,208 ----
+ /***************************************************************************************
+ *
+ * @param numLocs
+ **************************************************************************************/
private void calculate( int numLocs )
{
***************
*** 222,225 ****
--- 214,221 ----
+ /***************************************************************************************
+ *
+ * @param p
+ **************************************************************************************/
private void addLoc( Loc p )
{
-------------------------------------------------------
This Newsletter Sponsored by: Macrovision
For reliable Linux application installations, use the industry's leading
setup authoring tool, InstallShield X. Learn more and evaluate
today. http://clk.atdmt.com/MSI/go/ins0030000001msi/direct/01/