Annotation of OpenXM/src/OpenMath/PolyCalc.java, Revision 1.1
1.1 ! tam 1: import JP.ac.kobe_u.math.tam.OpenXM.*;
! 2: import java.applet.*;
! 3: import java.awt.*;
! 4:
! 5: class PolyCalc extends Applet{
! 6: private String host;
! 7: int ControlPort,DataPort;
! 8: private OpenXM oxm;
! 9: private Button random1_button,random2_button;
! 10: private Button mul_button,remainder_button,swap_button,set_button;
! 11: private TextField poly1,poly2;
! 12: private TextArea textarea;
! 13: //private Text
! 14:
! 15: PolyCalc(String host,int ControlPort,int DataPort){
! 16: this.host = host;
! 17: this.ControlPort = ControlPort;
! 18: this.DataPort = DataPort;
! 19: }
! 20:
! 21: public void init(){
! 22: GridBagLayout gridbag = new GridBagLayout();
! 23: GridBagConstraints c = new GridBagConstraints();
! 24:
! 25: //setFont();
! 26: setLayout(gridbag);
! 27:
! 28: c.fill = GridBagConstraints.BOTH;
! 29:
! 30: textarea = new TextArea();
! 31: textarea.setEditable(false);
! 32: c.gridwidth = GridBagConstraints.REMAINDER;
! 33: gridbag.setConstraints(textarea,c);
! 34: c.gridwidth = 1;
! 35: add(textarea);
! 36:
! 37: {
! 38: Label label = new Label("poly 1:");
! 39: gridbag.setConstraints(label,c);
! 40: add(label);
! 41: }
! 42:
! 43: random1_button = new Button("generate random polynomial");
! 44: gridbag.setConstraints(random1_button,c);
! 45: add(random1_button);
! 46:
! 47: mul_button = new Button("poly1 * poly2");
! 48: c.gridwidth = GridBagConstraints.REMAINDER;
! 49: gridbag.setConstraints(mul_button,c);
! 50: c.gridwidth = 1;
! 51: add(mul_button);
! 52:
! 53: poly1 = new TextField(20);
! 54: c.gridwidth = 2;
! 55: gridbag.setConstraints(poly1,c);
! 56: c.gridwidth = 1;
! 57: add(poly1);
! 58:
! 59: remainder_button = new Button("poly1 % poly2");
! 60: //c.gridx = 2;
! 61: //c.weightx = 0.0;
! 62: gridbag.setConstraints(remainder_button,c);
! 63: add(remainder_button);
! 64:
! 65: swap_button = new Button("swap poly1 & poly2");
! 66: c.gridwidth = GridBagConstraints.REMAINDER;
! 67: gridbag.setConstraints(swap_button,c);
! 68: c.gridwidth = 1;
! 69: add(swap_button);
! 70:
! 71: {
! 72: Label label = new Label("poly 2:");
! 73: gridbag.setConstraints(label,c);
! 74: add(label);
! 75: }
! 76:
! 77: random2_button = new Button("generate random polynomial");
! 78: gridbag.setConstraints(random2_button,c);
! 79: add(random2_button);
! 80:
! 81: set_button = new Button("poly1 <= poly2");
! 82: c.gridwidth = GridBagConstraints.REMAINDER;
! 83: gridbag.setConstraints(set_button,c);
! 84: c.gridwidth = 1;
! 85: add(set_button);
! 86:
! 87: poly2 = new TextField();
! 88: c.gridwidth = 2;
! 89: gridbag.setConstraints(poly2,c);
! 90: c.gridwidth = 1;
! 91: add(poly2);
! 92: }
! 93:
! 94: public void start(){
! 95: textarea.append("Connecting to "+ host
! 96: +"("+ ControlPort +","+ DataPort +")\n");
! 97:
! 98: try{
! 99: oxm = new OpenXM("localhost",1200,1300);
! 100: }catch(java.io.IOException e){
! 101: textarea.append("failed.\n");
! 102: stop();
! 103: return;
! 104: }
! 105: textarea.append("Connected.\n");
! 106: }
! 107:
! 108: public static void main(String argv[]){
! 109: Frame frame = new Frame("Polynomial Calculator");
! 110: Applet applet;
! 111: String host = "localhost";
! 112: int DataPort = 1300, ControlPort = 1200;
! 113:
! 114: for(int i=0;i<argv.length;i++){
! 115: if(argv[i].equals("-h")){
! 116: System.out.println("");
! 117: System.exit(0);
! 118: }else if(argv[i].equals("-host")){
! 119: host = argv[++i];
! 120: }else if(argv[i].equals("-data")){
! 121: DataPort = Integer.valueOf(argv[++i]).intValue();
! 122: }else if(argv[i].equals("-control")){
! 123: ControlPort = Integer.valueOf(argv[++i]).intValue();
! 124: }else{
! 125: System.err.println("unknown option :"+ argv[i]);
! 126: System.exit(1);
! 127: }
! 128: }
! 129: applet = new PolyCalc(host,ControlPort,DataPort);
! 130:
! 131: applet.init();
! 132: frame.add("Center",applet);
! 133: frame.pack();
! 134: frame.setSize(frame.getPreferredSize());
! 135: frame.show();
! 136: applet.start();
! 137: }
! 138: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>