コード例 #1
0
 private boolean getThinGens() {
   int thin =
       JOptionPane.showConfirmDialog(
           uacalc,
           "Eliminate some redundant projections",
           "Coordinate thinning",
           JOptionPane.YES_NO_OPTION,
           JOptionPane.QUESTION_MESSAGE);
   if (thin == JOptionPane.YES_OPTION || thin == JOptionPane.OK_OPTION) return true;
   return false;
 }
コード例 #2
0
  private void setupFreeAlgebraPanel() {
    final SmallAlgebra alg = uacalc.getCurrentAlgebra();
    if (alg == null) {
      JOptionPane.showMessageDialog(
          this,
          "<html>You must have an algebra loaded.<br>"
              + "Use the file menu or make a new one.</html>",
          "No algebra error",
          JOptionPane.ERROR_MESSAGE);
      return;
    }
    final int gens = getFreeGensDialog();
    if (!(gens > 0)) return;
    System.out.println("gens = " + gens);
    final boolean thin = getThinGens();
    final ProgressReport report = new ProgressReport(monitorPanel);
    monitorPanel.setProgressReport(report);
    final BackgroundTask<FreeAlgebra> freeAlgTask =
        new BackgroundTask<FreeAlgebra>(report) {
          public FreeAlgebra compute() {
            // monitorPanel.getProgressMonitor().reset();
            report.setDescription("F(" + gens + ") over " + alg.getName());
            FreeAlgebra freeAlg =
                new FreeAlgebra(uacalc.getCurrentAlgebra(), gens, true, thin, report);
            return freeAlg;
          }

          public void onCompletion(
              FreeAlgebra fr, Throwable exception, boolean cancelled, boolean outOfMemory) {
            // System.out.println("got to completion");
            // System.out.println("thrown = " + exception);
            // for (BackgroundTask task : monitorPanel.getTaskList()) {
            //  System.out.println("task: " + task.getStatus());
            // }
            if (outOfMemory) {
              // monitorPanel.getProgressMonitor().reset();
              report.addEndingLine("Out of memory!!!");
              // monitorPanel.getProgressModel().printlnToLog("Not enough memory");

              return;
            }
            if (!cancelled) {
              TermTablePanel ttp = new TermTablePanel(uacalc, fr.getTerms(), fr.getVariables());
              setTermTablePanel(ttp);
            } else {
              // monitorPanel.getProgressMonitor().reset();
              // monitorPanel.getProgressModel().printlnToLog("computation cancelled");
              report.addEndingLine("Computation cancelled");
            }
          }
        };
    monitorPanel.addTask(freeAlgTask);
    BackgroundExec.getBackgroundExec().execute(freeAlgTask);
  }
コード例 #3
0
 public int getFreeGensDialog() {
   String numGensStr =
       JOptionPane.showInputDialog(
           uacalc, "Number of generators?", "Free Algebra", JOptionPane.QUESTION_MESSAGE);
   if (numGensStr == null) return -1;
   int gens = -1;
   boolean gensOk = true;
   try {
     gens = Integer.parseInt(numGensStr);
   } catch (NumberFormatException e) {
     gensOk = false;
   }
   if (!gensOk || gens <= 0) {
     JOptionPane.showMessageDialog(
         this,
         "<html>The number of generators must be positive.<br>" + "Try again.</html>",
         "Number format error",
         JOptionPane.ERROR_MESSAGE);
     return -1;
   }
   return gens;
 }