import java.awt.*;
public class graafik1 extends abiapl{
 double p, t, p0=1000, k=0.13;
Image pilt;
Graphics piltg;
valik kv=new valik(this, "kv", -1, k, 10, 0.01), 
      p0v=new valik(this, "p0v", 0, 1000, 100000, 10);
Panel pn = new Panel();
Panel pt[]=new Panel[4];
Label l1=new Label("    P0="), l2=new Label("    k=");
public void init(){
 pilt=createImage(400, 300);
 piltg=pilt.getGraphics();
 pn.setLayout(new GridLayout(1,4));
for(int i=0; i<4; i++){pt[i]=new Panel(); pt[i].setLayout(new BorderLayout());}
pt[0].add("West", l1);
pt[0].add("Center",p0v);
pn.add(pt[0]);
pt[1].add("West", l2);
 pt[1].add("Center",kv);
pn.add(pt[1]);
 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);}
piltg.drawString("t", 200, 280);
for(int i=5000; i<30000; i+=5000){piltg.drawString(Integer.toString(i), 5, 
  250-i/100);}
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("kv"))k=vl.vaartus;
 if(vl.ise.equals("p0v"))p0=vl.vaartus;
 joonis();
}


void arvuta(){p=p0*Math.exp(k*t);}
public void paint(Graphics g){
 g.drawImage(pilt, 0, 0, this);
}
public void update(Graphics g){paint(g);}
}