Program: 22710
Project: 22710
Buggy source:
/** 
 * Show advanced settings dialog
 * @return false when canceled
 */
public boolean showSettingsDialog(){
  GenericDialogPlus gd=new GenericDialogPlus("String_Node_Str");
  final boolean[] oldEnableFeatures=wekaSegmentation.getEnabledFeatures();
  gd.addMessage("String_Node_Str");
  final int rows=(int)Math.round(FeatureStack.availableFeatures.length / 2.0);
  gd.addCheckboxGroup(rows,2,FeatureStack.availableFeatures,oldEnableFeatures);
  if (wekaSegmentation.getLoadedTrainingData() != null) {
    final Vector<Checkbox> v=gd.getCheckboxes();
    for (    Checkbox c : v)     c.setEnabled(false);
    gd.addMessage("String_Node_Str");
  }
  gd.addNumericField("String_Node_Str",wekaSegmentation.getMembraneThickness(),0);
  gd.addNumericField("String_Node_Str",wekaSegmentation.getMembranePatchSize(),0);
  gd.addNumericField("String_Node_Str",wekaSegmentation.getMinimumSigma(),1);
  gd.addNumericField("String_Node_Str",wekaSegmentation.getMaximumSigma(),1);
  if (wekaSegmentation.getLoadedTrainingData() != null) {
    for (int i=0; i < 4; i++)     ((TextField)gd.getNumericFields().get(i)).setEnabled(false);
  }
  gd.addMessage("String_Node_Str");
  GenericObjectEditor m_ClassifierEditor=new GenericObjectEditor();
  PropertyPanel m_CEPanel=new PropertyPanel(m_ClassifierEditor);
  m_ClassifierEditor.setClassType(Classifier.class);
  m_ClassifierEditor.setValue(wekaSegmentation.getClassifier());
  gd.addComponent(m_CEPanel,GridBagConstraints.HORIZONTAL,1);
  Object c=(Object)m_ClassifierEditor.getValue();
  String originalOptions="String_Node_Str";
  String originalClassifierName=c.getClass().getName();
  if (c instanceof OptionHandler) {
    originalOptions=Utils.joinOptions(((OptionHandler)c).getOptions());
  }
  gd.addMessage("String_Node_Str");
  for (int i=0; i < wekaSegmentation.getNumOfClasses(); i++)   gd.addStringField("String_Node_Str" + (i + 1),wekaSegmentation.getClassLabel(i),15);
  gd.addMessage("String_Node_Str");
  gd.addCheckbox("String_Node_Str",wekaSegmentation.doHomogenizeClasses());
  gd.addButton("String_Node_Str",new SaveFeatureStackButtonListener("String_Node_Str",wekaSegmentation.getFeatureStackArray()));
  gd.addSlider("String_Node_Str",0,100,win.overlayOpacity);
  gd.addHelp("String_Node_Str");
  gd.showDialog();
  if (gd.wasCanceled())   return false;
  final int numOfFeatures=FeatureStack.availableFeatures.length;
  final boolean[] newEnableFeatures=new boolean[numOfFeatures];
  boolean featuresChanged=false;
  for (int i=0; i < numOfFeatures; i++) {
    newEnableFeatures[i]=gd.getNextBoolean();
    if (newEnableFeatures[i] != oldEnableFeatures[i]) {
      featuresChanged=true;
      record(SET_FEATURE,new String[]{FeatureStack.availableFeatures[i] + "String_Node_Str" + newEnableFeatures[i]});
    }
  }
  if (featuresChanged) {
    wekaSegmentation.setEnabledFeatures(newEnableFeatures);
  }
  final int newThickness=(int)gd.getNextNumber();
  if (newThickness != wekaSegmentation.getMembraneThickness()) {
    featuresChanged=true;
    wekaSegmentation.setMembraneThickness(newThickness);
    record(SET_MEMBRANE_THICKNESS,new String[]{Integer.toString(newThickness)});
  }
  final int newPatch=(int)gd.getNextNumber();
  if (newPatch != wekaSegmentation.getMembranePatchSize()) {
    featuresChanged=true;
    record(SET_MEMBRANE_PATCH,new String[]{Integer.toString(newPatch)});
    wekaSegmentation.setMembranePatchSize(newPatch);
  }
  final float newMinSigma=(float)gd.getNextNumber();
  if (newMinSigma != wekaSegmentation.getMinimumSigma() && newMinSigma > 0) {
    featuresChanged=true;
    record(SET_MINIMUM_SIGMA,new String[]{Float.toString(newMinSigma)});
    wekaSegmentation.setMinimumSigma(newMinSigma);
  }
  final float newMaxSigma=(float)gd.getNextNumber();
  if (newMaxSigma != wekaSegmentation.getMaximumSigma() && newMaxSigma >= wekaSegmentation.getMinimumSigma()) {
    featuresChanged=true;
    record(SET_MAXIMUM_SIGMA,new String[]{Float.toString(newMaxSigma)});
    wekaSegmentation.setMaximumSigma(newMaxSigma);
  }
  if (wekaSegmentation.getMinimumSigma() > wekaSegmentation.getMaximumSigma()) {
    IJ.error("String_Node_Str");
    wekaSegmentation.setMinimumSigma(0f);
    wekaSegmentation.setMaximumSigma(16f);
  }
  c=(Object)m_ClassifierEditor.getValue();
  String options="String_Node_Str";
  final String[] optionsArray=((OptionHandler)c).getOptions();
  if (c instanceof OptionHandler) {
    options=Utils.joinOptions(optionsArray);
  }
  if (originalClassifierName.equals(c.getClass().getName()) == false || originalOptions.equals(options) == false) {
    AbstractClassifier cls;
    try {
      cls=(AbstractClassifier)(c.getClass().newInstance());
      cls.setOptions(optionsArray);
    }
 catch (    Exception ex) {
      ex.printStackTrace();
      return false;
    }
    wekaSegmentation.setClassifier(cls);
    record(SET_CLASSIFIER,new String[]{c.getClass().getName(),options});
    IJ.log("String_Node_Str" + c.getClass().getName() + "String_Node_Str"+ options);
  }
  boolean classNameChanged=false;
  for (int i=0; i < wekaSegmentation.getNumOfClasses(); i++) {
    String s=gd.getNextString();
    if (null == s || 0 == s.length()) {
      IJ.log("String_Node_Str" + (i + 1));
      continue;
    }
    s=s.trim();
    if (!s.equals(wekaSegmentation.getClassLabel(i))) {
      if (0 == s.toLowerCase().indexOf("String_Node_Str"))       s=s.substring(7);
      wekaSegmentation.setClassLabel(i,s);
      classNameChanged=true;
      addExampleButton[i].setText("String_Node_Str" + s);
      record(CHANGE_CLASS_NAME,new String[]{Integer.toString(i),s});
    }
  }
  final boolean homogenizeClasses=gd.getNextBoolean();
  if (wekaSegmentation.doHomogenizeClasses() != homogenizeClasses) {
    wekaSegmentation.setDoHomogenizeClasses(homogenizeClasses);
    record(SET_HOMOGENIZATION,new String[]{Boolean.toString(homogenizeClasses)});
  }
  final int newOpacity=(int)gd.getNextNumber();
  if (newOpacity != win.overlayOpacity) {
    win.overlayOpacity=newOpacity;
    win.overlayAlpha=AlphaComposite.getInstance(AlphaComposite.SRC_OVER,win.overlayOpacity / 100f);
    win.resultOverlay.setComposite(win.overlayAlpha);
    record(SET_OPACITY,new String[]{Integer.toString(win.overlayOpacity)});
    if (showColorOverlay)     displayImage.updateAndDraw();
  }
  if (classNameChanged) {
    win.pack();
  }
  if (featuresChanged) {
    wekaSegmentation.setFeaturesDirty();
  }
 else   if (wekaSegmentation.getFeatureStackArray().isEmpty() == false && wekaSegmentation.getFeatureStackArray().getReferenceSliceIndex() != -1)   wekaSegmentation.setUpdateFeatures(false);
  return true;
}

Fixed version (ground truth):
/** 
 * Show advanced settings dialog
 * @return false when canceled
 */
public boolean showSettingsDialog(){
  GenericDialogPlus gd=new GenericDialogPlus("String_Node_Str");
  final boolean[] oldEnableFeatures=wekaSegmentation.getEnabledFeatures();
  gd.addMessage("String_Node_Str");
  final int rows=(int)Math.round(FeatureStack.availableFeatures.length / 2.0);
  gd.addCheckboxGroup(rows,2,FeatureStack.availableFeatures,oldEnableFeatures);
  if (wekaSegmentation.getLoadedTrainingData() != null) {
    final Vector<Checkbox> v=gd.getCheckboxes();
    for (    Checkbox c : v)     c.setEnabled(false);
    gd.addMessage("String_Node_Str");
  }
  gd.addNumericField("String_Node_Str",wekaSegmentation.getMembraneThickness(),0);
  gd.addNumericField("String_Node_Str",wekaSegmentation.getMembranePatchSize(),0);
  gd.addNumericField("String_Node_Str",wekaSegmentation.getMinimumSigma(),1);
  gd.addNumericField("String_Node_Str",wekaSegmentation.getMaximumSigma(),1);
  if (wekaSegmentation.getLoadedTrainingData() != null) {
    for (int i=0; i < 4; i++)     ((TextField)gd.getNumericFields().get(i)).setEnabled(false);
  }
  gd.addMessage("String_Node_Str");
  GenericObjectEditor m_ClassifierEditor=new GenericObjectEditor();
  PropertyPanel m_CEPanel=new PropertyPanel(m_ClassifierEditor);
  m_ClassifierEditor.setClassType(Classifier.class);
  m_ClassifierEditor.setValue(wekaSegmentation.getClassifier());
  gd.addComponent(m_CEPanel,GridBagConstraints.HORIZONTAL,1);
  Object c=(Object)m_ClassifierEditor.getValue();
  String originalOptions="String_Node_Str";
  String originalClassifierName=c.getClass().getName();
  if (c instanceof OptionHandler) {
    originalOptions=Utils.joinOptions(((OptionHandler)c).getOptions());
  }
  gd.addMessage("String_Node_Str");
  for (int i=0; i < wekaSegmentation.getNumOfClasses(); i++)   gd.addStringField("String_Node_Str" + (i + 1),wekaSegmentation.getClassLabel(i),15);
  gd.addMessage("String_Node_Str");
  gd.addCheckbox("String_Node_Str",wekaSegmentation.doHomogenizeClasses());
  gd.addButton("String_Node_Str",new SaveFeatureStackButtonListener("String_Node_Str",wekaSegmentation.getFeatureStackArray()));
  gd.addSlider("String_Node_Str",0,100,win.overlayOpacity);
  gd.addHelp("String_Node_Str");
  gd.showDialog();
  if (gd.wasCanceled())   return false;
  final int numOfFeatures=FeatureStack.availableFeatures.length;
  final boolean[] newEnableFeatures=new boolean[numOfFeatures];
  boolean featuresChanged=false;
  for (int i=0; i < numOfFeatures; i++) {
    newEnableFeatures[i]=gd.getNextBoolean();
    if (newEnableFeatures[i] != oldEnableFeatures[i]) {
      featuresChanged=true;
      record(SET_FEATURE,new String[]{FeatureStack.availableFeatures[i] + "String_Node_Str" + newEnableFeatures[i]});
    }
  }
  if (featuresChanged) {
    wekaSegmentation.setEnabledFeatures(newEnableFeatures);
  }
  final int newThickness=(int)gd.getNextNumber();
  if (newThickness != wekaSegmentation.getMembraneThickness()) {
    featuresChanged=true;
    wekaSegmentation.setMembraneThickness(newThickness);
    record(SET_MEMBRANE_THICKNESS,new String[]{Integer.toString(newThickness)});
  }
  final int newPatch=(int)gd.getNextNumber();
  if (newPatch != wekaSegmentation.getMembranePatchSize()) {
    featuresChanged=true;
    record(SET_MEMBRANE_PATCH,new String[]{Integer.toString(newPatch)});
    wekaSegmentation.setMembranePatchSize(newPatch);
  }
  final float newMinSigma=(float)gd.getNextNumber();
  if (newMinSigma != wekaSegmentation.getMinimumSigma() && newMinSigma > 0) {
    featuresChanged=true;
    record(SET_MINIMUM_SIGMA,new String[]{Float.toString(newMinSigma)});
    wekaSegmentation.setMinimumSigma(newMinSigma);
  }
  final float newMaxSigma=(float)gd.getNextNumber();
  if (newMaxSigma != wekaSegmentation.getMaximumSigma() && newMaxSigma >= wekaSegmentation.getMinimumSigma()) {
    featuresChanged=true;
    record(SET_MAXIMUM_SIGMA,new String[]{Float.toString(newMaxSigma)});
    wekaSegmentation.setMaximumSigma(newMaxSigma);
  }
  if (wekaSegmentation.getMinimumSigma() > wekaSegmentation.getMaximumSigma()) {
    IJ.error("String_Node_Str");
    wekaSegmentation.setMinimumSigma(0f);
    wekaSegmentation.setMaximumSigma(16f);
  }
  c=(Object)m_ClassifierEditor.getValue();
  String options="String_Node_Str";
  final String[] optionsArray=((OptionHandler)c).getOptions();
  if (c instanceof OptionHandler) {
    options=Utils.joinOptions(optionsArray);
  }
  if (originalClassifierName.equals(c.getClass().getName()) == false || originalOptions.equals(options) == false) {
    AbstractClassifier cls;
    try {
      cls=(AbstractClassifier)(c.getClass().newInstance());
      cls.setOptions(optionsArray);
    }
 catch (    Exception ex) {
      ex.printStackTrace();
      return false;
    }
    wekaSegmentation.setClassifier(cls);
    win.trainingComplete=false;
    record(SET_CLASSIFIER,new String[]{c.getClass().getName(),options});
    IJ.log("String_Node_Str" + c.getClass().getName() + "String_Node_Str"+ options);
  }
  boolean classNameChanged=false;
  for (int i=0; i < wekaSegmentation.getNumOfClasses(); i++) {
    String s=gd.getNextString();
    if (null == s || 0 == s.length()) {
      IJ.log("String_Node_Str" + (i + 1));
      continue;
    }
    s=s.trim();
    if (!s.equals(wekaSegmentation.getClassLabel(i))) {
      if (0 == s.toLowerCase().indexOf("String_Node_Str"))       s=s.substring(7);
      wekaSegmentation.setClassLabel(i,s);
      classNameChanged=true;
      addExampleButton[i].setText("String_Node_Str" + s);
      record(CHANGE_CLASS_NAME,new String[]{Integer.toString(i),s});
    }
  }
  final boolean homogenizeClasses=gd.getNextBoolean();
  if (wekaSegmentation.doHomogenizeClasses() != homogenizeClasses) {
    wekaSegmentation.setDoHomogenizeClasses(homogenizeClasses);
    record(SET_HOMOGENIZATION,new String[]{Boolean.toString(homogenizeClasses)});
  }
  final int newOpacity=(int)gd.getNextNumber();
  if (newOpacity != win.overlayOpacity) {
    win.overlayOpacity=newOpacity;
    win.overlayAlpha=AlphaComposite.getInstance(AlphaComposite.SRC_OVER,win.overlayOpacity / 100f);
    win.resultOverlay.setComposite(win.overlayAlpha);
    record(SET_OPACITY,new String[]{Integer.toString(win.overlayOpacity)});
    if (showColorOverlay)     displayImage.updateAndDraw();
  }
  if (classNameChanged) {
    win.pack();
  }
  if (featuresChanged) {
    wekaSegmentation.setFeaturesDirty();
  }
 else   if (wekaSegmentation.getFeatureStackArray().isEmpty() == false && wekaSegmentation.getFeatureStackArray().getReferenceSliceIndex() != -1)   wekaSegmentation.setUpdateFeatures(false);
  return true;
}