[BACK]Return to PolyCalc.java CVS log [TXT][DIR] Up to [local] / OpenXM / src / OpenMath

Annotation of OpenXM/src/OpenMath/PolyCalc.java, Revision 1.3

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>