Пример #1
0
  /** Calls the algorithm. */
  protected void callAlgorithm() {

    try {
      resultImage =
          new ModelImage(imageA.getType(), imageA.getExtents(), (imageA.getImageName() + "_isn"));
      resultImage.copyFileTypeInfo(imageA);

      // Make algorithm
      isnAlgo = new PlugInAlgorithmISN(resultImage, imageA);

      // This is very important. Adding this object as a listener allows the algorithm to
      // notify this object when it has completed of failed. See algorithm performed event.
      // This is made possible by implementing AlgorithmedPerformed interface
      isnAlgo.addListener(this);

      createProgressBar(imageA.getImageName(), " ...", isnAlgo);

      // Hide dialog
      setVisible(false);

      if (isRunInSeparateThread()) {

        // Start the thread as a low priority because we wish to still have user interface work
        // fast.
        if (isnAlgo.startMethod(Thread.MIN_PRIORITY) == false) {
          MipavUtil.displayError("A thread is already running on this object");
        }
      } else {
        isnAlgo.run();
      }
    } catch (OutOfMemoryError x) {
      System.gc();
      MipavUtil.displayError("AlgorithmAbsoluteValue: unable to allocate enough memory");

      return;
    }
  }