Skip to content

Commit 484e05e

Browse files
committed
2025.12.21 (1.54s11; ROI group number)
1 parent 43bc6b3 commit 484e05e

File tree

10 files changed

+71
-29
lines changed

10 files changed

+71
-29
lines changed

ij/ImageJ.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class ImageJ extends Frame implements ActionListener,
7979

8080
/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
8181
public static final String VERSION = "1.54s";
82-
public static final String BUILD = "6";
82+
public static final String BUILD = "11";
8383
public static Color backgroundColor = new Color(237,237,237);
8484
/** SansSerif, 12-point, plain font. */
8585
public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);

ij/gui/ImageCanvas.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,20 @@ private void drawOverlay(Overlay overlay, Graphics g) {
337337
if (hyperstack) {
338338
int position = roi.getPosition();
339339
if (position>0) {
340-
if (z==0 && imp.getNSlices()>1)
340+
if (imp.getNChannels()==stackSize) {
341+
c = position;
342+
z = t = 0;
343+
} else if (imp.getNSlices()==stackSize) {
341344
z = position;
342-
else if (t==0)
345+
c = t = 0;
346+
} else if (imp.getNFrames()==stackSize) {
343347
t = position;
348+
c = z = 0;
349+
}
344350
}
345-
//IJ.log("drawOverlay: i="+i+", pos="+roi.getPosition()+" "+c+" "+z+" "+t+" "+roiManagerShowAllMode);
346-
if (((c==0||c==channel) && (z==0||z==slice) && (t==0||t==frame)) || roiManagerShowAllMode || position == PointRoi.POINTWISE_POSITION)
351+
boolean match = (c==0||c==channel) && (z==0||z==slice) && (t==0||t==frame);
352+
//IJ.log("drawOverlay1: i="+i+", pos="+roi.getPosition()+" "+c+" "+z+" "+t+" "+match+" "+roiManagerShowAllMode);
353+
if (match || roiManagerShowAllMode || position==PointRoi.POINTWISE_POSITION)
347354
drawRoi(g, roi, drawLabels?i+LIST_OFFSET:-1);
348355
} else {
349356
int position = stackSize>1?roi.getPosition():0;

ij/gui/Roi.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class Roi extends Object implements Cloneable, java.io.Serializable, Iter
5555
public static final int FERET_ARRAYSIZE = 16; // Size of array with Feret values
5656
public static final int FERET_ARRAY_POINTOFFSET = 8; // Where point coordinates start in Feret array
5757
private static final String NAMES_KEY = "group.names";
58+
public static final int MAX_ROI_GROUP = 65535; // limit to uint16 max value
5859

5960
static final int NO_MODS=0, ADD_TO_ROI=1, SUBTRACT_FROM_ROI=2; // modification states
6061

@@ -1807,7 +1808,7 @@ public static int getDefaultGroup() {
18071808
* @see #getGroupColor
18081809
*/
18091810
public static void setDefaultGroup(int group) {
1810-
if (group<0 || group>255)
1811+
if (group<0 || group>MAX_ROI_GROUP)
18111812
throw new IllegalArgumentException("Invalid group: "+group);
18121813
defaultGroup = group;
18131814
groupColor = getGroupColor(group);
@@ -1820,7 +1821,7 @@ public int getGroup() {
18201821

18211822
/** Returns the group name associtated with the specified group. */
18221823
public static String getGroupName(int groupNumber) {
1823-
if (groupNumber<1 || groupNumber>255)
1824+
if (groupNumber<1 || groupNumber>MAX_ROI_GROUP)
18241825
return null;
18251826
if (groupNames==null && groupNamesString==null)
18261827
return null;
@@ -1835,7 +1836,7 @@ public static String getGroupName(int groupNumber) {
18351836
}
18361837

18371838
public static synchronized void setGroupName(int groupNumber, String name) {
1838-
if (groupNumber<1 || groupNumber>255)
1839+
if (groupNumber<1 || groupNumber>MAX_ROI_GROUP)
18391840
return;
18401841
if (groupNamesString==null && groupNames==null)
18411842
groupNames = new String[groupNumber];
@@ -1884,8 +1885,8 @@ public static void setGroupNames(String names) {
18841885

18851886
/** Sets the group of this Roi, and updates stroke color accordingly. */
18861887
public void setGroup(int group) {
1887-
if (group<0 || group>255)
1888-
throw new IllegalArgumentException("Invalid group: "+group);
1888+
if (group<0 || group>MAX_ROI_GROUP)
1889+
group = 0;
18891890
if (group>0)
18901891
setStrokeColor(getGroupColor(group));
18911892
if (group==0 && this.group>0)

ij/gui/RoiDefaultsDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) {
5454
int group = (int)gd.getNextNumber();
5555
Vector stringFields = gd.getStringFields();
5656
TextField nameField = (TextField)(stringFields.get(0));
57-
if (group>=0 && group<=255 && group!=currentGroup) {
57+
if (group>=0 && group<=Roi.MAX_ROI_GROUP && group!=currentGroup) {
5858
Roi.setDefaultGroup(group);
5959
String name = getGroupName(group);
6060
nameField.setText(name);

ij/gui/RoiProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ public void textValueChanged(TextEvent e) {
419419
TextField tf = (TextField) e.getSource();
420420
String str = tf.getText();
421421
double group = Tools.parseDouble(str, Double.NaN);
422-
if (!Double.isNaN(group) && group>=0 && group<=255) {
422+
if (!Double.isNaN(group) && group>=0 && group<=Roi.MAX_ROI_GROUP) {
423423
roi.setGroup((int)group);
424424
String name = Roi.getGroupName((int)group);
425425
if (name==null)

ij/io/RoiDecoder.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public class RoiDecoder {
8989
public static final int ROI_PROPS_OFFSET = 40;
9090
public static final int ROI_PROPS_LENGTH = 44;
9191
public static final int COUNTERS_OFFSET = 48;
92+
public static final int GROUP_EXTENDED = 52; //short (uint16) for groups > 255
9293

9394
// subtypes
9495
public static final int TEXT = 1;
@@ -207,7 +208,11 @@ public Roi getRoi() throws IOException {
207208
overlayFontSize = getShort(hdr2Offset+OVERLAY_FONT_SIZE);
208209
imageOpacity = getByte(hdr2Offset+IMAGE_OPACITY);
209210
imageSize = getInt(hdr2Offset+IMAGE_SIZE);
210-
group = getByte(hdr2Offset+GROUP);
211+
int groupByte = getByte(hdr2Offset+GROUP);
212+
if (version>=229 && groupByte==0 && hdr2Offset+GROUP_EXTENDED+2<=size)
213+
group = getUnsignedShort(hdr2Offset+GROUP_EXTENDED);
214+
else
215+
group = groupByte;
211216
}
212217

213218
if (name!=null && name.endsWith(".roi"))

ij/io/RoiEncoder.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
public class RoiEncoder {
1616
static final int HEADER_SIZE = 64;
1717
static final int HEADER2_SIZE = 64;
18-
static final int VERSION = 228; // v1.52t (roi groups, scale stroke width)
18+
static final int VERSION = 229; // v1.54s (extended roi groups via uint16)
1919
private String path;
2020
private OutputStream f;
2121
private final int polygon=0, rect=1, oval=2, line=3, freeline=4, polyline=5, noRoi=6, freehand=7,
@@ -423,7 +423,12 @@ void putHeader2(Roi roi, int hdr2Offset) {
423423
putProps(roi, hdr2Offset);
424424
if (countersSize>0)
425425
putPointCounters(roi, hdr2Offset);
426-
putByte(hdr2Offset+RoiDecoder.GROUP, roi.getGroup());
426+
int group = roi.getGroup();
427+
if (group > 255) {
428+
putByte(hdr2Offset+RoiDecoder.GROUP, 0); // marker for extended group
429+
putShort(hdr2Offset+RoiDecoder.GROUP_EXTENDED, group);
430+
} else
431+
putByte(hdr2Offset+RoiDecoder.GROUP, group);
427432
}
428433

429434
void putName(Roi roi, int hdr2Offset) {

ij/plugin/ImageInfo.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,22 +534,27 @@ private static String d2s(double n) {
534534
}
535535

536536
private String getImageProperties(ImagePlus imp) {
537-
String s = "";
538537
String[] props = imp.getPropertiesAsArray();
539-
if (props==null)
538+
if (props==null || props.length==0)
540539
return null;
540+
ArrayList list = new ArrayList();
541541
for (int i=0; i<props.length; i+=2) {
542542
String key = props[i];
543543
String value = props[i+1];
544544
if (LUT.nameKey.equals(key) || "UniqueName".equals(key))
545545
continue;
546546
if (key!=null && value!=null && !(key.equals("ShowInfo")||key.equals("Slice_Label"))) {
547547
if (value.length()<80)
548-
s += key + ": " + value + "\n";
548+
list.add(key + ": " + value + "\n");
549549
else
550-
s += key + ": <" + value.length() + " characters>\n";
550+
list.add(key + ": <" + value.length() + " characters>\n");
551551
}
552552
}
553+
String[] arr = (String[])list.toArray(new String[list.size()]);
554+
Arrays.sort(arr);
555+
String s = "";
556+
for (int i=0; i<arr.length; i++)
557+
s += arr[i];
553558
return (s.length()>0)?s:null;
554559
}
555560

ij/plugin/tool/BrushTool.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import ij.process.*;
44
import ij.gui.*;
55
import ij.plugin.Colors;
6+
import ij.plugin.frame.Recorder;
67
import java.awt.*;
78
import java.awt.event.*;
89
import java.util.Vector;
@@ -174,16 +175,18 @@ public void mouseReleased(ImagePlus imp, MouseEvent e) {
174175
}
175176

176177
private void setWidth(int width) {
177-
if (gd==null)
178-
return;
179-
Vector numericFields = gd.getNumericFields();
180-
TextField widthField = (TextField)numericFields.elementAt(0);
181-
widthField.setText(""+width);
182-
Vector sliders = gd.getSliders();
183-
Scrollbar sb = (Scrollbar)sliders.elementAt(0);
184-
sb.setValue(width);
178+
if (gd==null) {
179+
this.width = width;
180+
} else {
181+
Vector numericFields = gd.getNumericFields();
182+
TextField widthField = (TextField)numericFields.elementAt(0);
183+
widthField.setText(""+width);
184+
Vector sliders = gd.getSliders();
185+
Scrollbar sb = (Scrollbar)sliders.elementAt(0);
186+
sb.setValue(width);
187+
}
185188
}
186-
189+
187190
private void setColor(Color c) {
188191
if (gd==null)
189192
return;
@@ -277,9 +280,16 @@ public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) {
277280
if (imp!=null) IJ.run("Undo");
278281
return true;
279282
}
283+
int oldWidth = width;
280284
width = (int)gd.getNextNumber();
281285
if (gd.invalidNumber() || width<0)
282286
width = (int)Prefs.get(widthKey, 1);
287+
if (width!=oldWidth && IJ.recording()) {
288+
if (Recorder.scriptMode())
289+
Recorder.recordCall("BrushTool.setBrushWidth("+width+");");
290+
else
291+
Recorder.recordString("call(\"ij.plugin.tool.BrushTool.setBrushWidth\","+width+");\n");
292+
}
283293
//transparency = (int)gd.getNextNumber();
284294
//if (gd.invalidNumber() || transparency<0 || transparency>100)
285295
// transparency = 100;

release-notes.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@
55
</head>
66
<body>
77

8-
<li> <u>1.54s6 2 October 2025</u>
8+
<li> <u>1.54s11 21 December 2025</u>
99
<ul>
10+
<li> Thanks to Curtis Rueden, increased the maximum ROI group
11+
number from 255 to 65535.
1012
<li> Thanks to Bram van den Broek, macro error messages longer
1113
than 90 characters are displayed on multiple lines and the full
1214
message is displayed in the Debug window.
15+
<li> Thanks to Michael Schmid, the
16+
call("ij.plugin.tool.BrushTool.setBrushWidth",width)
17+
macro function now works when the Brush Options dialog is
18+
not open, and it is now recordable.
19+
<li> Thanks to Jerome Mutterer, fixed regression that caused
20+
"Show All" in the ROI Manager to not work as expected with
21+
composite images.
1322
</ul>
1423

1524
<li> <u>1.54r 25 September 2025</u>

0 commit comments

Comments
 (0)