 class timeplot_n extends Thread
 {int n,nx,nt;
 double x[][][];
 double y[][][];
 double dt;
 double dt_real;
 double xmin,xmax,ymin,ymax;
 Plot p1;
 Plot2D pp; 
 String plotheading;
 String xheading;
 String yheading;
 String Framename;
 public void timeplot_n(double xi[][][],double yi[][][],double dti,double dt_reali,String Framename,String plotheading,String xheading,String yheading)
 {timeplot(xi,yi,dti,dt_reali,Framename,plotheading,xheading,yheading);}
 public void timeplot_n(double xi[][][],double yi[][][],double dti,double dt_reali)
 {timeplot(xi,yi,dti,dt_reali,"Time dependent plot","z=f(x,t)","x","y");}
  public void timeplot_n(double xi[][][],double yi[][][],double dti)
 {timeplot(xi,yi,dti,dti,"Time dependent plot","z=f(x,t)","x","y");}
 public void timeplot(double xi[][][],double yi[][][],double dti,double dt_reali,String Framename,String plotheading,String xheading,String yheading)
 {
 nx=xi[0][0].length;nt=xi[0].length;n=xi.length;dt=dti;
 dt_real=dt_reali;
 xmin=9.99e50;
 xmax=-9.99e50;
 ymin=9.99e50;
 ymax=-9.99e50;
 x=new double[n][nt][nx];
 y=new double[n][nt][nx];
 for(int k=0;k<n;k++)
 {
 for(int i=0;i<nt;i++)
 {for(int j=0;j<nx;j++)
   {x[k][i][j]=xi[k][i][j];
    y[k][i][j]=yi[k][i][j];
   if(x[k][i][j]<xmin) xmin=x[k][i][j];
   if(x[k][i][j]>xmax) xmax=x[k][i][j];
   if(y[k][i][j]<ymin) ymin=y[k][i][j];
   if(y[k][i][j]>ymax) ymax=y[k][i][j];
   }
 }
 }
 p1=new Plot(x[0][0],y[0][0]);
 pp=new Plot2D(p1); 
 this.plotheading=plotheading;
 this.xheading=xheading;
 this.yheading=yheading;
 this.Framename=Framename;
 pp.setPlabel(plotheading);
 pp.setXlabel(xheading);
 pp.setYlabel(yheading);
 FrameGraphic.plot(Framename,pp);
 }
 
 public timeplot_n(fi_xt f,double x0,double xn,double dx,double t0,double tn,double dti,double dt_reali,String Framename,String plotheading,String xheading,String yheading)
 {timeplot(f,x0,xn,dx,t0,tn,dti,dt_reali,Framename,plotheading,xheading,yheading);}
  public timeplot_n(fi_xt f,double x0,double xn,double dx,double t0,double tn,double dti,double dt_reali)
 {timeplot(f,x0,xn,dx,t0,tn,dti,dt_reali,"Time dependent plot","z=f(x,t)","x","y");}
   public timeplot_n(fi_xt f,double x0,double xn,double dx,double t0,double tn,double dti)
 {timeplot(f,x0,xn,dx,t0,tn,dti,dti,"Time dependent plot","z=f(x,t)","x","y");}
 
 public void timeplot(fi_xt f,double x0,double xn,double dx,double t0,double tn,double dti,double dt_reali,String Framename,String plotheading,String xheading,String yheading)
 {dt=dti;
  dt_real=dt_reali;
  nx=(int)((xn-x0)/dx+1);
  nt=(int)((tn-t0)/dt_real+1);
  double a[]=f.func(0.0,0.0);
  n=a.length;
 xmin=x0;
 xmax=xn;
 ymin=9.99e50;
 ymax=-9.99e50;
 x=new double[n][nt][nx];
 y=new double[n][nt][nx];
 double xx=0;
 double t;
 for(int i=0;i<nt;i++)
 {for(int j=0;j<nx;j++)
   {xx=x0+dx*j;
   t=t0+dt_real*i;
   a=f.func(xx,t);
   for(int k=0;k<n;k++)
    {x[k][i][j]=xx;
     y[k][i][j]=a[k];
     if(y[k][i][j]<ymin) ymin=y[k][i][j];
     if(y[k][i][j]>ymax) ymax=y[k][i][j];
    }
   }
 }
  p1=new Plot(x[0][0],y[0][0]);
  for(int k=1;k<n;k++)
  p1.addData(x[k][0],y[k][0]);
  pp=new Plot2D(p1); 
  this.plotheading=plotheading;
 this.xheading=xheading;
 this.yheading=yheading;
  this.Framename=Framename;
 pp.setPlabel(plotheading);
 pp.setXlabel(xheading);
 pp.setYlabel(yheading);
 FrameGraphic.plot(Framename,pp);
 }
 
  public void timeplot(f_xt f,double x0,double xn,double dx,double t0,double tn,double dti,double dt_reali)
  {String Framename="Zamana bağlı grafik";
   String plotheading="z=f(x,t)";
   String xheading="x";
   String yheading="y";
   timeplot(f,x0,xn,dx,t0,tn,dti,dt_reali,Framename,plotheading,xheading,yheading);
  }
  public timeplot_n(f_xt f,double x0,double xn,double dx,double t0,double tn,double dti,double dt_reali,String Framename,String plotheading,String xheading,String yheading)
 {timeplot(f,x0,xn,dx,t0,tn,dti,dt_reali,Framename,plotheading,xheading,yheading);}
  public timeplot_n(f_xt f,double x0,double xn,double dx,double t0,double tn,double dti,double dt_reali)
 {timeplot(f,x0,xn,dx,t0,tn,dti,dt_reali,"Time dependent plot","z=f(x,t)","x","y");}
   public timeplot_n(f_xt f,double x0,double xn,double dx,double t0,double tn,double dti)
 {timeplot(f,x0,xn,dx,t0,tn,dti,dti,"Time dependent plot","z=f(x,t)","x","y");}
   
 public void timeplot(f_xt f,double x0,double xn,double dx,double t0,double tn,double dti,double dt_reali,String Framename,String plotheading,String xheading,String yheading)
 {dt=dti;
  dt_real=dt_reali;
  nx=(int)((xn-x0)/dx+1);
  nt=(int)((tn-t0)/dt_real+1);
  double a[]=new double[1];
  n=1;
 xmin=x0;
 xmax=xn;
 ymin=9.99e50;
 ymax=-9.99e50;
 x=new double[n][nt][nx+1];
 y=new double[n][nt][nx+1];
 double xx=0;
 double t;
 for(int i=0;i<nt;i++)
 {for(int j=0;j<=nx;j++)
   {xx=x0+dx*j;
   t=t0+dt_real*i;
   a[0]=f.func(xx,t);
   for(int k=0;k<n;k++)
    {x[k][i][j]=xx;
     y[k][i][j]=a[k];
     if(y[k][i][j]<ymin) ymin=y[k][i][j];
     if(y[k][i][j]>ymax) ymax=y[k][i][j];
    }
   }
 }
  p1=new Plot(x[0][0],y[0][0]);
 pp=new Plot2D(p1); 
  this.plotheading=plotheading;
 this.xheading=xheading;
 this.yheading=yheading;
  this.Framename=Framename;
 pp.setPlabel(plotheading);
 pp.setXlabel(xheading);
 pp.setYlabel(yheading);
 FrameGraphic.plot(Framename,pp);
 }
 public timeplot_n(double yi[][][],double x0,double xn,double dti,double dt_reali)
 {nx=yi[0].length;nt=yi.length+1;
 dt=dti;
 dt_real=dt_reali;
 xmin=x0;
 xmax=xn;
 ymin=9.99e50;
 ymax=-9.99e50;
 x=new double[n][nt][nx+1];
 y=new double[n][nt][nx+1];
 double dx=(xn-x0)/(nx-1);
 for(int k=0;k<n;k++)
 {
 for(int i=0;i<nt;i++)
 {for(int j=0;j<=nx;j++)
   {x[k][i][j]=x0+dx*j;
    y[k][i][j]=yi[k][i][j];
    if(y[k][i][j]<ymin) ymin=y[k][i][j];
    if(y[k][i][j]>ymax) ymax=y[k][i][j];
    }
 }
 }
  p1=new Plot(x[0][0],y[0][0]);
 pp=new Plot2D(p1);
 this.plotheading=plotheading;
 this.xheading=xheading;
 this.yheading=yheading; 
 this.Framename=Framename;
 pp.setPlabel(plotheading);
 pp.setXlabel(xheading);
 pp.setYlabel(yheading);
 FrameGraphic.plot(Framename,pp);
 }
 
 public void run()
 {
 //pp.plot();
 for(int i=0;i<nt;i++)
 try {
 pp.replaceData(x[0][i],y[0][i],0);
  int t=(int)(1000*dt);
 for(int k=1;k<n;k++)
 {   //Thread.sleep(t);
	 pp.replaceData(x[k][i],y[k][i],k);
 }
 pp.setPlabel(plotheading+" t = "+i*dt_real+" s");
 pp.setMinMax(xmin,xmax,ymin,ymax);
 Thread.sleep(t); 
 pp.repaint();
     }
 catch(InterruptedException e)
 {System.err.println(e.toString());}
 }
 
 public void plot() {start();}
 }