home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2001 December / dppcpro1201.iso / Extras / maple / Viewer / WebEQ / MMLViewerInstall.cab / MMLViewerApplet.cab / webeq3 / TestDrive$TDButtonAdapter.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-05-24  |  3.1 KB  |  89 lines

  1. package webeq3;
  2.  
  3. import java.awt.event.MouseAdapter;
  4. import java.awt.event.MouseEvent;
  5. import java.io.FileOutputStream;
  6. import java.io.IOException;
  7. import java.io.PrintStream;
  8. import webeq3.schema.Normalizer;
  9. import webeq3.util.OutputHandler;
  10.  
  11. class TestDrive$TDButtonAdapter extends MouseAdapter {
  12.    String name;
  13.    // $FF: synthetic field
  14.    private final TestDrive this$0;
  15.  
  16.    public TestDrive$TDButtonAdapter(TestDrive var1, String var2) {
  17.       this.this$0 = var1;
  18.       this.name = var2;
  19.    }
  20.  
  21.    public void mouseClicked(MouseEvent var1) {
  22.       if (this.name.equals("next")) {
  23.          ++this.this$0.idx;
  24.          if (this.this$0.idx == this.this$0.mathMLVector.size()) {
  25.             this.this$0.idx = 0;
  26.          }
  27.       } else if (this.name.equals("prev")) {
  28.          --this.this$0.idx;
  29.          if (this.this$0.idx < 0) {
  30.             this.this$0.idx = this.this$0.mathMLVector.size() - 1;
  31.          }
  32.       } else if (this.name.equals("write answers")) {
  33.          StringBuffer var2 = new StringBuffer();
  34.          OutputHandler var3 = new OutputHandler(var2);
  35.          String var4 = this.this$0.ansInput.getText();
  36.          if (var4 != null) {
  37.             this.this$0.ansfile = var4;
  38.          }
  39.  
  40.          Object var5 = null;
  41.  
  42.          try {
  43.             var10 = new PrintStream(new FileOutputStream(this.this$0.ansfile));
  44.          } catch (IOException var8) {
  45.             System.out.println("problems opening answer file...");
  46.             return;
  47.          }
  48.  
  49.          for(this.this$0.idx = 0; this.this$0.idx < this.this$0.mathMLVector.size(); ++this.this$0.idx) {
  50.             this.this$0.setEquation(this.this$0.idx);
  51.             this.this$0.eq.redraw();
  52.             this.this$0.presentationRoot = this.this$0.eq.root.getCopy();
  53.  
  54.             try {
  55.                this.this$0.normalizedRoot = this.this$0.eq.root.getCopy();
  56.                Normalizer.normalize(this.this$0.normalizedRoot);
  57.             } catch (Exception var9) {
  58.                System.out.println("Normalization failed: " + var9);
  59.                continue;
  60.             }
  61.  
  62.             try {
  63.                this.this$0.p2cconverter.convert(this.this$0.normalizedRoot, this.this$0.eq.markupRoot);
  64.                this.this$0.contentRoot = this.this$0.eq.markupRoot.getCopy();
  65.             } catch (Exception var7) {
  66.                System.out.println("Conversiont failed: " + var7);
  67.             }
  68.  
  69.             var10.println("\n" + (String)this.this$0.descVector.elementAt(this.this$0.idx));
  70.             var3.reset();
  71.             this.this$0.rawRoot.print("", var3);
  72.             var10.print(var3.getString());
  73.             var3.reset();
  74.             this.this$0.normalizedRoot.print("", var3);
  75.             var10.print(var3.getString());
  76.             var3.reset();
  77.             this.this$0.contentRoot.print("", var3);
  78.             var10.print(var3.getString());
  79.          }
  80.  
  81.          var10.close();
  82.          this.this$0.idx = 0;
  83.       }
  84.  
  85.       this.this$0.setEquation(this.this$0.idx);
  86.       this.this$0.repaint();
  87.    }
  88. }
  89.