/* palabolic reflector fdtd 2D */ /* coded by Ikeuchi Mitsuru */ /* ver 0.0.1 2003.02.05 */ import java.awt.*; import java.awt.event.*; import java.applet.*; public class reflectorFDTD2D extends Applet implements ActionListener, AdjustmentListener, Runnable { /* -------------------------------------- set global ------ */ Button bt_reset, bt_start, bt_stop; Scrollbar scr,slm; Thread th = null; Dimension dim; Image imgOff; Graphics gOff; int sleepTime = 50; double scrVar = 20.0; int started = 1; double t = 0.0; double dt = 1.0; int NNx = 201; int NNy = 201; double Ez[][] = new double[NNx+1][NNy+1]; double Hx[][] = new double[NNx+1][NNy+1]; double Hy[][] = new double[NNx+1][NNy+1]; int metal[][] = new int[NNx+1][NNy+1]; double omega = Math.PI/16.0; double theta = 0.0; int dispWidth = 400; int dispHeight = 220; int NN = 201+1; int xpts[] = new int[NN]; int ypts[] = new int[NN]; /* ----------------------------- applet control ------ */ public void init() { resize(dispWidth+100,dispHeight); setBackground(Color.white); dim = getSize(); imgOff = createImage(dim.width,dim.height); gOff = imgOff.getGraphics(); bt_reset= new Button("reset"); add(bt_reset); bt_reset.addActionListener(this); bt_start= new Button("start"); add(bt_start); bt_start.addActionListener(this); bt_stop = new Button("stop"); add(bt_stop); bt_stop.addActionListener(this); slm= new Scrollbar(Scrollbar.HORIZONTAL,16,10,8,110); add(new Label("lambda=")); add(slm); slm.addAdjustmentListener(this); scr= new Scrollbar(Scrollbar.HORIZONTAL,20,10,0,110); add(new Label("height=")); add(scr); scr.addAdjustmentListener(this); setInitialCondition(); repaint(); } public void start() { if (th == null) { th = new Thread(this); th.start(); } } public void stop() { if (th != null) { th.stop(); th = null; } } public void actionPerformed(ActionEvent ev){ if(ev.getSource() == bt_reset){ started = 0; setInitialCondition(); offPaint(); repaint(); } else if(ev.getSource() == bt_start){ if (started==0) { started = 1; } else if (started==1) { theta = 0.0; } offPaint(); repaint(); } else if(ev.getSource() == bt_stop){ started = 0; } } public void adjustmentValueChanged(AdjustmentEvent ev){ if(ev.getSource() == slm) { omega = Math.PI/((double)slm.getValue()); repaint(); } else if(ev.getSource() == scr) { scrVar = 1.0*(double)(scr.getValue()); repaint(); } } public void run() { while (th != null) { try { timeEvolution(); offPaint(); repaint(); Thread.sleep(sleepTime); } catch (InterruptedException e) { } } } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { g.drawImage(imgOff,0,0,this); } /* ----------------------------- offPaint -------------------- */ void offPaint() { int i,j; gOff.setColor(Color.white); gOff.fillRect(0,0,dim.width,dim.height); gOff.setColor(Color.green); for(j=0; j-0.005*(j-100)*(j-100)) { metal[i][j] = 1; } } } /* for(i=97;i<104;i++) { for(j=0;j<64;j++) { metal[i][j]=1; } for(j=80;j<120;j++) { metal[i][j]=1; } for(j=136;j