/** Called by ImageJ when the user selects Quit. */ public void quit() { quitMacro = IJ.macroRunning(); Thread thread = new Thread(this, "Quit"); thread.setPriority(Thread.NORM_PRIORITY); thread.start(); IJ.wait(10); }
/** Called by ImageJ when the user selects Quit. */ public void quit() { quitMacro = IJ.macroRunning(); Thread thread = new Thread(this, "Quit"); thread.setPriority(Thread.NORM_PRIORITY); thread.start(); IJ.wait(10); }
public static void recordCall(String call, boolean recordCommand) { if (IJ.debugMode) IJ.log("recordCall: "+call+" "+commandName); boolean isMacro = Thread.currentThread().getName().endsWith("Macro$") && !recordInMacros; if (textArea!=null && scriptMode && !IJ.macroRunning() && !isMacro) { if (javaMode() && call.startsWith("rm.setSelected")) { call = call.replace("[", "new int[]{"); call = call.replace("])", "})"); } if (javaMode() && call.startsWith("rt = ")) call = "ResultTable " + call; textArea.append(call+"\n"); if (!recordCommand) commandName = null; } }
public static void recordCall(String call, boolean recordCommand) { if (IJ.debugMode) IJ.log("recordCall: "+call+" "+commandName); boolean isMacro = Thread.currentThread().getName().endsWith("Macro$") && !recordInMacros; if (textArea!=null && scriptMode && !IJ.macroRunning() && !isMacro) { if (javaMode() && call.startsWith("rm.setSelected")) { call = call.replace("[", "new int[]{"); call = call.replace("])", "})"); } if (javaMode() && call.startsWith("rt = ")) call = "ResultTable " + call; textArea.append(call+"\n"); if (!recordCommand) commandName = null; } }
public synchronized void showDialog() { super.showDialog(); if (isMacro()) return; if (!IJ.macroRunning()) { // add to Window menu on event dispatch thread final NonBlockingGenericDialog thisDialog = this; EventQueue.invokeLater(new Runnable() { public void run() { WindowManager.addWindow(thisDialog); } }); } try { wait(); } catch (InterruptedException e) { } }
public synchronized void showDialog() { super.showDialog(); if (isMacro()) return; if (!IJ.macroRunning()) { // add to Window menu on event dispatch thread final NonBlockingGenericDialog thisDialog = this; EventQueue.invokeLater(new Runnable() { public void run() { WindowManager.addWindow(thisDialog); } }); } try { wait(); } catch (InterruptedException e) { } }
@Override public void run(final String arg) { if (!IJ.macroRunning()) { IJ.error("Cannot install extensions from outside a macro!"); return; } Functions.registerExtensions(this); }
@Override public void run(String arg) { if (!LibraryChecker.checkImageJ()) return; if (!IJ.macroRunning()) { IJ.error("Cannot install extensions from outside a macro."); return; } Functions.registerExtensions(this); }
@Override public void run(String arg) { if (!LibraryChecker.checkImageJ()) return; if (!IJ.macroRunning()) { IJ.error("Cannot install extensions from outside a macro."); return; } Functions.registerExtensions(this); }
private void rotate(ImagePlus imp) { Roi roi = imp.getRoi(); if (IJ.macroRunning()) { String options = Macro.getOptions(); if (options!=null && (options.indexOf("grid=")!=-1||options.indexOf("interpolat")!=-1)) { IJ.run("Rotate... ", options); // run Image>Transform>Rotate return; } } (new RoiRotator()).run(""); }
private void rotate(ImagePlus imp) { Roi roi = imp.getRoi(); if (IJ.macroRunning()) { String options = Macro.getOptions(); if (options!=null && (options.indexOf("grid=")!=-1||options.indexOf("interpolat")!=-1)) { IJ.run("Rotate... ", options); // run Image>Transform>Rotate return; } } (new RoiRotator()).run(""); }
/** Locks the image so other threads can test to see if it is in use. Returns true if the image was successfully locked. Beeps, displays a message in the status bar, and returns false if the image is already locked. */ public synchronized boolean lock() { if (locked) { IJ.beep(); IJ.showStatus("\"" + title + "\" is locked"); if (IJ.macroRunning()) IJ.wait(500); return false; } else { locked = true; return true; } }
/** Locks the image so other threads can test to see if it is in use. Returns true if the image was successfully locked. Beeps, displays a message in the status bar, and returns false if the image is already locked. */ public synchronized boolean lock() { if (locked) { IJ.beep(); IJ.showStatus("\"" + title + "\" is locked"); if (IJ.macroRunning()) IJ.wait(500); return false; } else { locked = true; return true; } }
void print(ImagePlus imp) { PrinterJob pj = PrinterJob.getPrinterJob(); pj.setPrintable(this); //pj.pageDialog(pj.defaultPage()); if (IJ.macroRunning() || pj.printDialog()) { imp.startTiming(); try {pj.print(); } catch (PrinterException e) { IJ.log(""+e); } } }
void print(ImagePlus imp) { PrinterJob pj = PrinterJob.getPrinterJob(); pj.setPrintable(this); //pj.pageDialog(pj.defaultPage()); if (IJ.macroRunning() || pj.printDialog()) { imp.startTiming(); try {pj.print(); } catch (PrinterException e) { IJ.log(""+e); } } }
public static boolean showCompositeAdvisory(ImagePlus imp, String title) { if (imp==null || imp.getCompositeMode()!=IJ.COMPOSITE || imp.getNChannels()==1 || IJ.macroRunning()) return true; String msg = "Channel "+imp.getC()+" of this color composite image will be processed."; GenericDialog gd = new GenericDialog(title); gd.addMessage(msg); gd.showDialog(); return !gd.wasCanceled(); }
public static boolean showCompositeAdvisory(ImagePlus imp, String title) { if (imp==null || imp.getCompositeMode()!=IJ.COMPOSITE || imp.getNChannels()==1 || IJ.macroRunning()) return true; String msg = "Channel "+imp.getC()+" of this color composite image will be processed."; GenericDialog gd = new GenericDialog(title); gd.addMessage(msg); gd.showDialog(); return !gd.wasCanceled(); }
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); } }
static boolean swapImages(ImagePlus imp1, ImagePlus imp2) { if (imp1.getWidth()!=imp2.getWidth() || imp1.getHeight()!=imp2.getHeight() || imp1.getBitDepth()!=imp2.getBitDepth() || IJ.macroRunning()) return false; ImageProcessor ip1 = imp1.getProcessor(); ImageProcessor ip2 = imp2.getProcessor(); double min1 = ip1.getMin(); double max1 = ip1.getMax(); double min2 = ip2.getMin(); double max2 = ip2.getMax(); ip2.setSnapshotPixels(ip1.getPixels()); ip2.swapPixelArrays(); ip1.setPixels(ip2.getSnapshotPixels()); ip2.setSnapshotPixels(null); ip1.setMinAndMax(min2, max2); ip2.setMinAndMax(min1, max1); return true; }