// pump2c.java(羽根車2円弧法) // import java.applet.Applet; import java.awt.*; import java.io.*; import java.lang.*; import java.net.URL; import java.util.*; import java.applet.*; import java.awt.event.*; public class pump2c extends Applet { TextArea ta2; TextField tf1,tf2,tf3,tf4,tf5,tf6; Button b; // Button b = new Button(""); Choice mychoice; double x_max; double y_max; double x_min; double y_min; double d1; double d2; double beta1; double beta2; double xp1; double yp1; double xp2; double yp2; double xp3; double yp3; double xp4; double yp4; double xp5; double yp5; double xp6; double yp6; double xp7; double yp7; double xp8; double yp8; double xp9; double yp9; double xp10; double yp10; double radius1; double radius2; double a1; double b1; double a2; double b2; double a3; double b3; double th; double th1; double th2; int alpha1; int alpha2; int alpha11; int alpha22; int alpha3; int m; boolean drawn = false; double angle; double xx; double yy; Labo_Util labo; // 初めに一度だけ実行するメソッド public void init() { setLayout(new FlowLayout(FlowLayout.LEFT)); ta2 = new TextArea("",10,60); tf1 = new TextField("100"); tf2 = new TextField("200"); tf3 = new TextField("14"); tf4 = new TextField("22.5"); tf5 = new TextField("50"); tf6 = new TextField("110"); ta2.setEditable(false); ta2.setBackground(new Color(255,255,232)); mychoice = new Choice(); mychoice.setBackground(Color.white); mychoice.addItem("6"); mychoice.addItem("7"); mychoice.addItem("8"); mychoice.addItem("9"); mychoice.addItem("10"); mychoice.addItem("11"); mychoice.addItem("12"); add(mychoice); add(b=new Button("")) { drawn = true; repaint(); } } return true; } */ class MyListener implements ActionListener{ public void actionPerformed(ActionEvent e) { if((e.getSource()==b)) { // d1,d2,beta1,beta2の取得 String instr1 = tf1.getText(); //テキストフィールド1よりStringをゲット d1 = labo.String2double(instr1); String instr2 = tf2.getText(); //テキストフィールド2よりStringをゲット d2 = labo.String2double(instr2); String instr3 = tf3.getText(); //テキストフィールド3よりStringをゲット beta1 = labo.String2double(instr3); String instr4 = tf4.getText(); //テキストフィールド4よりStringをゲット beta2 = labo.String2double(instr4); String instr5 = tf5.getText(); //テキストフィールド5よりStringをゲット radius2 = labo.String2double(instr5); String instr6 = tf6.getText(); //テキストフィールド6よりStringをゲット th = labo.String2double(instr6); m=mychoice.getSelectedIndex()+6; //羽枚数をゲット // 各種計算 xp1=0; yp1=0; xp2=0; yp2=0.5*d2; xp3=-radius2*Math.sin(beta2*Math.PI/180); yp3=yp2-radius2*Math.cos(beta2*Math.PI/180); xp4=0.5*d1*Math.cos(0.5*Math.PI-th*Math.PI/180); yp4=0.5*d1*Math.sin(0.5*Math.PI-th*Math.PI/180); th1=270-beta1-th; xp5=xp4+radius2*Math.cos(th1*Math.PI/180); yp5=yp4+radius2*Math.sin(th1*Math.PI/180); xp6=0.5*(xp3+xp5); yp6=0.5*(yp3+yp5); a1=Math.tan(0.5*Math.PI-beta2*Math.PI/180); b1=0.5*d2; a2=-(xp5-xp3)/(yp5-yp3); b2=yp6-a2*xp6; xp7=(b2-b1)/(a1-a2); yp7=a2*xp7+b2; a3=(yp5-yp7)/(xp5-xp7); b3=yp7-a3*xp7; radius1=radius2+Math.sqrt(Math.pow((xp3-xp7),2)+Math.pow((yp3-yp7),2)); th2=labo.kakudo(xp5-xp7,yp5-yp7)*180/Math.PI; xp8=xp7+radius1*Math.cos(th2*Math.PI/180); yp8=yp7+radius1*Math.sin(th2*Math.PI/180); alpha1=(int)(Math.atan((yp8-yp7)/(xp8-xp7))*180/Math.PI); alpha2=(int)(Math.atan((yp2-yp7)/(xp2-xp7))*180/Math.PI); alpha11=(int)(Math.atan((yp4-yp5)/(xp4-xp5))*180/Math.PI); alpha22=(int)(Math.atan((yp8-yp5)/(xp8-xp5))*180/Math.PI); // 結果表示 ta2.replaceRange("d1 = "+String.valueOf(d1)+"\n",0,500); ta2.append("d1 = "+String.valueOf(d2)+"\n"); ta2.append("beta1 = "+String.valueOf(beta1)+"\n"); ta2.append("beta2 = "+String.valueOf(beta2)+"\n"); ta2.append("Z = "+String.valueOf(m)+"\n"); ta2.append("th = "+String.valueOf(th)+"\n"); ta2.append("R1 = "+String.valueOf(radius1)+"\n"); ta2.append("R2 = "+String.valueOf(radius2)+"\n"); // グラフ表示 // String label = o.toString(); if(e.getSource()==b) { drawn = true; repaint(); } } } } }