home *** CD-ROM | disk | FTP | other *** search
- package webeq3;
-
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.PrintStream;
- import webeq3.schema.Normalizer;
- import webeq3.util.OutputHandler;
-
- class TestDrive$TDButtonAdapter extends MouseAdapter {
- String name;
- // $FF: synthetic field
- private final TestDrive this$0;
-
- public TestDrive$TDButtonAdapter(TestDrive var1, String var2) {
- this.this$0 = var1;
- this.name = var2;
- }
-
- public void mouseClicked(MouseEvent var1) {
- if (this.name.equals("next")) {
- ++this.this$0.idx;
- if (this.this$0.idx == this.this$0.mathMLVector.size()) {
- this.this$0.idx = 0;
- }
- } else if (this.name.equals("prev")) {
- --this.this$0.idx;
- if (this.this$0.idx < 0) {
- this.this$0.idx = this.this$0.mathMLVector.size() - 1;
- }
- } else if (this.name.equals("write answers")) {
- StringBuffer var2 = new StringBuffer();
- OutputHandler var3 = new OutputHandler(var2);
- String var4 = this.this$0.ansInput.getText();
- if (var4 != null) {
- this.this$0.ansfile = var4;
- }
-
- Object var5 = null;
-
- try {
- var10 = new PrintStream(new FileOutputStream(this.this$0.ansfile));
- } catch (IOException var8) {
- System.out.println("problems opening answer file...");
- return;
- }
-
- for(this.this$0.idx = 0; this.this$0.idx < this.this$0.mathMLVector.size(); ++this.this$0.idx) {
- this.this$0.setEquation(this.this$0.idx);
- this.this$0.eq.redraw();
- this.this$0.presentationRoot = this.this$0.eq.root.getCopy();
-
- try {
- this.this$0.normalizedRoot = this.this$0.eq.root.getCopy();
- Normalizer.normalize(this.this$0.normalizedRoot);
- } catch (Exception var9) {
- System.out.println("Normalization failed: " + var9);
- continue;
- }
-
- try {
- this.this$0.p2cconverter.convert(this.this$0.normalizedRoot, this.this$0.eq.markupRoot);
- this.this$0.contentRoot = this.this$0.eq.markupRoot.getCopy();
- } catch (Exception var7) {
- System.out.println("Conversiont failed: " + var7);
- }
-
- var10.println("\n" + (String)this.this$0.descVector.elementAt(this.this$0.idx));
- var3.reset();
- this.this$0.rawRoot.print("", var3);
- var10.print(var3.getString());
- var3.reset();
- this.this$0.normalizedRoot.print("", var3);
- var10.print(var3.getString());
- var3.reset();
- this.this$0.contentRoot.print("", var3);
- var10.print(var3.getString());
- }
-
- var10.close();
- this.this$0.idx = 0;
- }
-
- this.this$0.setEquation(this.this$0.idx);
- this.this$0.repaint();
- }
- }
-