/** Using the specified image, runs the ROI Manager "Add", "Add & Draw", "Update", "Delete", "Measure", "Draw", "Show All", "Show None", "Fill", "Deselect", "Select All", "Combine", "AND", "XOR", "Split", "Sort" or "Multi Measure" command. */ public boolean runCommand(ImagePlus imp, String cmd) { WindowManager.setTempCurrentImage(imp); boolean ok = runCommand(cmd); WindowManager.setTempCurrentImage(null); return ok; }
/** Using the specified image, runs the ROI Manager "Add", "Add & Draw", "Update", "Delete", "Measure", "Draw", "Show All", "Show None", "Fill", "Deselect", "Select All", "Combine", "AND", "XOR", "Split", "Sort" or "Multi Measure" command. */ public boolean runCommand(ImagePlus imp, String cmd) { WindowManager.setTempCurrentImage(imp); boolean ok = runCommand(cmd); WindowManager.setTempCurrentImage(null); return ok; }
public static void removeBatchModeImage(ImagePlus imp) { if (imageTable!=null && imp!=null) { int index = imageTable.indexOf(imp); if (index!=-1) { imageTable.remove(index); imageActivations.remove(imp); WindowManager.setTempCurrentImage(getLastBatchModeImage()); } } }
public static void removeBatchModeImage(ImagePlus imp) { if (imageTable!=null && imp!=null) { int index = imageTable.indexOf(imp); if (index!=-1) { imageTable.remove(index); imageActivations.remove(imp); WindowManager.setTempCurrentImage(getLastBatchModeImage()); } } }
/** Runs the specified plugin using the specified image. */ public static Object runPlugIn(ImagePlus imp, String className, String arg) { if (imp!=null) { ImagePlus temp = WindowManager.getTempCurrentImage(); WindowManager.setTempCurrentImage(imp); Object o = runPlugIn("", className, arg); WindowManager.setTempCurrentImage(temp); return o; } else return runPlugIn(className, arg); }
/** Runs the specified plugin using the specified image. */ public static Object runPlugIn(ImagePlus imp, String className, String arg) { if (imp!=null) { ImagePlus temp = WindowManager.getTempCurrentImage(); WindowManager.setTempCurrentImage(imp); Object o = runPlugIn("", className, arg); WindowManager.setTempCurrentImage(temp); return o; } else return runPlugIn(className, arg); }
private boolean runMacro(String macro, ImagePlus imp) { WindowManager.setTempCurrentImage(imp); Interpreter interp = new Interpreter(); try { outputImage = interp.runBatchMacro(macro, imp); } catch(Throwable e) { interp.abortMacro(); String msg = e.getMessage(); if (!(e instanceof RuntimeException && msg!=null && e.getMessage().equals(Macro.MACRO_CANCELED))) IJ.handleException(e); return false; } finally { WindowManager.setTempCurrentImage(null); } return true; }
/** Deprecated; replaced by ij.plugin.ChannelSplitter. */ public void split(ImagePlus imp) { WindowManager.setTempCurrentImage(imp); (new ChannelSplitter()).run(""); }
public static void setActiveImage(final String name) { final Module m = getActiveModule(); if (m == null) return; final Object value = m.getInput(name); if (value == null || !(value instanceof ImagePlus)) return; WindowManager.setTempCurrentImage((ImagePlus) value); }
/** * Modifies legacy ImageJ data structures so that there are no dangling * references to an obsolete ImagePlus. */ public static void deleteImagePlus(final ImagePlus imp) { final ImagePlus currImagePlus = WindowManager.getCurrentImage(); if (imp == currImagePlus) WindowManager.setTempCurrentImage(null); Interpreter.removeBatchModeImage(imp); }
public void destroy() { flush(); WindowManager.setTempCurrentImage(imp); // the FakeImagePlus WindowManager.removeWindow(fake_win); // the FakeImageWindow }
/** Deprecated; replaced by ij.plugin.ChannelSplitter. */ public void split(ImagePlus imp) { WindowManager.setTempCurrentImage(imp); (new ChannelSplitter()).run(""); }
/** Runs an ImageJ command using the specified image and options. To generate run() calls, start the recorder (Plugins/Macro/Record) and run commands from the ImageJ menu bar.*/ public static void run(ImagePlus imp, String command, String options) { if (ij==null && Menus.getCommands()==null) init(); if (imp!=null) { ImagePlus temp = WindowManager.getTempCurrentImage(); WindowManager.setTempCurrentImage(imp); run(command, options); WindowManager.setTempCurrentImage(temp); } else run(command, options); }
/** Runs an ImageJ command using the specified image and options. To generate run() calls, start the recorder (Plugins/Macro/Record) and run commands from the ImageJ menu bar.*/ public static void run(ImagePlus imp, String command, String options) { if (ij==null && Menus.getCommands()==null) init(); if (imp!=null) { ImagePlus temp = WindowManager.getTempCurrentImage(); WindowManager.setTempCurrentImage(imp); run(command, options); WindowManager.setTempCurrentImage(temp); } else run(command, options); }
private String runOnVirtualLayerSet(final String command, final LayerSet layer_set, Display display) { ImagePlus imp = layer_set.createLayerStack(Displayable.class, ImagePlus.COLOR_RGB, display.getDisplayChannelAlphas()).getImagePlus(); WindowManager.setTempCurrentImage(imp); return command; }
private void setTempCurrentImage() { WindowManager.setCurrentWindow(canvas.getFakeImagePlus().getWindow()); WindowManager.setTempCurrentImage(canvas.getFakeImagePlus()); }
/** Closes this image and sets the ImageProcessor to null. To avoid the "Save changes?" dialog, first set the public 'changes' variable to false. */ public void close() { ImageWindow win = getWindow(); if (win!=null) win.close(); else { if (WindowManager.getCurrentImage()==this) WindowManager.setTempCurrentImage(null); deleteRoi(); //save any ROI so it can be restored later Interpreter.removeBatchModeImage(this); } }
/** Closes this image and sets the ImageProcessor to null. To avoid the "Save changes?" dialog, first set the public 'changes' variable to false. */ public void close() { ImageWindow win = getWindow(); if (win!=null) win.close(); else { if (WindowManager.getCurrentImage()==this) WindowManager.setTempCurrentImage(null); deleteRoi(); //save any ROI so it can be restored later Interpreter.removeBatchModeImage(this); } }
/** Set as current image the Patch ImagePlus only for half a second, for a plugin to see it and grab a pointer. * YES this is a tremendous hack that may not work in all situations, but will be reasonably ok for PlugInFilter operations. * This action is intended for commands that don't alter the original image. * */ private String setTempCurrentImage(final String command, final Displayable active) { if (!isPatch(command, active)) return null; final Patch pa = (Patch)active; final Project project = pa.getProject(); WindowManager.setTempCurrentImage(pa.getImagePlus()); project.getLoader().releaseToFit((long)(project.getLoader().estimateImageFileSize(pa, 0) * 5)); return command; }
/** Duplicate the active image (if any) and set it as active, so the command is run on it. */ private String duplicate(final String command, final Displayable active) { if (!isPatch(command, active)) return null; Patch pa = (Patch)active; Project project = pa.getProject(); project.getLoader().releaseToFit((long)(project.getLoader().estimateImageFileSize(pa, 0) * 5)); ImagePlus imp = new ImagePlus("Copy of " + pa.getTitle(), pa.getImageProcessor().duplicate()); // don't show it yet WindowManager.setTempCurrentImage(imp); imp.show(); // now execute command return command; }