@Override public void taskDone(Task t) { p("Task " + t + " is done"); setCursor(null); // if (t.isSuccess()) { this.data = ((ComputeNN) t).getData(); p("Got nndata " + data); if (data == null) { JOptionPane.showMessageDialog(this, "There was a problem in nn compute, I got no result"); } else { maincont.setData(data); rasterViewCreate( false, "After masked neighbor subtraction, span=" + maincont.getSpan() + ", BG mask=" + maincont.getBgMask()); } }
public void rasterViewCreate(boolean load, String title) { p("=========rasterViewCreate called: load=" + load); // if (load) { // Exception e = new Exception("Tracing call"); // p(ErrorHandler.getString(e)); // } if (!getExpContext()) { return; } if (load) { if (selection != null) GuiUtils.showNonModalMsg( "Loading " + selection + " for " + maincont.getFiletype() + ", flow " + maincont.getFlow(), "Process"); } String base = "?"; if (maincont.getFiletype() == RawType.ACQ) { base = "" + maincont.getExp().getWellContext().getBase(maincont.getFlow()); } this.flowPanel.setToolTipText( "<html>Base for flow " + maincont.getFlow() + ":" + base + "<br>Flow order: " + maincont.getExp().getFlowOrder() + "</html>"); raster = new RasterView(maincont, load); this.panImage.removeAll(); panImage.add(raster); // repaint(); // p("adding raster view"); if (load) { this.getUserPreferences(); } raster.update(load, maincont); // paintImmediately(0,0,1000,1000); panImage.repaint(); raster.repaint(); if (load) { title = "Raw data"; } title += " flow " + maincont.getFlow() + "=" + base; chartViewCreate(title); invalidate(); revalidate(); // this.paintAll(getGraphics()); repaint(); if (load) { if (this.automatic_nn) { p("also doing nn - disable nn"); this.btnNN.setEnabled(false); btnNN.setText(""); btnNN.setToolTipText( "Automatically computing NN - check Explorer Options if you wish to change it!"); RasterData data = computeNN(null); maincont.setData(data); rasterViewCreate( false, "After masked neighbor subtraction, span=" + maincont.getSpan() + ", BG mask=" + maincont.getBgMask()); } else { this.btnNN.setEnabled(true); btnNN.setText("Compute NN"); btnNN.setToolTipText( "Click to compute NN bg subtraction - check Explorer Options if you wish <b>automate</b> this!"); } } }
private RasterData computeNN(ProgressListener prog, RasterData rawdata) { // p("computeNN. Maincont is: " + maincont); if (rawdata == null) { GuiUtils.showNonModalDialog( "<html>I see no data yet - did you already pick a region?<br>" + "(Even if you see something somewhere, if you didn't actually select a region, it might just show some sample data)</html>", "No data - region selected?"); return null; } RasterData nndata = null; try { if (maincont == null) { maincont = ExplorerContext.getCurContext(expContext); } int span = Math.max(1, this.maincont.getSpan()); NearestNeighbor nn = new NearestNeighbor(span, maincont.getMedianFunction()); BitMask ignore = maincont.getIgnoreMask(); BitMask take = maincont.getBgMask(); if (take != null && take == ignore) { JOptionPane.showMessageDialog( this, "You select the same mask for ignore and bg :-). \nYou should select another mask for the bg (or you get a null result. I will just return the old data."); return rawdata; } if (take != null && take.computePercentage() < 1) { int ans = JOptionPane.showConfirmDialog( this, "<html>The bg mask only has " + take.computePercentage() + "% wells, do you want to still use it?" + "<br><b>Did you already select a region?</b>" + "<br>You might want to use the MaskEditor (and <b>refresh</b> the masks possibly) to check them</html>", "Few wells", JOptionPane.OK_CANCEL_OPTION); if (ans == JOptionPane.CANCEL_OPTION) { return rawdata; } } maincont.setBgMask(take); maincont.setIgnoreMask(ignore); if (prog != null) prog.setMessage( "Masked neighbor subtraction: ignore mask " + ignore + " and empty mask " + take); // RasterData nndata = nn.compute(rawdata, mask, prog, span); // p("calling computebetter"); // if (boxslow.isSelected()) nndata =nn.computeSlow(rawdata, ignore, take, prog, span); nndata = nn.computeBetter(rawdata, ignore, take, prog, span); } catch (Exception e) { p("Error with nn: " + ErrorHandler.getString(e)); JOptionPane.showMessageDialog( this, "I was not able to do the masked neighbor subtraction:\n" + ErrorHandler.getString(e)); return null; } if (nndata == null) { JOptionPane.showMessageDialog( this, "I was not able to do the masked neighbor subtraction - I got no error but also no result :-) "); } return nndata; }