import java.awt.*;
public class graafik3 extends abiapl{
 double p, t, p0=1500, m=0.00005;
Image pilt;
Graphics piltg;
valik mv=new valik(this, "mv", 0, m, 1, 0.000001), 
      p0v=new valik(this, "p0v", 0, p0, 100000, 10);
Panel pn = new Panel();
Panel pt[]=new Panel[4];
Label l1=new Label("    P0="), l2=new Label("    m=");
public void init(){
int i;
mv.komataga=-100;
 pilt=createImage(400, 300);
 piltg=pilt.getGraphics();
for(i=0; i<4; i++){pt[i]=new Panel(); pt[i].setLayout(new BorderLayout());}
 pn.setLayout(new GridLayout(1,2));
pt[0].add("West", l1);
 pt[0].add("Center", p0v);
pt[1].add("West",l2);
 pt[1].add("Center", mv);
for(i=0; i<2; i++){pn.add(pt[i]);}
 setLayout(new BorderLayout());
 add("South", pn);
 joonis();
}
void joonis(){
int ux, uy, vx, vy;
vx=0; t=0; arvuta();
vy=(int)(250-p/100);
piltg.setColor(Color.white);
piltg.fillRect(0, 0, 400, 400);
piltg.setColor(Color.black);
for(int i=3; i<15; i+=3){
 piltg.drawString(Integer.toString(i),i*30, 260);}
for(int i=5000; i<30000; i+=5000){piltg.drawString(Integer.toString(i), 5, 
  250-i/100);}
piltg.drawString("P", 10, 10);
piltg.drawString("t", 380, 260);
for(t=0; t<15; t+=0.1){
 arvuta();
 ux=(int)(t*30);
 uy=(int)(250-p/100);
if(uy<0) break;
 piltg.drawLine(ux, uy, vx, vy);
 vx=ux; vy=uy;
} 

repaint();}

public void seaVaartus(valik vl){
 if(vl.ise.equals("mv"))m=vl.vaartus;
 if(vl.ise.equals("p0v"))p0=vl.vaartus;
 joonis();
}


void arvuta(){p=p0/(1-p0*m*t);}
public void paint(Graphics g){
 g.drawImage(pilt, 0, 0, this);
}
public void update(Graphics g){paint(g);}
}