version 1.5, 1999/11/02 15:58:11 |
version 1.13, 2005/07/17 02:48:21 |
|
|
/** |
/** |
* $OpenXM: OpenXM/src/OpenMath/PolyCalc.java,v 1.4 1999/11/02 15:10:31 tam Exp $ |
* $OpenXM: OpenXM/src/OpenMath/PolyCalc.java,v 1.12 2000/10/11 09:34:06 ohara Exp $ |
*/ |
*/ |
|
|
import JP.ac.kobe_u.math.tam.OpenXM.*; |
/* |
|
How to try. |
|
ox -ox ox_sm1 |
|
java PolyCalc |
|
Input two polynomials in x and y and Press the grobner base button. |
|
Actions for other buttons have not yet been implemented. |
|
*/ |
|
|
|
import ORG.openxm.tam.*; |
import java.applet.*; |
import java.applet.*; |
import java.awt.event.*; |
import java.awt.event.*; |
import java.awt.*; |
import java.awt.*; |
|
|
class PolyCalc extends Applet implements ActionListener{ |
class PolyCalc extends Applet implements ActionListener,Runnable{ |
private String host = "localhost"; |
private String host = "localhost"; |
private int ControlPort = 1200,DataPort = 1300; |
private int ControlPort = 1200,DataPort = 1300; |
private OpenXM oxm; |
private OpenXM oxm; |
Line 15 class PolyCalc extends Applet implements ActionListene |
|
Line 23 class PolyCalc extends Applet implements ActionListene |
|
//private Button mul_button,remainder_button,swap_button,set_button; |
//private Button mul_button,remainder_button,swap_button,set_button; |
private TextField poly1,poly2; |
private TextField poly1,poly2; |
private TextArea textarea; |
private TextArea textarea; |
|
private Thread thread = null; |
private boolean debug = false; |
private boolean debug = false; |
//private Text |
//private Text |
|
|
Line 104 class PolyCalc extends Applet implements ActionListene |
|
Line 113 class PolyCalc extends Applet implements ActionListene |
|
c.gridwidth = 1; |
c.gridwidth = 1; |
add(poly2); |
add(poly2); |
|
|
|
button = new Button("grobner base"); |
|
button.addActionListener(this); |
|
gridbag.setConstraints(button,c); |
|
add(button); |
|
|
button = new Button("quit"); |
button = new Button("quit"); |
button.addActionListener(this); |
button.addActionListener(this); |
c.gridwidth = GridBagConstraints.REMAINDER; |
|
gridbag.setConstraints(button,c); |
gridbag.setConstraints(button,c); |
c.gridwidth = 1; |
|
add(button); |
add(button); |
} |
} |
|
|
public void actionPerformed(ActionEvent e) { |
public void run(){ // for debug |
String arg = e.getActionCommand(); |
try{ |
|
while(true){ |
|
OXmessage tmp = oxm.receive(); |
|
|
|
textarea.append("=> "+ tmp.getBody() +"\n"); |
|
Thread.yield(); |
|
} |
|
}catch(java.io.IOException e){} |
|
} |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
String arg = evt.getActionCommand(); |
|
|
debug("press \""+ arg +"\" button."); |
debug("press \""+ arg +"\" button."); |
|
|
|
if(arg.equals("quit")){ |
|
}else if(arg.equals("grobner base")){ |
|
try{ |
|
debug("poly A: "+ poly1.getText()); |
|
oxm.send(new CMO_STRING("[[("+ poly1.getText() +") ("+ poly2.getText() +")] (x,y)] gb")); |
|
oxm.send(new SM(SM.SM_executeStringByLocalParser)); |
|
oxm.send(new SM(SM.SM_popString)); |
|
}catch(java.io.IOException e){ |
|
}catch(MathcapViolation e){ |
|
} |
|
} |
/* |
/* |
if ("first".equals(arg)) { |
if ("first".equals(arg)) { |
((CardLayout)cards.getLayout()).first(cards); |
((CardLayout)cards.getLayout()).first(cards); |
Line 137 class PolyCalc extends Applet implements ActionListene |
|
Line 171 class PolyCalc extends Applet implements ActionListene |
|
+"("+ ControlPort +","+ DataPort +")\n"); |
+"("+ ControlPort +","+ DataPort +")\n"); |
|
|
try{ |
try{ |
|
/* |
|
Runtime r = Runtime.getRuntime(); |
|
|
|
r.exec("ox -ox ox_sm1"); |
|
*/ |
oxm = new OpenXM(host,ControlPort,DataPort); |
oxm = new OpenXM(host,ControlPort,DataPort); |
textarea.append("Connected.\n"); |
textarea.append("Connected.\n"); |
|
oxm.send(new CMO_STRING("[(parse) (cohom.sm1) pushfile] extension ;\n")); |
|
oxm.send(new SM(SM.SM_executeStringByLocalParser)); |
|
|
|
thread = new Thread(this); |
|
thread.start(); |
}catch(java.io.IOException e){ |
}catch(java.io.IOException e){ |
textarea.append("failed.\n"); |
textarea.append("failed.\n"); |
stop(); |
stop(); |
|
}catch(MathcapViolation e){ |
} |
} |
} |
} |
|
|
private void debug(String str){ |
private void debug(String str){ |
if(debug){ |
if(debug){ |
System.out.println(str); |
System.err.println(str); |
} |
} |
} |
} |
|
|
Line 174 class PolyCalc extends Applet implements ActionListene |
|
Line 219 class PolyCalc extends Applet implements ActionListene |
|
|
|
for(int i=0;i<argv.length;i++){ |
for(int i=0;i<argv.length;i++){ |
if(argv[i].equals("-h")){ |
if(argv[i].equals("-h")){ |
System.out.print(usage()); |
System.err.print(usage()); |
System.exit(0); |
System.exit(0); |
}else if(argv[i].equals("-debug")){ |
}else if(argv[i].equals("-debug")){ |
//debug = true; |
//debug = true; |