import sk.uniba.fmph.pocprak.ioutils.*;
import sk.uniba.fmph.pocprak.simplegraphics.*;
/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class ObezitaScatterPlot {
  public double[] height= new double[5000];
  public double[] weight= new double[5000];
  public int nevent = 0;
  public ObezitaScatterPlot() throws Exception{
    super();
    double[] data;
    InTextFile in = InTextFile.open("obezita.txt");
    while (true){
      data = in.readlnDoubles();
      if(data==null) break;
      if(data.length==2){
        height[nevent]=data[0];
        weight[nevent]=data[1];
        nevent++;
      }
    }
    in.close();
  }
  public void MakePlot(){
      GrGraphics gr=SimpleGraphics.CreateGrEnvironment();
      gr.setBasePoint(gr.LL);
      gr.setUserFrameSize(0.,0.,250.,150.);
      GrAxisX xaxis = new GrAxisX(0.D,250.D,0.D);
      xaxis.setLTicks(0.0D,50.D);
      xaxis.draw(gr);
      GrAxisY yaxis = new GrAxisY(0.D,150.D,0.D);
      yaxis.setLTicks(0.0D,50.D);
      yaxis.draw(gr);
      for(int i = 0;i<nevent;i++){
        gr.drawPoint(height[i],weight[i]);
      }
      gr.repaint();
      gr.drawLine2D(140.,40.,220.,120.);
      gr.repaint();
  }


  public static void main(String[] args) throws Exception{
    ObezitaScatterPlot obezitascatterplot = new ObezitaScatterPlot();
    obezitascatterplot.MakePlot();
  }
}
