//****************************************************************************** // Frap1.java: Applet // //****************************************************************************** import java.applet.*; import java.awt.*; //import gjt.Stopwatch; //import gjt.*; //============================================================================== // Main Class for applet diffusion // //============================================================================== public class Frap1 extends Applet{ ThreeDBorder tdb=null; Frap1Diff SDiff=null; public void init(){ String param; SDiff= new Frap1Diff(this); tdb = new ThreeDBorder(SDiff,5); tdb.inset(); setLayout(new BorderLayout()); add("Center",tdb); //param=getParameter("NumParticles"); //if (param != null) // SDiff.NUM_PARTICLE=Integer.parseInt(param); } public void start(){ SDiff.init(); //SDiff.start(); } public void stop(){ SDiff.stop(); } } class Frap1Diff extends Canvas implements Runnable, StopwatchClient { // THREAD SUPPORT: // m_diffusion is the Thread object for the applet //-------------------------------------------------------------------------- Thread m_diffusion = null; private Thread m_watch = null; private Applet applet; public int NUM_PARTICLE=2; private Particle p[]; private Graphics m_g; private Image m_image; private Dimension m_dimImage; private int Tick=0; private boolean Background=true; private Color BG=new Color(153,204,204); // SimpleDiffusion Class Constructor //-------------------------------------------------------------------------- public Frap1Diff(Applet applet) { this.applet=applet; } // APPLET INFO SUPPORT: // The getAppletInfo() method returns a string describing the applet's // author, copyright date, or miscellaneous information. //-------------------------------------------------------------------------- public String getAppletInfo() { return "Name: diffusion\r\n" + "Author: Joe Patlak\r\n" + "Created with Microsoft Visual J++ Version 1.0"; } //-------------------------------------------------------------------------- public void init() { Dimension dim=size(); int nWidth=dim.width; int nHeight=dim.height; Point a=new Point(nWidth/2,nHeight/2); Point b=new Point(0,0); Point c=new Point(nWidth-5,nHeight-5); int charge=1; p = new Particle[NUM_PARTICLE]; for (int i=0; iNUM_PARTICLE/2-1) charge=-1; p[i]= new Particle(applet,charge,a,b,c); p[i].m_StdDev=5.0; p[i].BG=BG; } p[1].a_string="images/anion2.gif"; p[1].m_StdDev=2.0; p[1].Init(-1,a,b,c); ResizeImage(); } //------------------------------------------------------------------------- public void destroy(){ } // diffusion Paint Handler //-------------------------------------------------------------------------- public void paint(Graphics g) { if (m_image != null){ g.drawImage(m_image,0,0,null); } } //-------------------------------------------------------------------------- public void update(Graphics g) { ResizeImage(); paint(g); for (int i=0; i