public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (isVisible()
        && (e.getSource() == optionPane)
        && (JOptionPane.VALUE_PROPERTY.equals(prop)
            || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
      Object value = optionPane.getValue();

      if (value == JOptionPane.UNINITIALIZED_VALUE) return;
      optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

      if (button1.equals(value)) {
        try {
          double a = Double.parseDouble(left.getText());
          double b = Double.parseDouble(right.getText());
          double err = Double.parseDouble(error.getText());

          if (a > b) {
            JOptionPane.showMessageDialog(this, "A < B!!!", null, JOptionPane.ERROR_MESSAGE);
          } else {
            hideIt();
            graphic.startApplyingMethod(parentFrame.getSelectedMethod(), err, a, b);
          }
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this, "Trebuie sa fie numar real!", null, JOptionPane.ERROR_MESSAGE);
        }
      } else if (button2.equals(value)) {
        hideIt();
      }
    }
  }
  /** This method reacts to state changes in the option pane. */
  public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (isVisible()
        && (e.getSource() == optionPane)
        && (JOptionPane.VALUE_PROPERTY.equals(prop)
            || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
      Object value = optionPane.getValue();

      if (value == JOptionPane.UNINITIALIZED_VALUE) {
        // ignore reset
        return;
      }

      // Reset the JOptionPane's value.
      // If you don't do this, then if the user
      // presses the same button next time, no
      // property change event will be fired.
      optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

      if (btnString1.equals(value)) {
        String[] strings = new String[1];
        strings[0] = numPlatesTextField.getText();

        // make sure the inputed values are numbers only
        if (tools.MathOps.areNumbers(strings)) {

          int numP = Integer.parseInt(strings[0]);
          if (numRows != -1 && numCols != -1) {
            Model_Main TheMainModel = models.Model_Main.getModel();
            if (TheMainModel == null) TheMainModel = new Model_Main();

            boolean worked = TheMainModel.initNewPlates(numP, numRows, numCols);

            if (worked) {
              if (ParentFrame != null) ParentFrame.setVisible(false);

              MainGUI TheMainGUI = new MainGUI(TheMainModel);
              if (TheMainGUI != null)
                TheMainGUI.setTitle("Project: " + TheMainModel.getInputProjectPath());
              TheMainGUI.setVisible(true);
            }
          }

        } else {
          JOptionPane.showMessageDialog(
              null, "Please Enter a Valid Number of Plates ", "Error", JOptionPane.ERROR_MESSAGE);
          return;
        }
        clearAndHide();

      } else { // user closed dialog or clicked cancel
        clearAndHide();
      }
    }
  }
Exemple #3
0
  /** This method reacts to state changes in the option pane. */
  public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (isVisible()
        && (e.getSource() == optionPane)
        && (JOptionPane.VALUE_PROPERTY.equals(prop)
            || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
      Object value = optionPane.getValue();

      if (value == JOptionPane.UNINITIALIZED_VALUE) {
        // ignore reset
        return;
      }

      // Reset the JOptionPane's value.
      // If you don't do this, then if the user
      // presses the same button next time, no
      // property change event will be fired.
      optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

      if (btnString1.equals(value)) {
        typedText = textField1.getText();
        String ucText = typedText.toUpperCase();
        if (magicWord.equals(ucText)) {
          // we're done; clear and dismiss the dialog
          clearAndHide();
        } else {
          // text was invalid
          textField1.selectAll();
          JOptionPane.showMessageDialog(
              iRuleDialog.this,
              "Sorry, \""
                  + typedText
                  + "\" "
                  + "isn't a valid response.\n"
                  + "Please enter "
                  + magicWord
                  + ".",
              "Try again",
              JOptionPane.ERROR_MESSAGE);
          typedText = null;
          textField1.requestFocusInWindow();
        }
      } else { // user closed dialog or clicked cancel
        mainGuiWindow.setLabel("It's OK.");
        typedText = null;
        clearAndHide();
      }
    }
  }
  /** This method reacts to state changes in the option pane. */
  public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (isVisible()
        && (e.getSource() == optionPane)
        && (JOptionPane.VALUE_PROPERTY.equals(prop)
            || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
      Object value = optionPane.getValue();

      if (value == JOptionPane.UNINITIALIZED_VALUE) {
        // ignore reset
        return;
      }

      // Reset the JOptionPane's value.
      // If you don't do this, then if the user
      // presses the same button next time, no
      // property change event will be fired.
      optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

      if (btnString1.equals(value)) {
        String[] strings = null;

        strings = new String[1];
        strings[0] = textField[0].getText().trim(); // zScore thresh

        // make sure the inputed values are numbers only
        if (tools.MathOps.areNumbers(strings)) {

          zScore_channel = (String) channelBox.getSelectedItem();
          zScore_threshold = Float.parseFloat(strings[0].trim());

          clearAndHide();

        } else {
          JOptionPane.showMessageDialog(
              null,
              "Error with inputed bounds!  Make sure numbers make sense ",
              "Thresholds",
              JOptionPane.ERROR_MESSAGE);
        }

      } else {
        // user closed dialog or clicked cancel
        typedText = null;
        clearAndHide();
      }
    }
  }
  /** This method reacts to state changes in the option pane. */
  public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (isVisible()
        && (e.getSource() == optionPane)
        && (JOptionPane.VALUE_PROPERTY.equals(prop)
            || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
      Object value = optionPane.getValue();

      if (value == JOptionPane.UNINITIALIZED_VALUE) {
        // ignore reset
        return;
      }

      // Reset the JOptionPane's value.
      // If you don't do this, then if the user
      // presses the same button next time, no
      // property change event will be fired.
      optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

      if (btnString1.equals(value)) {
        String[] strings = null;

        strings = new String[3];
        strings[0] = textField[0].getText(); // Nuc thresh
        strings[1] = textField[1].getText(); // Cyt Thresh
        strings[2] = textField[2].getText(); // Bkgd thresh

        // make sure the inputed values are numbers only
        if (tools.MathOps.areNumbers(strings)) {
          int NucBoundaryChannel = channelBox_nuc.getSelectedIndex();
          int CytoBoundaryChannel = channelBox_cyto.getSelectedIndex();
          float Thresh_Nuc_Value = Float.parseFloat(strings[0]);
          float Thresh_CellBoundary = Float.parseFloat(strings[1]);
          float Thresh_Bkgd_Value = Float.parseFloat(strings[2]);

          // Storing the Parameters for each Model_Field
          int len = TheWells.length;
          for (int i = 0; i < len; i++) {
            Model_Well well = TheWells[i];
            Model_Field[] fields = well.getFields();
            for (int p = 0; p < fields.length; p++) {

              Model_ParameterSet pset = fields[p].getParameterSet();
              pset.setParameter("Algorithm", "DefaultSegmentor_v1");

              // Threshold Channel Nucleus
              pset.setParameter(
                  "Thresh_Nuc_ChannelName",
                  "" + models.Model_Main.getModel().getTheChannelNames()[NucBoundaryChannel]);
              // Threshold Channel Cytoplasm
              pset.setParameter(
                  "Thresh_Cyt_ChannelName",
                  models.Model_Main.getModel().getTheChannelNames()[CytoBoundaryChannel]);
              // Nuc bound threshold
              pset.setParameter("Thresh_Nuc_Value", "" + Thresh_Nuc_Value);
              // Cell bound Threshold
              pset.setParameter("Thresh_Cyt_Value", "" + Thresh_CellBoundary);
              // Bkgd threshold
              pset.setParameter("Thresh_Bkgd_Value", "" + Thresh_Bkgd_Value);

              if (CoordsToSave == 0) pset.setParameter("CoordsToSaveToHDF", "BoundingBox");
              else if (CoordsToSave == 1) pset.setParameter("CoordsToSaveToHDF", "Centroid");
              else if (CoordsToSave == 2) pset.setParameter("CoordsToSaveToHDF", "Outlines");
              else if (CoordsToSave == 3) pset.setParameter("CoordsToSaveToHDF", "Everything");

              // Finding the index of this channel name
              for (int j = 0; j < models.Model_Main.getModel().getTheChannelNames().length; j++)
                if (models.Model_Main.getModel()
                    .getTheChannelNames()[j]
                    .equalsIgnoreCase(pset.getParameter_String("Thresh_Nuc_ChannelName")))
                  pset.setParameter("Thresh_Nuc_ChannelIndex", "" + j);
              // Finding the index of this channel name
              for (int j = 0; j < models.Model_Main.getModel().getTheChannelNames().length; j++)
                if (models.Model_Main.getModel()
                    .getTheChannelNames()[j]
                    .equalsIgnoreCase(pset.getParameter_String("Thresh_Cyt_ChannelName")))
                  pset.setParameter("Thresh_Cyt_ChannelIndex", "" + j);

              // Storing Parameters used to process this field
              String hdfPath = models.Model_Main.getModel().getOutputProjectPath() + "/Data.h5";
              try {
                pset.writeParameters(
                    hdfPath,
                    well.getPlate().getID(),
                    well.getWellIndex(),
                    fields[p].getIndexInWell());
              } catch (H5IO_Exception e1) {
                e1.printStackTrace();
              }
            }
          }
          if (Thresh_Bkgd_Value > 0) models.Model_Main.getModel().setBackgroundSubtract(true);

          // Only getting wells with Images that we can process
          int numWells = TheWells.length;
          ArrayList<Model_Well> wellsWIm = new ArrayList<Model_Well>();
          for (int i = 0; i < numWells; i++)
            if (TheWells[i].getFields() != null && TheWells[i].getFields().length > 0)
              wellsWIm.add(TheWells[i]);
          int numW = wellsWIm.size();
          Model_Well[] wellsWithImages = new Model_Well[numW];
          for (int i = 0; i < numW; i++) wellsWithImages[i] = wellsWIm.get(i);

          // File dir = models.Model_Main.getModel()
          // .getProjectDirectory();
          // File f = new File(dir.getAbsolutePath() + "/BatchJobs");
          // if (f.exists())
          // deleteDir(f);
          //
          // f = new File(dir.getAbsolutePath() + "/BatchJobs");
          // f.mkdir();
          // File f2 = new File(dir.getAbsolutePath() +
          // "/BatchResults");
          // if (f2.exists())
          // deleteDir(f2);
          // f2 = new File(dir.getAbsolutePath() + "/BatchResults");
          // f2.mkdir();

          if (models.Model_Main.getModel().isProcessing()) {
            JOptionPane.showMessageDialog(
                null,
                "Please wait till segmentation is complete before starting another process",
                "Be Patient",
                JOptionPane.ERROR_MESSAGE);
            return;
          }

          // Single thread run
          Processor_WriteParameters tasker = new Processor_WriteParameters(wellsWithImages, null);
          tasker.start();

        } else {
          JOptionPane.showMessageDialog(
              null,
              "Error with inputed bounds!  Make sure numbers make sense ",
              "Thresholds",
              JOptionPane.ERROR_MESSAGE);
          return;
        }
        clearAndHide();

      } else { // user closed dialog or clicked cancel
        clearAndHide();
      }
    }
  }