/**************** azmandel03 *************************************************/ /**************** azmandel03 //Hajime Satoh 2002-6/08,6/12,6/13,6/14,6/21 ******/ /**************** azmandel03 *************************************************/ //プログラム名称= azmandel03.java /***************************************************************************/ import java.applet.Applet; import java.awt.*; import java.awt.event.*; /***************************************************************************/ public class azmandel03 extends Applet implements //AdjustmentListener, ActionListener, MouseListener,MouseMotionListener{ int M1x=0,M1y=0,M2x=0,M2y=0; // Mouse Scrollbar scrX; Scrollbar scr; // Scrollbar Button button_input; // Button Color [] C={Color.red,Color.pink,Color.magenta, Color.blue,Color.cyan,Color.green, Color.yellow,Color.gray}; int colorLen=C.length; // 色の数 double rs=-2.0,re=0.5,is=-1.2,ie=1.2; double rs0=-2.0,re0=0.5,is0=-1.2,ie0=1.2; double rs9=0.0,re9=0.0,is9=0.0,ie9=0.0; double rd,id; double xn,xn1,yn,yn1,A,B; double aa,bb; double a=-2.0,b=0.5,c=-1.2,d=1.2; double a0=-2.0,b0=0.5,c0=-1.2,d0=1.2; double a00=-2.0,b00=0.5,c00=-1.2,d00=1.2; int mm=1; int width=720,height=720,n=50,nn; int xx=0,yy=0; int limit,limit0=50,m=5,m0=5,mousepressed=0,sw1st=0; int limit00=50,m00=5; TextField txf0;TextField txf1;TextField txf2; // TextField txf3;TextField txf4;TextField txf5; TextField txf6; // /*******************************************************************/ //初期値を表示する。ボタン入力を待つ。 /********************************************************************/ public void init() { button_input = new Button("Draw →"); add(button_input); // 入力ボタン add(new Label("Left="));txf1=new TextField(""+a0);txf1.setSize(50,20);add(txf1); add(new Label("Right="));txf2=new TextField(""+b0);txf2.setSize(50,20);add(txf2); add(new Label("Down="));txf3=new TextField(""+c0);txf3.setSize(50,20);add(txf3); add(new Label("Up="));txf4=new TextField(""+d0);txf4.setSize(50,20);add(txf4); add(new Label("Calc.="));txf5=new TextField(""+limit0);txf5.setSize(50,20);add(txf5); add(new Label("Magnify="));txf6=new TextField(""+m0);txf6.setSize(50,20);add(txf6); /****/ addMouseListener(this); // Mouse addMouseMotionListener(this); // Mouse button_input.addActionListener(this); // Button } // end init /***************************************************************************/ // イベント処理(押されたボタン種別の判定、入力データをスクリーンから読込む) // その後、計算及び作図ルーチンに制御を渡す。 /***************************************************************************/ // public void adjustmentValueChanged(AdjustmentEvent eee) { // repaint(); } //end adjustmentValueChanged /*****************************************************************************/ public void actionPerformed(ActionEvent e) { if (e.getSource() == button_input) { // どのボタンか? 入力です。 nn=0;mm=1; a=(Double.valueOf(txf1.getText())).doubleValue(); b=(Double.valueOf(txf2.getText())).doubleValue(); c=(Double.valueOf(txf3.getText())).doubleValue(); d=(Double.valueOf(txf4.getText())).doubleValue(); limit=Integer.parseInt(txf5.getText()); m=Integer.parseInt(txf6.getText()); n=limit; rs=a;re=b;is=c;ie=d; rs0=a;re0=b;is0=c;ie0=d; repaint(); } // end of button-input } //end actionPerformed /**************************************************************************/ public void mouseReleased(MouseEvent mmm){ nn=nn+1;mm=mm*m; rs=rs0+(re0-rs0)*((double)M1x/(double)width-1.0/(2.0*(double)m)); re=rs0+(re0-rs0)*((double)M1x/(double)width+1.0/(2.0*(double)m)); is=ie0-(ie0-is0)*((double)M1y/(double)height+1.0/(2.0*(double)m)); ie=ie0-(ie0-is0)*((double)M1y/(double)height-1.0/(2.0*(double)m)); rs0=rs;re0=re;is0=is;ie0=ie; repaint(); } // end of mousePressed public void mypaint(){Graphics ggg=getGraphics(); ggg.setColor(Color.white); // 表示窓の色*の設定 ggg.drawRect(M1x-72,(720-M1y)-72,144,144); // 拡大領域を表示します } public void mouseClicked(MouseEvent mmm){ M1x=mmm.getX();M1y=mmm.getY();M1y=(360-M1y)+360;mypaint();} public void mousePressed(MouseEvent mmm){ M1x=mmm.getX();M1y=mmm.getY();M1y=(360-M1y)+360;mypaint();} public void mouseMoved(MouseEvent mmm){} public void mouseEntered(MouseEvent mmm){} public void mouseDragged(MouseEvent mmm){} public void mouseExited(MouseEvent mmm){} /***************************************************************************/ //================= azmandel03 計算式 及び計算結果の表示 ================= /***************************************************************************/ public void paint( Graphics g ) { /***************************************************************************/ // rs,re,is,ie を事前に求めておき、複素関数への入力とする。 //f(z)=z2+C で定義される数列を考える。初期値は、z0=(x0=0,y0=0)とする。 //C=A+B・i とする。この複素平面C(A,B)で、複素関数f(z)の収束・発散を見る。 // 領域内で位置を順次移動し(AおよびBを順次変えて)収束・発散を見る。 //zn=Xn+Yn・i とする。 //zn1=zn2+C  数列を順次計算する。 // =(Xn2-Yn2+A)+(2Xn・Yn+B)・i //xn1=Xn2-Yn2+A // f(z)=z2+C の実部 //yn1=2Xn・Yn+B // f(z)=Z2+C の虚部 /***************************************************************************/ g.setColor(Color.black); // 収束点の色*の設定 g.fillRect(0,100,width,height); // 設定した色*で塗り潰す rd=(re-rs)/(double)width; // 実部 A の増分 id=(ie-is)/(double)height; // 虚部 B の増分 for(int xx=0;xx04 ) { // 収束・発散の判定 g.setColor(C[L%colorLen]); g.drawLine(xx,yy,xx,yy); // 発散点の彩色 break; } xn=xn1; yn=yn1; } }} //ii //rr g.setColor(Color.yellow); // 表示窓の色*の設定 g.fillRect(20,30,680,50); g.setColor(Color.black); // rs9=(Math.round(rs*100000.0))/100000.0; re9=(Math.round(re*100000.0))/100000.0; is9=(Math.round(is*100000.0))/100000.0; ie9=(Math.round(ie*100000.0))/100000.0; g.drawString("starting Value:",50,40); g.drawString("A = "+rs9,70,55); g.drawString("B = "+is9,70,75); A=(Math.round(A*100000.0))/100000.0; B=(Math.round(B*100000.0))/100000.0; g.drawString("Ending Value:",180,40); g.drawString("A = "+A,200,55); g.drawString("B = "+B,200,75); g.drawString("Magnification:",320,40); g.drawString("# of Magni.Oper = "+nn,340,55); g.drawString("Magnified = "+mm+" times",340,75); g.drawString("Domain:",480,40); g.drawString("Left = "+rs9+", Right = "+re9,500,55); g.drawString("Down = "+is9+", Up = "+ie9,500,75); }} //end paint //end azmandel03 //System.out.println(xn1);System.out.println(yn1); //try {Thread.sleep(1000);}catch(InterruptedException ee) {} /******************End of azmandel03 ******************************/ /******************End of azmandel03 ******************************/