public boolean quitting() { if (hasInstance()) return IJ.getInstance().quitting(); return false; }
public void focusGained(FocusEvent e) { if (!Interpreter.isBatchMode() && ij!=null && !ij.quitting() && imp!=null) { if (IJ.debugMode) IJ.log("focusGained: "+imp); WindowManager.setCurrentWindow(this); } }
/** 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(); }
static public void destroy() { if (null != IJ.getInstance() && !IJ.getInstance().quitting()) { setImageJToolbar(); } }
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); } } }
public void focusGained(FocusEvent e) { if (!Interpreter.isBatchMode() && ij!=null && !ij.quitting() && imp!=null) { if (IJ.debugMode) IJ.log("focusGained: "+imp); WindowManager.setCurrentWindow(this); } }
/** 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(""); }
/** * 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; }
if (ijInstance.quitting()) { return;
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); }
if (ijInstance.quitting()) { return;
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); }
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; }
@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); } }
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; }
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 }
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 }
/** 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 */
/** 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; }
/** 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; }