From 8799326e2cd8b7f23f7f8648e8cb39f11b6f0383 Mon Sep 17 00:00:00 2001 From: Wayne Rasband Date: Fri, 28 Jun 2024 11:33:59 -0400 Subject: [PATCH] 2024.06.28 (1.54k8; RoiManager select) --- functions.html | 6 +-- ij/CommandListener.java | 2 +- ij/IJ.java | 6 +-- ij/ImageJ.java | 2 +- ij/gui/GenericDialog.java | 4 +- ij/gui/ProfilePlot.java | 31 ++++++------- ij/gui/TextRoi.java | 2 +- ij/gui/Toolbar.java | 2 +- ij/io/FileOpener.java | 5 +- ij/plugin/ChannelArranger.java | 2 +- ij/plugin/Duplicator.java | 6 ++- ij/plugin/FFT.java | 2 +- ij/plugin/ImageCalculator.java | 4 +- ij/plugin/Macro_Runner.java | 4 +- ij/plugin/ZProjector.java | 2 +- ij/plugin/filter/Benchmark.java | 2 +- ij/plugin/filter/FFTFilter.java | 2 +- ij/plugin/filter/MaximumFinder.java | 2 +- ij/plugin/filter/ParticleAnalyzer.java | 2 +- ij/plugin/frame/Editor.java | 2 +- ij/plugin/frame/RoiManager.java | 63 ++++++-------------------- ij/plugin/tool/PlugInTool.java | 2 +- ij/process/BinaryProcessor.java | 2 +- ij/process/FHT.java | 2 +- ij/text/TextCanvas.java | 2 +- release-notes.html | 16 +++++-- 26 files changed, 75 insertions(+), 102 deletions(-) diff --git a/functions.html b/functions.html index 143c7f3c0..37f9caedd 100644 --- a/functions.html +++ b/functions.html @@ -14,7 +14,7 @@ - +

Built-in Macro Functions

@@ -5463,9 +5463,9 @@

Built-in Macro Functions

- + -Last updated 2024-06-12 +Last updated 2024-06-17 diff --git a/ij/CommandListener.java b/ij/CommandListener.java index 7ec2870fa..e1a88bce2 100644 --- a/ij/CommandListener.java +++ b/ij/CommandListener.java @@ -2,7 +2,7 @@ /** Plugins that implement this interface are notified when ImageJ is about to run a menu command. There is an example plugin at - http://imagej.nih.gov/ij/plugins/download/misc/Command_Listener.java + http://imagej.net/ij/plugins/download/misc/Command_Listener.java */ public interface CommandListener { diff --git a/ij/IJ.java b/ij/IJ.java index 8e05de270..ab91e6562 100644 --- a/ij/IJ.java +++ b/ij/IJ.java @@ -42,7 +42,7 @@ public class IJ { public static final int COMPOSITE=1, COLOR=2, GRAYSCALE=3; /** @deprecated */ - public static final String URL = "http://imagej.nih.gov/ij"; + public static final String URL = "http://imagej.net/ij"; /** ImageJ website */ public static final String URL2 = "http://imagej.net/ij"; @@ -534,7 +534,7 @@ public static void showStatus(String message, String options) { * @deprecated * replaced by IJ.log(), ResultsTable.setResult() and TextWindow.append(). * There are examples at - * http://imagej.nih.gov/ij/plugins/sine-cosine.html + * http://imagej.net/ij/plugins/sine-cosine.html */ public static void write(String s) { if (textPanel==null && ij!=null) @@ -799,7 +799,7 @@ public static void showMessage(String msg) { /** Displays a message in a dialog box with the specified title. Displays HTML formatted text if 'msg' starts with "". There are examples at - "http://imagej.nih.gov/ij/macros/HtmlDialogDemo.txt". + "http://imagej.net/ij/macros/HtmlDialogDemo.txt". Writes to the Java console if ImageJ is not present. */ public static void showMessage(String title, String msg) { if (ij!=null) { diff --git a/ij/ImageJ.java b/ij/ImageJ.java index 9d5310d6f..9b63dbf28 100644 --- a/ij/ImageJ.java +++ b/ij/ImageJ.java @@ -79,7 +79,7 @@ public class ImageJ extends Frame implements ActionListener, /** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */ public static final String VERSION = "1.54k"; - public static final String BUILD = "3"; + public static final String BUILD = "8"; public static Color backgroundColor = new Color(237,237,237); /** SansSerif, 12-point, plain font. */ public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12); diff --git a/ij/gui/GenericDialog.java b/ij/gui/GenericDialog.java index 8ae212cc9..4c33e6f8f 100644 --- a/ij/gui/GenericDialog.java +++ b/ij/gui/GenericDialog.java @@ -627,7 +627,7 @@ public void addCheckboxGroup(int rows, int columns, String[] labels, boolean[] d * @param labels the labels * @param defaultValues the initial states * @param headings the column headings - * Example: http://imagej.nih.gov/ij/plugins/multi-column-dialog/index.html + * Example: http://imagej.net/ij/plugins/multi-column-dialog/index.html */ public void addCheckboxGroup(int rows, int columns, String[] labels, boolean[] defaultValues, String[] headings) { Panel panel = new Panel(); @@ -1903,7 +1903,7 @@ public void windowClosing(WindowEvent e) { /** Adds a "Help" button that opens the specified URL in the default browser. With v1.46b or later, displays an HTML formatted message if 'url' starts with "". There is an example at - http://imagej.nih.gov/ij/macros/js/DialogWithHelp.js + http://imagej.net/ij/macros/js/DialogWithHelp.js If url is an empty String, pressing the "Help" button does nothing except calling the DialogListeners (if any). See also: setHelpLabel. */ diff --git a/ij/gui/ProfilePlot.java b/ij/gui/ProfilePlot.java index fbad3abf0..fb2beb445 100644 --- a/ij/gui/ProfilePlot.java +++ b/ij/gui/ProfilePlot.java @@ -8,7 +8,7 @@ import ij.measure.*; import ij.plugin.Straightener; -/** Creates a density profile plot of a rectangular selection or line selection. */ +/** Creates a density profile plot of a line or rectangular selection. */ public class ProfilePlot { static final int MIN_WIDTH = 350; @@ -30,12 +30,22 @@ public class ProfilePlot { public ProfilePlot() { } + /** Based on the current line or rectangular selection, + * creates a profile plot that can be retrieved using + * the getPlot() method. + */ public ProfilePlot(ImagePlus imp) { this(imp, false); } - public ProfilePlot(ImagePlus imp, boolean averageHorizontally) { + /** Based on the current rectangular selection, + * creates profile plot, which is a vertical if + * verticalPlot is 'true'. Use the getPlot() method + * to retrieve the plot. + */ + public ProfilePlot(ImagePlus imp, boolean verticalPlot) { this.imp = imp; + boolean averageHorizontally = verticalPlot; Roi roi = imp.getRoi(); if (roi==null) { IJ.error("Profile Plot", "Selection required."); @@ -104,6 +114,7 @@ public void createWindow() { plot.show(); } + /** Returns the profile plot as a Plot object. */ public Plot getPlot() { if (profile==null) return null; @@ -283,22 +294,6 @@ public static double[] getColumnAverageProfile(Rectangle rect, ImageProcessor ip return values2; } - /* - double[] getIrregularProfile(Roi roi, ImageProcessor ip, Calibration cal) { - boolean interpolate = PlotWindow.interpolate; - FloatPolygon p = roi.getFloatPolygon(); - float[][] xyPoints = ((PolygonRoi)roi).getEquidistantPoints(p.xpoints, p.ypoints, p.npoints, 1.0, imp); - float[] xPoints = xyPoints[0]; - float[] yPoints = xyPoints[1]; - double[] values = new double[xPoints.length]; - for (int i=0; i - ImagePlus img = IJ.openImage("http://imagej.nih.gov/ij/images/FluorescentCells.zip"); + ImagePlus img = IJ.openImage("http://imagej.net/ij/images/FluorescentCells.zip"); int[] order = {3,2,1}; ImagePlus img2 = ChannelArranger.run(img, order); img2.setDisplayMode(IJ.COLOR); diff --git a/ij/plugin/Duplicator.java b/ij/plugin/Duplicator.java index e57b8c916..79afcbc8e 100644 --- a/ij/plugin/Duplicator.java +++ b/ij/plugin/Duplicator.java @@ -85,8 +85,10 @@ else if (duplicateStack || imp.getStackSize()==1) { imp2 = crop(imp); recordCrop(imp); } - if (ignoreSelection && roi!=null) + if (ignoreSelection && roi!=null) { imp.setRoi(roi); + imp2.setRoi((Roi)roi.clone()); + } Calibration cal = imp2.getCalibration(); if (roi!=null && (cal.xOrigin!=0.0||cal.yOrigin!=0.0)) { cal.xOrigin -= roi.getBounds().x; @@ -94,7 +96,7 @@ else if (duplicateStack || imp.getStackSize()==1) { } imp2.setTitle(newTitle); imp2.setProp("UniqueName","true"); - if (roi!=null && roi.isArea() && roi.getType()!=Roi.RECTANGLE) { + if (roi!=null && !ignoreSelection && roi.isArea() && roi.getType()!=Roi.RECTANGLE) { Roi roi2 = cropRoi(imp, roi); if (roi2==null) return; diff --git a/ij/plugin/FFT.java b/ij/plugin/FFT.java index 3845cf477..3ebb5f48b 100644 --- a/ij/plugin/FFT.java +++ b/ij/plugin/FFT.java @@ -14,7 +14,7 @@ This class implements the FFT, Inverse FFT and Redisplay Power Spectrum commands in the Process/FFT submenu. It is based on Arlo Reeves' Pascal implementation of the Fast Hartley Transform from NIH Image -(http://imagej.nih.gov/ij/docs/ImageFFT/). +(http://imagej.net/ij/docs/ImageFFT/). The Fast Hartley Transform was restricted by U.S. Patent No. 4,646,256, but was placed in the public domain by Stanford University in 1995 and is now freely available. diff --git a/ij/plugin/ImageCalculator.java b/ij/plugin/ImageCalculator.java index 73664cf55..c751cb394 100644 --- a/ij/plugin/ImageCalculator.java +++ b/ij/plugin/ImageCalculator.java @@ -10,8 +10,8 @@ /** This plugin implements the Process/Image Calculator command.
    // test script
-   imp1 = IJ.openImage("http://imagej.nih.gov/ij/images/boats.gif")
-   imp2 = IJ.openImage("http://imagej.nih.gov/ij/images/bridge.gif")
+   imp1 = IJ.openImage("http://imagej.net/ij/images/boats.gif")
+   imp2 = IJ.openImage("http://imagej.net/ij/images/bridge.gif")
    imp3 = ImageCalculator.run(imp1, imp2, "add create 32-bit");
    imp3.show();
 
diff --git a/ij/plugin/Macro_Runner.java b/ij/plugin/Macro_Runner.java index abd213686..cf6e05904 100644 --- a/ij/plugin/Macro_Runner.java +++ b/ij/plugin/Macro_Runner.java @@ -287,7 +287,7 @@ private static String runScript(Object plugin, String script, String arg) { /** Runs a BeanShell script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function. Returns, as a string, the last expression evaluated by the script. - Uses the plugin at http://imagej.nih.gov/ij/plugins/bsh/ + Uses the plugin at http://imagej.net/ij/plugins/bsh/ to run the script. */ public static String runBeanShell(String script, String arg) { @@ -309,7 +309,7 @@ public static String runBeanShell(String script, String arg) { which the script can retrieve using the getArgument() function. Returns, as a string, the value of the variable 'result'. For example, a Python script containing the line "result=123" will return the string "123". - Uses the plugin at http://imagej.nih.gov/ij/plugins/jython/ + Uses the plugin at http://imagej.net/ij/plugins/jython/ to run the script. */ public static String runPython(String script, String arg) { diff --git a/ij/plugin/ZProjector.java b/ij/plugin/ZProjector.java index e357b7f89..8236ae0db 100644 --- a/ij/plugin/ZProjector.java +++ b/ij/plugin/ZProjector.java @@ -72,7 +72,7 @@ public static ImagePlus run(ImagePlus imp, String method) { /** Performs projection using the specified method and stack range, and returns the result, where 'method' is "avg", "min", "max", "sum", "sd" or "median". Add " all" to 'method' to project all hyperstack time points.
- Example: http://imagej.nih.gov/ij/macros/js/ProjectionDemo.js + Example: http://imagej.net/ij/macros/js/ProjectionDemo.js */ public static ImagePlus run(ImagePlus imp, String method, int startSlice, int stopSlice) { ZProjector zp = new ZProjector(imp); diff --git a/ij/plugin/filter/Benchmark.java b/ij/plugin/filter/Benchmark.java index 56d706dd6..820cada2a 100644 --- a/ij/plugin/filter/Benchmark.java +++ b/ij/plugin/filter/Benchmark.java @@ -7,7 +7,7 @@ /** Implements the Plugins/Utilities/Run Benchmark command when the current image is 512x512 and RGB. Results and additional benchmarks are available at
- "http://imagej.nih.gov/ij/plugins/benchmarks.html". */ + "http://imagej.net/ij/plugins/benchmarks.html". */ public class Benchmark implements PlugInFilter{ String arg; diff --git a/ij/plugin/filter/FFTFilter.java b/ij/plugin/filter/FFTFilter.java index faf943802..ff1aac678 100644 --- a/ij/plugin/filter/FFTFilter.java +++ b/ij/plugin/filter/FFTFilter.java @@ -9,7 +9,7 @@ /** This class implements the Process/FFT/Bandpass Filter command. It is based on -Joachim Walter's FFT Filter plugin at "http://imagej.nih.gov/ij/plugins/fft-filter.html". +Joachim Walter's FFT Filter plugin at "http://imagej.net/ij/plugins/fft-filter.html". 2001/10/29: First Version (JW) 2003/02/06: 1st bugfix (works in macros/plugins, works on stacks, overwrites image(=>filter)) (JW) 2003/07/03: integrated into ImageJ, added "Display Filter" option (WSR) diff --git a/ij/plugin/filter/MaximumFinder.java b/ij/plugin/filter/MaximumFinder.java index cdce2c6ca..160e276fb 100644 --- a/ij/plugin/filter/MaximumFinder.java +++ b/ij/plugin/filter/MaximumFinder.java @@ -249,7 +249,7 @@ public void run(ImageProcessor ip) { /** Finds the image maxima and returns them as a Polygon, where * poly.npoints is the number of maxima. There is an example at
- * http://imagej.nih.gov/ij/macros/js/FindMaxima.js. + * http://imagej.net/ij/macros/js/FindMaxima.js. * @param ip The input image * @param tolerance Height tolerance: maxima are accepted only if protruding more than this value * from the ridge to a higher maximum diff --git a/ij/plugin/filter/ParticleAnalyzer.java b/ij/plugin/filter/ParticleAnalyzer.java index 9cd892834..ac03f197d 100644 --- a/ij/plugin/filter/ParticleAnalyzer.java +++ b/ij/plugin/filter/ParticleAnalyzer.java @@ -1194,7 +1194,7 @@ public static void setLineWidth(int width) { /** Sets the RoiManager to be used by the next ParticleAnalyzer instance. There is a JavaScript example at - http://imagej.nih.gov/ij/macros/js/HiddenRoiManager.js + http://imagej.net/ij/macros/js/HiddenRoiManager.js */ public static void setRoiManager(RoiManager manager) { staticRoiManager = manager; diff --git a/ij/plugin/frame/Editor.java b/ij/plugin/frame/Editor.java index 6dd81b88a..27b683b41 100644 --- a/ij/plugin/frame/Editor.java +++ b/ij/plugin/frame/Editor.java @@ -614,7 +614,7 @@ public void evaluateScript(String ext) { plugin = "bsh"; url = "/plugins/bsh/BeanShell.jar"; } else { - // download Jython from http://imagej.nih.gov/ij/plugins/jython/ + // download Jython from http://imagej.net/ij/plugins/jython/ plugin = "Jython"; url = "/plugins/jython/Jython.jar"; } diff --git a/ij/plugin/frame/RoiManager.java b/ij/plugin/frame/RoiManager.java index b3102fe57..5fbed5aa7 100644 --- a/ij/plugin/frame/RoiManager.java +++ b/ij/plugin/frame/RoiManager.java @@ -389,28 +389,15 @@ else if (color==null && defaultColor!=null) } if (lineWidth>100) lineWidth = 1; int n = getCount(); - int position = imp!=null?roi.getPosition():0; int saveCurrentSlice = imp!=null?imp.getCurrentSlice():0; - if (position>0 && position!=saveCurrentSlice) { - if (imp.lock()) - imp.setSliceWithoutUpdate(position); - else - return false; //can't lock image, must not change the stack slice - } else - position = 0; //we need to revert to the original stack slice and unlock if position>0 if (n>0 && !IJ.isMacro() && imp!=null && !allowDuplicates) { // check for duplicate Roi roi2 = (Roi)rois.get(n-1); if (roi2!=null) { String label = (String)listModel.getElementAt(n-1); int slice2 = getSliceNumber(roi2, label); - if (roi.equals(roi2) && (slice2==-1||slice2==imp.getCurrentSlice()) && imp.getID()==prevID && !Interpreter.isBatchMode()) { - if (position>0) { - imp.setSliceWithoutUpdate(saveCurrentSlice); - imp.unlock(); - } + if (roi.equals(roi2) && (slice2==-1||slice2==imp.getCurrentSlice()) && imp.getID()==prevID && !Interpreter.isBatchMode()) return false; - } } } allowDuplicates = false; @@ -421,19 +408,14 @@ else if (color==null && defaultColor!=null) String label = name!=null?name:getLabel(imp, roi, -1); if (promptForName) label = promptForName(label); - if (label==null) { - if (position>0) { - imp.setSliceWithoutUpdate(saveCurrentSlice); - imp.unlock(); - } + if (label==null) return false; - } listModel.addElement(label); roi.setName(label); Roi roiCopy = (Roi)roi.clone(); - // set ROI position to current stack position if image and RoiManager are visible - if (imp!=null && imp.getStackSize()>1 && imp.getWindow()!=null && isVisible()) - roiCopy.setPosition(imp); + boolean hasPosition = roiCopy.getPosition()>0 || roiCopy.hasHyperStackPosition(); + if (!hasPosition && imp!=null && imp.getStackSize()>1) + roiCopy.setPosition(imp); // set ROI position to current stack position if (lineWidth>1) roiCopy.setStrokeWidth(lineWidth); if (color!=null) @@ -442,10 +424,6 @@ else if (color==null && defaultColor!=null) updateShowAll(); if (record()) recordAdd(defaultColor, defaultLineWidth); - if (position>0) { - imp.setSliceWithoutUpdate(saveCurrentSlice); - imp.unlock(); - } return true; } @@ -708,6 +686,8 @@ String promptForName(String name) { } boolean restore(ImagePlus imp, int index, boolean setSlice) { + if (index>=rois.size()) + return false; Roi roi = (Roi)rois.get(index); if (imp==null || roi==null) return false; @@ -1086,7 +1066,7 @@ boolean measure(ImagePlus imp) { /** This method measures the selected ROIs, or all ROIs if * none are selected, on all the slices of a stack and returns * a ResultsTable arranged with one row per slice. - * @see JavaScript example + * @see JavaScript example */ public ResultsTable multiMeasure(ImagePlus imp) { Roi[] rois = getSelectedRoisAsArray(); @@ -2560,34 +2540,20 @@ public void select(int index) { /** Assigns the ROI at the specified index to 'imp'. */ public void select(ImagePlus imp, int index) { - if (index<0) { - deselect(); + deselect(); + if (index<0) return; - } - int n = getCount(); - if (index>=n) return; - boolean mm = list.getSelectionMode() == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION; - if (mm) - list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - int delay = 1; - long start = System.currentTimeMillis(); - while (true) { - if (list.isSelectedIndex(index)) - break; - list.clearSelection(); - list.setSelectedIndex(index); - } + list.setSelectedIndex(index); if (imp==null) imp = WindowManager.getCurrentImage(); if (imp!=null) restore(imp, index, true); - if (mm) - list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } public void selectAndMakeVisible(ImagePlus imp, int index) { select(imp, index); list.ensureIndexIsVisible(index); + repaint(); } public void select(int index, boolean shiftKeyDown, boolean altKeyDown) { @@ -2649,9 +2615,8 @@ public static void selectGroup(String group) { } public void deselect() { - int n = getCount(); - for (int i=0; i0) { gImage.setColor(Color.darkGray); diff --git a/release-notes.html b/release-notes.html index 08e1ee5f9..feb5ad4e9 100644 --- a/release-notes.html +++ b/release-notes.html @@ -5,8 +5,11 @@ -
  • 1.54k3 15 June 2024 +
  • 1.54k8 28 June 2024
      +
    • Thanks to Herbie Gluender, the Image>Duplicate +command retains the selection when "Ignore Selection" is +checked in the dialog.
    • Thanks to Michael Schmid, file dialogs show the prompt in the status bar, a work around on Macs where file dialogs do not have titles. @@ -15,7 +18,14 @@ first FileInfo from tiff stacks.
    • Thanks to Michael Nonet and Guenter Pudmich, fixed bug with the roiManager("rename",name) macro function causing the -stack position to be lost. +stack position to be lost. +
    • Thanks to Philippe Carl and Michael Schmid, fixed bug +where the roiManager("select",index) macro function did +not remove previous selections. +
    • Thanks to Felix Rudolphi and Curtis Rueden, fixed a +1.54i regression that caused FileOpener to throw +HeadlessExceptions in headless environments. +
  • 1.54j 12 June 2024 @@ -3114,6 +3124,6 @@ analyzer to hang when processong 32-bit images. -Home +Home