/** Loads the default settings from Preferences to set up the dialog. */
  public void legacyLoadDefaults() {
    String defaultsString = Preferences.getDialogDefaults(getDialogName());

    if ((defaultsString != null) && (newImage != null)) {

      try {
        StringTokenizer st = new StringTokenizer(defaultsString, ",");

        textSearchWindowSide.setText("" + MipavUtil.getInt(st));
        textSimilarityWindowSide.setText("" + MipavUtil.getInt(st));
        textNoiseStandardDeviation.setText("" + MipavUtil.getFloat(st));
        textDegree.setText("" + MipavUtil.getFloat(st));
        doRician = MipavUtil.getBoolean(st);
        doRicianCheckBox.setSelected(doRician);
        textDegree.setEnabled(doRician);
        labelDegree.setEnabled(doRician);
        image25DCheckBox.setSelected(MipavUtil.getBoolean(st));

        if (MipavUtil.getBoolean(st)) {
          newImage.setSelected(true);
        } else {
          replaceImage.setSelected(true);
        }

      } catch (Exception ex) {

        // since there was a problem parsing the defaults string, start over with the original
        // defaults
        Preferences.debug("Resetting defaults for dialog: " + getDialogName());
        Preferences.removeProperty(getDialogName());
      }
    }
  }
  /** Construct the panel's GUI. */
  private void initGUI() {
    PanelManager mainPanelManager = new PanelManager(this);
    PanelManager destPanelManager = new PanelManager("Destination");
    PanelManager regionPanelManager = new PanelManager("Process");

    ButtonGroup destinationGroup = new ButtonGroup();
    ButtonGroup imageVOIGroup = new ButtonGroup();

    newImageRadio = WidgetFactory.buildRadioButton("New image", true, destinationGroup);
    destPanelManager.add(newImageRadio);
    replaceImageRadio = WidgetFactory.buildRadioButton("Replace image", false, destinationGroup);
    destPanelManager.addOnNextLine(replaceImageRadio);

    // Only if the image is unlocked can it be replaced.
    if (srcImage.getLockStatus() == ModelStorageBase.UNLOCKED) {
      replaceImageRadio.setEnabled(true);
      if (ViewUserInterface.getReference().doForceInPlace()) {
        replaceImageRadio.setSelected(true);
        newImageRadio.setEnabled(false);
      }
    } else {
      replaceImageRadio.setEnabled(false);
    }

    wholeImageRadio = WidgetFactory.buildRadioButton("Whole image", true, imageVOIGroup);
    regionPanelManager.add(wholeImageRadio);
    voiRegionsRadio = WidgetFactory.buildRadioButton("VOI region(s)", false, imageVOIGroup);
    regionPanelManager.addOnNextLine(voiRegionsRadio);

    mainPanelManager.add(destPanelManager.getPanel());
    mainPanelManager.add(regionPanelManager.getPanel());
  }
 /**
  * Changes whether a new image should be generated by the algorithm.
  *
  * @param flag true if a new image should be made, false otherwise
  */
 public void setOutputNewImage(boolean flag) {
   newImageRadio.setSelected(flag);
   replaceImageRadio.setSelected(!flag);
 }
 /**
  * Changes whether a whole image should be processed (as opposed to just VOI regions).
  *
  * @param flag true if the whole image should be processed, false if just VOI regions
  */
 public void setProcessWholeImage(boolean flag) {
   wholeImageRadio.setSelected(flag);
   voiRegionsRadio.setSelected(!flag);
 }