//****************************************************************************** // Frap1.java: Applet // //****************************************************************************** import java.applet.*; import java.awt.*; //import gjt.*; //============================================================================== // Main Class for applet diffusion // //============================================================================== public class Frap2 extends Applet { ThreeDBorder tdb = null; FrapCanvas dc = null; public void init(){ dc = new FrapCanvas(this); tdb = new ThreeDBorder(dc,5); tdb.inset(); setLayout(new BorderLayout()); add("Center",tdb); } public Insets insets(){ return new Insets(5,5,5,5); } public void start(){ dc.init(); //dc.start(); } public void stop(){ dc.stop(); } } class FrapCanvas extends Canvas implements Runnable //, StopwatchClient { // THREAD SUPPORT: // m_diffusion is the Thread object for the applet //-------------------------------------------------------------------------- Thread m_diffusion = null; Thread m_watch = null; private Applet applet; private final int NUM_PARTICLE=200; private Particle p[]; private Graphics m_g,m_r; private Image m_image,m_ready; private Dimension m_dimImage; private int Tick=0; private Color BG=new Color(153,204,204); private Point Start,UL,LR; private boolean ResetLocation=false; private boolean ImageReady=false; public Membrane m_Membrane; // diffusion Class Constructor //-------------------------------------------------------------------------- public FrapCanvas(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"; } // The init() method is called by the AWT when an applet is first loaded or // reloaded. Override this method to perform whatever initialization your // applet needs, such as initializing data structures, loading images or // fonts, creating frame windows, setting the layout manager, or adding UI // components. //-------------------------------------------------------------------------- public void init() { Dimension dim=size(); int nWidth=dim.width; int nHeight=dim.height; Start= new Point(nWidth/2,nHeight/2); UL=new Point(0,0); LR=new Point(nWidth-5,nHeight-5); //m_Membrane=new Membrane(); //m_Membrane.SetVoltage(0); //m_Membrane.addElement(0.2); //m_Membrane.addElement(0.0); int charge=1; p = new Particle[NUM_PARTICLE]; for (int i=0; iNUM_PARTICLE/2) charge=-1; p[i]= new Particle(applet,charge,Start,UL,LR); p[i].m_StdDev=5.0; p[i].BG=getBackground(); //p[i].m_Barrier=nWidth/2; //p[i].m_Membrane=m_Membrane; //p[i].m_MembraneIndex=0; //if (iNUM_PARTICLE/2) charge=-1; p[i].Init(charge,Start,UL,LR); } ResetLocation=false; } m_g.setColor(BG); m_g.fillRect(0,0,m_dimImage.width,m_dimImage.height); for (int i=0; i