public boolean doSelectCoord() throws HeadlessException {

    SingleCoordSelectionPanel pan = new SingleCoordSelectionPanel();
    // pan.setMaxX(this.expContext.getNrcols());
    // pan.setMaxY(this.expContext.getNrrows());
    if (maincont.getAbsDataAreaCoord() != null) {
      pan.setCoord1(maincont.getAbsDataAreaCoord());
    }
    int ans =
        JOptionPane.showConfirmDialog(
            this, pan, "Enter a selection:", JOptionPane.OK_CANCEL_OPTION);
    if (ans == JOptionPane.CANCEL_OPTION) {
      return true;
    }
    // RELATIVE to current sub experiment
    WellCoordinate c1 =
        new WellCoordinate(
            pan.getCoord1().getCol() - maincont.getExp().getColOffset(),
            pan.getCoord1().getRow() - maincont.getExp().getRowOffset());
    WellCoordinate c2 = c1.add(100, 100);
    WellSelection sel = new WellSelection(c1, c2);
    WellCoordinate abs = pan.getCoord1();
    if (maincont.getAbsDataAreaCoord() != null && abs.equals(maincont.getAbsDataAreaCoord())) {
      GuiUtils.showNonModalMsg("Same coordinates, I won't to anything", "Process");
      return true;
    }
    maincont.setAbsDataAreaCoord(abs);

    LookupUtils.publish(wellSelectionContent, sel);

    return false;
  }
 protected boolean getExpContext() {
   //  Exception e = new Exception("showing stack trace");
   //   p(ErrorHandler.getString(e));
   if (expContext == null) {
     expContext = GlobalContext.getContext().getExperimentContext();
   }
   if (expContext == null) {
     GuiUtils.showNonModalMsg("Got no experiment context from global contexet");
     return false;
   }
   maincont = ExplorerContext.getCurContext(expContext);
   info.setText(expContext.getRawDir());
   this.btnreload.setToolTipText(
       "Reload data from dir " + expContext.getRawDir() + " at " + maincont.getAbsDataAreaCoord());
   return true;
 }
  private void subtractActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_subtractActionPerformed

    RasterData data = maincont.getData();
    if (data == null) {
      JOptionPane.showMessageDialog(this, "I have no data yet to subtract anything from :-)");
      return;
    }
    if (subtract_type == null) {
      subtract_type = maincont.getFiletype();
    }
    FlowSelection pan =
        new FlowSelection(
            "Select the flow and file type you wish to subtract from the currently selected data");
    pan.setFlow(subtract_flow);
    pan.setFiletype(subtract_type);
    int ans =
        JOptionPane.showConfirmDialog(
            this,
            pan,
            "Data Subtraction",
            JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE);
    if (ans != JOptionPane.OK_OPTION) {
      return;
    }

    subtract_flow = pan.getFlow();
    subtract_type = pan.getFiletype();
    // otherwise load the data and then subtract
    RasterData sub = null;
    DataAccessManager manager = DataAccessManager.getManager(maincont.getExp().getWellContext());
    try {
      p("Loading subregion, RELATIVE coord " + maincont.getRelativeDataAreaCoord());
      sub =
          manager.getRasterDataForArea(
              null,
              maincont.getRasterSize(),
              maincont.getRelativeDataAreaCoord(),
              pan.getFlow(),
              pan.getFiletype(),
              null,
              0,
              -1);
      // now subtract first frame
    } catch (Exception ex) {
      p("Error when loading: " + ErrorHandler.getString(ex));
    }
    if (sub == null) {
      JOptionPane.showMessageDialog(
          this,
          "I could not load flow "
              + pan.getFlow()
              + ", "
              + pan.getFiletype()
              + ", @ "
              + maincont.getAbsDataAreaCoord());
      return;
    }
    String what = "raw";
    if (this.automatic_nn) {
      GuiUtils.showNonModalMsg("Computing NN before subtraction");
      sub = computeNN(null, sub);
      what = "NN subtracted";
    }

    data.subtract(sub);
    JOptionPane.showMessageDialog(
        this,
        "I subtracted the "
            + what
            + " data from "
            + pan.getFlow()
            + ", "
            + pan.getFiletype()
            + ", @ "
            + maincont.getAbsDataAreaCoord());
    this.rasterViewUpdate();
  } // GEN-LAST:event_subtractActionPerformed