/* * h5b.java - revised 19 Apr 05 - width 601, height 301 * @author jackord@kw.igs.net */ import java.applet.Applet; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class h5b extends Applet implements ActionListener { int kk=0; // Declarations String bs="Plot"; Button b=new Button(bs); public void init() { setLayout(new FlowLayout(FlowLayout.LEFT)); add(b); b.addActionListener(this); setBackground(new Color(211, 211, 211)); } public void fey(double e, double v, Graphics g) { // Feynman Algorithm double x, y, a, dx; int x1, y1, x2, y2; dx=.002; x=0; y=0; x1=0; y1=300; a=e*e*e*(x-1)*y; v=v+a*dx/2; while (((x<1) || (v*y<0)) && (x<8)) { x=x+dx; y=y+v*dx; x2=(int)(75*e*x); y2=(int)(60*(5-y*y)); g.drawLine(x1, y1, x2, y2); x1=x2; y1=y2; a=e*e*e*(x-1)*y; v=v+a*dx; } x=0; y=4/e; x1=0; y1=(int)(60*(5-y)); // Plot Classical while (y<5) { x=x+dx; y=4/e/Math.sqrt(1-x); x2=(int)(75*e*x); y2=(int)(60*(5-y)); g.drawLine(x1, y1, x2, y2); x1=x2; y1=y2; } x1=(int)(75*e); g.drawLine(x1, 0, x1, 300); } public void paint(Graphics g) { // Paint double e, vo; g.setColor(Color.black); g.drawRect(0, 0, 600, 300); g.setFont(new Font("TimesRoman", Font.PLAIN, 14)); if (kk==1) { g.setColor(Color.blue); e=2.33811; vo=6.61317; fey(e, vo, g); g.setColor(Color.magenta); e=4.08793; vo=11.5622; fey(e, vo, g); g.setColor(Color.red); e=5.5205; vo=15.61338; fey(e, vo, g); } kk=0; } public void actionPerformed(ActionEvent e) { String tst; tst=e.getActionCommand(); if (bs.equals(tst)) { kk=1; } repaint(); } }