package hep.aida.ref.plotter.adapter;
import jas.hist.*;
import hep.aida.*;

/**
 *
 * @author  manj
 * @version $Id: AIDAProfileAdapter2D.java,v 1.3 2004/02/19 16:37:41 turri Exp $
 */
class AIDAProfileAdapter2D extends AIDAProfileAdapter implements Rebinnable2DHistogramData, HasStatistics
{
    AIDAProfileAdapter2D(IProfile2D profile)
   {
      super(profile);
      this.profile=profile;
   }
   public double[][][] rebin(int xbins, double xmin, double xmax,
                             int ybins, double ymin, double ymax,
                             boolean wantErrors, boolean hurry, boolean overflow)
   {
      setValid();
      double[][][] data=new double [2][profile.xAxis().bins()][profile.yAxis().bins()];
      for(int i=0;i<profile.xAxis().bins();i++)
         for(int j=0;j<profile.yAxis().bins();j++)
         {
            data[0][i][j]=profile.binHeight(i,j);
            if (Double.isInfinite(data[0][i][j])) data[0][i][j] = Double.NaN;
            if ( errorMode() == USE_ERROR_ON_MEAN ) data[1][i][j]=profile.binError(i,j);
            else data[1][i][j]=profile.binRms(i,j);
         }
      return data;
   }
   public double getXMin()
   {
      return profile.xAxis().lowerEdge();
   }
   public double getXMax()
   {
      return profile.xAxis().upperEdge();
   }
   public double getYMin()
   {
      return profile.yAxis().lowerEdge();
   }
   public double getYMax()
   {
      return profile.yAxis().upperEdge();
   }
   public int getXBins()
   {
      return profile.xAxis().bins();
   }
   public int getYBins()
   {
      return profile.yAxis().bins();
   }
   public boolean isRebinnable()
   {
      return false;
   }
   public int getXAxisType()
   {
      return DOUBLE;
   }
   public int getYAxisType()
   {
      return DOUBLE;
   }
   public String[] getXAxisLabels()
   {
      return null;
   }
   public String[] getYAxisLabels()
   {
      return null;
   }
   public String getTitle()
   {
      return profile.title();
   }
   public Statistics getStatistics()
   {
      return new AIDAProfileStatistics2D(profile);
   }
   
   private IProfile2D profile;
}