Skip to content

Commit b026637

Browse files
committed
2024.11.09 (1.54m23; Overlay.setMinStrokeWidth)
1 parent 8dceb82 commit b026637

File tree

6 files changed

+51
-21
lines changed

6 files changed

+51
-21
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.54m";
82-
public static final String BUILD = "18";
82+
public static final String BUILD = "23";
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/Overlay.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class Overlay implements Iterable<Roi> {
2121
private boolean isCalibrationBar;
2222
private boolean selectable = true;
2323
private boolean draggable = true;
24+
private double minStrokeWidth = -1;
2425

2526
/** Constructs an empty Overlay. */
2627
public Overlay() {
@@ -36,8 +37,11 @@ public Overlay(Roi roi) {
3637

3738
/** Adds an ROI to this Overlay. */
3839
public void add(Roi roi) {
39-
if (roi!=null)
40+
if (roi!=null) {
41+
if (minStrokeWidth>=0)
42+
roi.setMinStrokeWidth(minStrokeWidth);
4043
list.add(roi);
44+
}
4145
}
4246

4347
/** Adds an ROI to this Overlay using the specified name. */
@@ -479,6 +483,11 @@ public void setDraggable(boolean draggable) {
479483
this.draggable = draggable;
480484
}
481485

486+
/** Sets the minimum scaled stroke width (default is 0.05). */
487+
public void setMinStrokeWidth(double minWidth) {
488+
minStrokeWidth = minWidth;
489+
}
490+
482491
/** Returns 'true' if ROIs in this overlay can be dragged by their labels. */
483492
public boolean isDraggable() {
484493
return draggable;

ij/gui/Roi.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public class Roi extends Object implements Cloneable, java.io.Serializable, Iter
7777
private static int defaultGroup; // zero is no specific group
7878
private static Color groupColor;
7979
private static double defaultStrokeWidth;
80+
private static float defaultMinStrokeWidth = 0.05f;
81+
private float minStrokeWidth = defaultMinStrokeWidth;
8082
private static String groupNamesString = Prefs.get(NAMES_KEY, null);
8183
private static String[] groupNames;
8284
private static boolean groupNamesChanged;
@@ -2065,6 +2067,7 @@ public void setNonScalable(boolean nonScalable) {
20652067
* @see #setUnscalableStrokeWidth(double)
20662068
* @see #setStrokeColor(Color)
20672069
* @see ij.ImagePlus#setOverlay(ij.gui.Overlay)
2070+
* @see setMineStrokeWidth(double)
20682071
*/
20692072
public void setStrokeWidth(float strokeWidth) {
20702073
if (strokeWidth<0f)
@@ -2091,6 +2094,11 @@ public void setStrokeWidth(double strokeWidth) {
20912094
setStrokeWidth((float)strokeWidth);
20922095
}
20932096

2097+
/** Sets the minimum scaled stroke width (default=0.05). */
2098+
public void setMinStrokeWidth(double minWidth) {
2099+
minStrokeWidth = (float)minWidth;
2100+
}
2101+
20942102
/** Sets the width of the line used to draw this ROI and
20952103
* prevents the width from increasing when the image
20962104
* is zoomed.
@@ -2132,7 +2140,8 @@ protected BasicStroke getScaledStroke() {
21322140
double mag = ic.getMagnification();
21332141
if (mag!=1.0) {
21342142
float width = (float)(stroke.getLineWidth()*mag);
2135-
//return new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
2143+
if (width<minStrokeWidth)
2144+
width = minStrokeWidth;
21362145
return new BasicStroke(width, stroke.getEndCap(), stroke.getLineJoin(), stroke.getMiterLimit(), stroke.getDashArray(), stroke.getDashPhase());
21372146
} else
21382147
return stroke;

ij/macro/Functions.java

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6765,16 +6765,6 @@ else if (name.equals("paste")) {
67656765
getImage().setOverlay(overlayClipboard);
67666766
return Double.NaN;
67676767
} else if (name.equals("pasteAndMerge")) {
6768-
/*
6769-
interp.getParens();
6770-
if (overlayClipboard==null)
6771-
interp.error("Overlay clipboard empty");
6772-
Overlay overlay = getImage().getOverlay();
6773-
if (overlay!=null)
6774-
getImage().setOverlay(overlay.add(overlayClipboard));
6775-
else
6776-
getImage().setOverlay(overlayClipboard);
6777-
*/
67786768
return Double.NaN;
67796769
} else if (name.equals("drawLabels")) {
67806770
overlayDrawLabels = getBooleanArg();
@@ -6798,11 +6788,13 @@ else if (name.equals("paste")) {
67986788
if (overlay==null && name.equals("size")) {
67996789
interp.getParens();
68006790
return 0.0;
6801-
} else if (name.equals("hidden"))
6791+
} else if (name.equals("hidden")) {
68026792
return overlay!=null && imp.getHideOverlay()?1.0:0.0;
6803-
else if (name.equals("addSelection") || name.equals("addRoi"))
6793+
} else if (name.equals("setMinStrokeWidth")) {
6794+
return setMinStrokeWidth(imp, overlay);
6795+
} else if (name.equals("addSelection") || name.equals("addRoi")) {
68046796
return overlayAddSelection(imp, overlay);
6805-
else if (name.equals("setPosition")) {
6797+
} else if (name.equals("setPosition")) {
68066798
addDrawingToOverlay(imp);
68076799
return overlaySetPosition(overlay);
68086800
} else if (name.equals("setFillColor"))
@@ -6954,7 +6946,7 @@ private double activateSelection(ImagePlus imp, Overlay overlay, boolean wait) {
69546946
ResultsTable.selectRow(roi);
69556947
return Double.NaN;
69566948
}
6957-
6949+
69586950
private double getOverlayElementBounds(Overlay overlay) {
69596951
int index = (int)getFirstArg();
69606952
Variable x = getNextVariable();
@@ -6971,7 +6963,7 @@ private double getOverlayElementBounds(Overlay overlay) {
69716963
height.setValue(r.height);
69726964
return Double.NaN;
69736965
}
6974-
6966+
69756967
double overlayAddSelection(ImagePlus imp, Overlay overlay) {
69766968
String strokeColor = null;
69776969
double strokeWidth = Double.NaN;
@@ -7014,6 +7006,16 @@ private double getOverlayElementBounds(Overlay overlay) {
70147006
return Double.NaN;
70157007
}
70167008

7009+
private double setMinStrokeWidth(ImagePlus imp, Overlay overlay) {
7010+
double minStrokeWidth = getArg();
7011+
if (overlay==null) {
7012+
overlay = new Overlay();
7013+
imp.setOverlay(overlay);
7014+
}
7015+
overlay.setMinStrokeWidth(minStrokeWidth);
7016+
return Double.NaN;
7017+
}
7018+
70177019
double overlaySetPosition(Overlay overlay) {
70187020
int c=0, z=0, t=0;
70197021
int nargs = 1;
@@ -7813,7 +7815,10 @@ private Variable doRoi() {
78137815
return new Variable(Colors.colorToString(color));
78147816
}
78157817
ImagePlus imp = getImage();
7816-
if (name.equals("paste")) {
7818+
if (name.equals("setMinStrokeWidth")) {
7819+
setMinStrokeWidth(imp, imp.getOverlay());
7820+
return null;
7821+
} else if (name.equals("paste")) {
78177822
interp.getParens();
78187823
//IJ.log("paste: "+roiClipboard);
78197824
if (roiClipboard!=null)

ij/process/StackConverter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ public void convertToGray16() {
173173
}
174174
((CompositeImage)imp).setLuts(luts);
175175
imp.updateAndDraw();
176-
}
176+
} else if (scale)
177+
imp.setDisplayRange(0,65535);
177178
}
178179

179180
/** Converts this Stack to 32-bit (float) grayscale. */

release-notes.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
<body>
77

88

9-
<li> <u>1.54m16 28 October 2024</u>
9+
<li> <u>1.54m23 9 November 2024</u>
1010
<ul>
11+
<li> Thanks to Kenneth Sloan, added the Overlay.setMinStrokeWidth(minStrokeWidth)
12+
macro function and Java method that you can use to specify a
13+
minimum scaled stroke width
14+
(<a href="http://wsr.imagej.net/macros/Polygons.ijm">example</a>). DOC
1115
<li> Thanks to Michael Cammer, the <i>Orthogonal Views</i> command
1216
no longer removes overlays.
1317
<li> Thanks to 'Patricia' and Herbie Gluender, the
@@ -36,6 +40,8 @@
3640
-batch option.
3741
<li> Thanks to Guenter Pudmich, fixed bug with the calculation
3842
of 16 and 32 bit histogram bin widths.
43+
<li> Thanks to Gilles Carpentier, fixed several Hyperstack type
44+
conversion bugs.
3945
</ul>
4046

4147
<li> <u>1.54k 15 September 2024</u>

0 commit comments

Comments
 (0)