ij.ImageJ.quitting()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中ij.ImageJ.quitting()方法的一些代码示例,展示了ImageJ.quitting()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageJ.quitting()方法的具体详情如下:
包路径:ij.ImageJ
类名称:ImageJ
方法名:quitting

ImageJ.quitting介绍

[英]Returns true if ImageJ is exiting.
[中]如果ImageJ正在退出,则返回true。

代码示例

代码示例来源:origin: net.imagej/imagej-legacy

public boolean quitting() {
  if (hasInstance()) return IJ.getInstance().quitting();
  return false;
}

代码示例来源:origin: net.imagej/ij

public void focusGained(FocusEvent e) {
  if (!Interpreter.isBatchMode() && ij!=null && !ij.quitting() && imp!=null) {
    if (IJ.debugMode) IJ.log("focusGained: "+imp);
    WindowManager.setCurrentWindow(this);
  }
}

代码示例来源:origin: sc.fiji/TrakEM2_

/** Release all memory and unregister itself. Child Loader classes should call this method in their destroy() methods. */
synchronized public void destroy() {
  if (null != IJ.getInstance() && IJ.getInstance().quitting()) {
    return; // no need to do anything else
  }
  Utils.showStatus("Releasing all memory ...", false);
  destroyCache();
  // First remove from list:
  v_loaders.remove(this);
  exec.shutdownNow();
  guiExec.quit();
}

代码示例来源:origin: sc.fiji/TrakEM2_

static public void destroy() {
  if (null != IJ.getInstance() && !IJ.getInstance().quitting()) {
    setImageJToolbar();
  }
}

代码示例来源:origin: sc.fiji/TrakEM2_

private void destroyCache() {
  synchronized (db_lock) {
    try {
      final ImageJ ij = IJ.getInstance();
      if (null != ij && ij.quitting()) {
        return;
      }
      if (null != mawts) {
        mawts.removeAndFlushAll();
      }
    } catch (final Throwable t) {
      IJError.print(t);
    }
  }
}

代码示例来源:origin: imagej/ImageJA

public void focusGained(FocusEvent e) {
  if (!Interpreter.isBatchMode() && ij!=null && !ij.quitting() && imp!=null) {
    if (IJ.debugMode) IJ.log("focusGained: "+imp);
    WindowManager.setCurrentWindow(this);
  }
}

代码示例来源:origin: sc.fiji/TrakEM2_

/** Release all memory and unregister itself. */
public void destroy() {
  if (IJ.getInstance().quitting()) {
    if (isConnected()) disconnect();
    return; // no need to do anything else
  }
  super.destroy();
  if (isConnected()) disconnect();
  System.gc();
  //try { Thread.sleep(1000); } catch (Exception e) {}
  //System.gc(); // twice ..
  Utils.showStatus("");
}

代码示例来源:origin: net.imagej/imagej-legacy

/**
 * Forcibly shuts down ImageJ1, with no user interaction or opportunity to
 * cancel. If ImageJ1 is not currently initialized, or if ImageJ1 is already
 * in the process of quitting (i.e., {@link ij.ImageJ#quitting()} returns
 * {@code true}), then this method does nothing.
 */
public synchronized void dispose() {
  final ImageJ ij = IJ.getInstance();
  if (ij != null && ij.quitting()) return; // IJ1 is already on its way out
  disposing = true;
  closeImageWindows();
  disposeNonImageWindows();
  if (ij != null) {
    // quit legacy ImageJ on the same thread
    ij.exitWhenQuitting(false); // do *not* quit the JVM!
    ij.run();
  }
  disposing = false;
}

代码示例来源:origin: net.imagej/ij

if (ijInstance.quitting()) {
  return;

代码示例来源:origin: net.imagej/ij

public static void setImageJMenuBar(ImageWindow win) {
  ImageJ ij = IJ.getInstance();
  boolean setMenuBar = true;
  ImagePlus imp = win.getImagePlus();
  if (imp!=null)
    setMenuBar = imp.setIJMenuBar();
  MenuBar mb = Menus.getMenuBar();
  if (mb!=null && mb==win.getMenuBar())
    setMenuBar = false;
  setMenuBarTime = 0L;
  if (setMenuBar && ij!=null && !ij.quitting() && !Interpreter.nonBatchMacroRunning()) {
    IJ.wait(10); // may be needed for Java 1.4 on OS X
    long t0 = System.currentTimeMillis();
    win.setMenuBar(mb);
    long time = System.currentTimeMillis()-t0;
    setMenuBarTime = time;
    Menus.setMenuBarCount++;
    if (IJ.debugMode) IJ.log("setMenuBar: "+time+"ms ("+Menus.setMenuBarCount+")");
    if (time>2000L)
      Prefs.setIJMenuBar = false;
  }
  if (imp!=null) imp.setIJMenuBar(true);
}

代码示例来源:origin: net.imagej/ij

if (ijInstance.quitting()) {
  return;

代码示例来源:origin: imagej/ImageJA

public static void setImageJMenuBar(ImageWindow win) {
  ImageJ ij = IJ.getInstance();
  boolean setMenuBar = true;
  ImagePlus imp = win.getImagePlus();
  if (imp!=null)
    setMenuBar = imp.setIJMenuBar();
  MenuBar mb = Menus.getMenuBar();
  if (mb!=null && mb==win.getMenuBar())
    setMenuBar = false;
  setMenuBarTime = 0L;
  if (setMenuBar && ij!=null && !ij.quitting() && !Interpreter.nonBatchMacroRunning()) {
    IJ.wait(10); // may be needed for Java 1.4 on OS X
    long t0 = System.currentTimeMillis();
    win.setMenuBar(mb);
    long time = System.currentTimeMillis()-t0;
    setMenuBarTime = time;
    Menus.setMenuBarCount++;
    if (IJ.debugMode) IJ.log("setMenuBar: "+time+"ms ("+Menus.setMenuBarCount+")");
    if (time>2000L)
      Prefs.setIJMenuBar = false;
  }
  if (imp!=null) imp.setIJMenuBar(true);
}

代码示例来源:origin: net.imagej/ij

boolean saveContents() {
  int lineCount = textPanel.getLineCount();
  if (!textPanel.unsavedLines) lineCount = 0;
  ImageJ ij = IJ.getInstance();
  boolean macro = IJ.macroRunning() || Interpreter.isBatchMode();
  boolean isResults = getTitle().contains("Results");
  if (lineCount>0 && !macro && ij!=null && !ij.quitting() && isResults) {
    YesNoCancelDialog d = new YesNoCancelDialog(this, getTitle(), "Save "+lineCount+" measurements?");
    if (d.cancelPressed())
      return false;
    else if (d.yesPressed()) {
      if (!textPanel.saveAs(""))
        return false;
    }
  }
  textPanel.rt.reset();
  return true;
}

代码示例来源:origin: ca.mcgill/Sholl_Analysis

@Override
public void windowClosing(final WindowEvent e) {
  try {
    final TextWindow tw = (TextWindow) e.getWindow();
    final EnhancedResultsTable ert = (EnhancedResultsTable) tw.getTextPanel().getResultsTable();
    if (!(ert.getUnsavedMeasurements() && ert.getCounter() > 0))
      return;
    final ImageJ ij = IJ.getInstance();
    final boolean macro = (IJ.macroRunning()) || Interpreter.isBatchMode();
    if (!macro && ij != null && !ij.quitting()) {
      promptForSave(windowTitle);
    }
  } catch (final Exception exc) {
    IJ.log(">>>> An error occurred when closing table:\n" + exc);
  }
}

代码示例来源:origin: imagej/ImageJA

boolean saveContents() {
  int lineCount = textPanel.getLineCount();
  if (!textPanel.unsavedLines) lineCount = 0;
  ImageJ ij = IJ.getInstance();
  boolean macro = IJ.macroRunning() || Interpreter.isBatchMode();
  boolean isResults = getTitle().contains("Results");
  if (lineCount>0 && !macro && ij!=null && !ij.quitting() && isResults) {
    YesNoCancelDialog d = new YesNoCancelDialog(this, getTitle(), "Save "+lineCount+" measurements?");
    if (d.cancelPressed())
      return false;
    else if (d.yesPressed()) {
      if (!textPanel.saveAs(""))
        return false;
    }
  }
  textPanel.rt.reset();
  return true;
}

代码示例来源:origin: net.imagej/ij

public void windowActivated(WindowEvent e) {
  if (IJ.debugMode) IJ.log("windowActivated: "+imp.getTitle());
  if (IJ.isMacOSX())
    setImageJMenuBar(this);
  if (imp==null)
    return;
  ImageJ ij = IJ.getInstance();
  if (ij!=null && !closed && !ij.quitting() && !Interpreter.isBatchMode())
    WindowManager.setCurrentWindow(this);
  Roi roi = imp.getRoi();
  if (roi!=null && (roi instanceof PointRoi))
    PointToolOptions.update();
  if (imp.isComposite())
    Channels.updateChannels();
  imp.setActivated(); // notify ImagePlus that image has been activated
}

代码示例来源:origin: imagej/ImageJA

public void windowActivated(WindowEvent e) {
  if (IJ.debugMode) IJ.log("windowActivated: "+imp.getTitle());
  if (IJ.isMacOSX())
    setImageJMenuBar(this);
  if (imp==null)
    return;
  ImageJ ij = IJ.getInstance();
  if (ij!=null && !closed && !ij.quitting() && !Interpreter.isBatchMode())
    WindowManager.setCurrentWindow(this);
  Roi roi = imp.getRoi();
  if (roi!=null && (roi instanceof PointRoi))
    PointToolOptions.update();
  if (imp.isComposite())
    Channels.updateChannels();
  imp.setActivated(); // notify ImagePlus that image has been activated
}

代码示例来源:origin: sc.fiji/TrakEM2_

/** Set the source Display as front. */
@Override
public void windowActivated(final WindowEvent we) {
  // find which was it to make it be the front
  final ImageJ ij = IJ.getInstance();
  if (null != ij && ij.quitting()) return;
  final Object source = we.getSource();
  for (final Display d : al_displays) {
    if (source == d.frame) {
      front = d;
      // set toolbar
      ProjectToolbar.setProjectToolbar();
      // now, select the layer in the LayerTree
      front.getProject().select(front.layer);
      // finally, set the virtual ImagePlus that ImageJ will see
      d.setTempCurrentImage();
      // copied from ij.gui.ImageWindow, with modifications
      if (IJ.isMacintosh() && IJ.getInstance()!=null) {
        IJ.wait(10); // may be needed for Java 1.4 on OS X
        d.frame.setMenuBar(Menus.getMenuBar());
      }
      return;
    }
  }
  // else, restore the ImageJ toolbar for non-project images
  //if (!source.equals(IJ.getInstance())) {
  //	ProjectToolbar.setImageJToolbar();
  //}
}
/** Restore the ImageJ toolbar */

代码示例来源:origin: net.imagej/ij

/** Sets the measurement counter to zero. Displays a dialog that
  allows the user to save any existing measurements. Returns
  false if the user cancels the dialog.
*/
public synchronized static boolean resetCounter() {
  TextPanel tp = IJ.isResultsWindow()?IJ.getTextPanel():null;
  int counter = systemRT.size();
  int lineCount = tp!=null?IJ.getTextPanel().getLineCount():0;
  ImageJ ij = IJ.getInstance();
  boolean macro = (IJ.macroRunning()&&!switchingModes) || Interpreter.isBatchMode();
  switchingModes = false;
  if (counter>0 && lineCount>0 && unsavedMeasurements && !macro && ij!=null && !ij.quitting()) {
    YesNoCancelDialog d = new YesNoCancelDialog(ij, "ImageJ", "Save "+counter+" measurements?");
    if (d.cancelPressed())
      return false;
    else if (d.yesPressed()) {
      if (!(new MeasurementsWriter()).save(""))
        return false;
    }
  }
  umeans = null;
  systemRT.reset();
  RoiManager.resetMultiMeasureResults();
  unsavedMeasurements = false;
  if (tp!=null) tp.clear();
  summarized = false;
  return true;
}

代码示例来源:origin: imagej/ImageJA

/** Sets the measurement counter to zero. Displays a dialog that
  allows the user to save any existing measurements. Returns
  false if the user cancels the dialog.
*/
public synchronized static boolean resetCounter() {
  TextPanel tp = IJ.isResultsWindow()?IJ.getTextPanel():null;
  int counter = systemRT.size();
  int lineCount = tp!=null?IJ.getTextPanel().getLineCount():0;
  ImageJ ij = IJ.getInstance();
  boolean macro = (IJ.macroRunning()&&!switchingModes) || Interpreter.isBatchMode();
  switchingModes = false;
  if (counter>0 && lineCount>0 && unsavedMeasurements && !macro && ij!=null && !ij.quitting()) {
    YesNoCancelDialog d = new YesNoCancelDialog(ij, "ImageJ", "Save "+counter+" measurements?");
    if (d.cancelPressed())
      return false;
    else if (d.yesPressed()) {
      if (!(new MeasurementsWriter()).save(""))
        return false;
    }
  }
  umeans = null;
  systemRT.reset();
  RoiManager.resetMultiMeasureResults();
  unsavedMeasurements = false;
  if (tp!=null) tp.clear();
  summarized = false;
  return true;
}

相关文章