Skip to content

Commit 715f940

Browse files
committed
2021.07.06 (1.53k19; GenericDialog.addButton)
1 parent da13b15 commit 715f940

File tree

9 files changed

+52
-54
lines changed

9 files changed

+52
-54
lines changed

ij/ImageJ.java

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

7979
/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
8080
public static final String VERSION = "1.53k";
81-
public static final String BUILD = "16";
81+
public static final String BUILD = ""; //19
8282
public static Color backgroundColor = new Color(237,237,237);
8383
/** SansSerif, 12-point, plain font. */
8484
public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);

ij/Prefs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public class Prefs {
186186
public static boolean supportMacroUndo;
187187
/** Use NonBlockingGenericDialogs in filters */
188188
public static boolean nonBlockingFilterDialogs;
189-
/** Use v=65535-v to invert 16-bit images (more to come) */
189+
/** Currently not used */
190190
public static boolean modernMode;
191191
//Save location of moved image windows */
192192
//public static boolean saveImageLocation = true;

ij/gui/GenericDialog.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,26 @@ public void addFileField(String label, String defaultPath, int columns) {
372372
saveLabel(panel, label);
373373
}
374374

375+
/**
376+
* Add button to the dialog
377+
* @param label button label
378+
* @param listener listener to handle the action when pressing the button
379+
*/
380+
public void addButton(String label, ActionListener listener) {
381+
if (GraphicsEnvironment.isHeadless())
382+
return;
383+
Button button = new Button(label);
384+
button.addActionListener(listener);
385+
button.addKeyListener(this);
386+
GridBagLayout layout = (GridBagLayout)getLayout();
387+
Panel panel = new Panel();
388+
addPanel(panel);
389+
GridBagConstraints constraints = layout.getConstraints(panel);
390+
remove(panel);
391+
layout.setConstraints(button, constraints);
392+
add(button);
393+
}
394+
375395
/** Adds a popup menu that lists the currently open images.
376396
* Call getNextImage() to retrieve the selected
377397
* image. Based on the addImageChoice()

ij/gui/Toolbar.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
import java.awt.image.BufferedImage;
66
import javax.imageio.ImageIO;
77
import java.io.File;
8-
import java.util.*;
8+
import java.util.Timer;
9+
import java.util.Hashtable;
10+
import java.util.TimerTask;
11+
import java.util.Arrays;
12+
import java.util.Locale;
913
import ij.*;
1014
import ij.plugin.frame.*;
1115
import ij.plugin.MacroInstaller;
@@ -1271,7 +1275,7 @@ public void mousePressed(final MouseEvent e) {
12711275

12721276
if (!isRightClick && longClickDelay>0) {
12731277
if (pressTimer==null)
1274-
pressTimer = new java.util.Timer();
1278+
pressTimer = new Timer();
12751279
pressTimer.schedule(new TimerTask() {
12761280
public void run() {
12771281
if (pressTimer != null) {

ij/plugin/Options.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void miscOptions() {
4848
gd.addCheckbox("Save window locations", !Prefs.doNotSaveWindowLocations);
4949
gd.addCheckbox("Non-blocking filter dialogs", Prefs.nonBlockingFilterDialogs);
5050
gd.addCheckbox("Debug mode", IJ.debugMode);
51-
gd.addCheckbox("Modern mode", Prefs.modernMode);
51+
//gd.addCheckbox("Modern mode", Prefs.modernMode);
5252
gd.addHelp(IJ.URL+"/docs/menus/edit.html#misc");
5353
gd.showDialog();
5454
if (gd.wasCanceled())
@@ -84,7 +84,7 @@ else if (divValue.equalsIgnoreCase("max"))
8484
Prefs.doNotSaveWindowLocations = !gd.getNextBoolean();
8585
Prefs.nonBlockingFilterDialogs = gd.getNextBoolean();
8686
IJ.setDebugMode(gd.getNextBoolean());
87-
Prefs.modernMode = gd.getNextBoolean();
87+
//Prefs.modernMode = gd.getNextBoolean();
8888
}
8989

9090
void lineWidth() {

ij/plugin/filter/Filters.java

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,14 @@ public int setup(String arg, ImagePlus imp) {
2020
this.imp = imp;
2121
if (imp!=null) {
2222
Roi roi = imp.getRoi();
23-
if (Prefs.modernMode && imp.getType()==ImagePlus.GRAY16 && arg.equals("invert")) {
23+
if (imp.getType()==ImagePlus.GRAY16 && arg.equals("invert")) {
2424
imp.resetRoi();
2525
roi = null;
2626
}
2727
if (roi!=null && !roi.isArea())
2828
noRoi = true;
2929
}
3030
int flags = IJ.setupDialog(imp, DOES_ALL-DOES_8C+SUPPORTS_MASKING);
31-
if ((flags&PlugInFilter.DOES_STACKS)!=0 && imp.getType()==ImagePlus.GRAY16 && imp.getStackSize()>1 && !Prefs.modernMode && arg.equals("invert")) {
32-
invert16BitStack(imp);
33-
return DONE;
34-
}
3531
return flags;
3632
}
3733

@@ -43,7 +39,7 @@ public void run(ImageProcessor ip) {
4339
if (arg.equals("invert")) {
4440
ip.invert();
4541
slice++;
46-
if (Prefs.modernMode && imp.getBitDepth()==16 && imp.getStackSize()>1 && slice==imp.getStackSize())
42+
if (imp.getBitDepth()==16 && imp.getStackSize()>1 && slice==imp.getStackSize())
4743
imp.resetDisplayRange();
4844
return;
4945
}
@@ -94,28 +90,7 @@ public void run(ImageProcessor ip) {
9490
}
9591

9692
}
97-
98-
void invert16BitStack(ImagePlus imp) {
99-
imp.deleteRoi();
100-
imp.getCalibration().disableDensityCalibration();
101-
ImageStatistics stats = new StackStatistics(imp);
102-
ImageStack stack = imp.getStack();
103-
int nslices = stack.size();
104-
int min=(int)stats.min, range=(int)(stats.max-stats.min);
105-
int n = imp.getWidth()*imp.getHeight();
106-
for (int slice=1; slice<=nslices; slice++) {
107-
ImageProcessor ip = stack.getProcessor(slice);
108-
short[] pixels = (short[])ip.getPixels();
109-
for (int i=0; i<n; i++) {
110-
int before = pixels[i]&0xffff;
111-
pixels[i] = (short)(range-((pixels[i]&0xffff)-min));
112-
}
113-
}
114-
imp.setStack(null, stack);
115-
imp.setDisplayRange(0, range);
116-
imp.updateAndDraw();
117-
}
118-
93+
11994
/** Returns the default standard deviation used by Process/Noise/Add Specified Noise. */
12095
public static double getSD() {
12196
return sd;

ij/process/ShortProcessor.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -567,18 +567,13 @@ private void process(int op, double value) {
567567
}
568568
}
569569
}
570-
570+
571571
public void invert() {
572-
if (ij.Prefs.modernMode)
573-
invert(65536);
574-
else {
575-
resetMinAndMax();
576-
process(INVERT, 0.0);
577-
}
578-
}
579-
580-
public void invert(int range) {
581-
setMinAndMax(0, 65535);
572+
int range = 65536;
573+
int defaultRange = ij.ImagePlus.getDefault16bitRange();
574+
if (defaultRange>0 && !isSigned16Bit())
575+
range = (int)Math.pow(2,defaultRange);
576+
setMinAndMax(0, range-1);
582577
process(INVERT, 0.0);
583578
resetMinAndMax();
584579
}

plugins/MacAdapter9.class

2.22 KB
Binary file not shown.

release-notes.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,28 @@
55
</head>
66
<body>
77

8-
<li> <u>1.53k16 3 July 2021</u>
8+
<li> <u>1.53 5 July 2021</u>
99
<ul>
10-
<li> Thanks Mike Nelson, added the "Modern mode" option to
11-
the <i>Edit&gt;Options&gt;Misc</i> dialog. 16-bit images are
12-
inverted using <i>v=65535-v</i> When this option is enabled.
10+
<li> Thanks Mike Nelson, 16-bit images are
11+
inverted using the full pixel value range (0-65535) or, if set,
12+
using the "Unsigned 16-bit range" in the "Set" option of the
13+
<i>Image&gt;Adjust&gt;Brightness/Contrast</i> dialog.
1314
<li> Thanks to Alan Brooks, added the macOS-specific
14-
MacAdapter9 plugin, which supports drag and drop on the
15-
ImageJ.app and the "About ImageJ" command on Java 9 or
16-
later.
15+
MacAdapter9 plugin, which, on Java 9 or later,
16+
supports drag and drop on the ImageJ.app and the
17+
"About ImageJ" command.
1718
<li> Thanks to Romain Guiet, the ROI Manager's
18-
Associate Show All ROIs with slices option is
19+
"Associate 'Show All' ROIs with slices" option is
1920
now enabled by default.
2021
<li> Thanks to Gilles Carpentier, the particle analyzer now assumes
2122
the threshold is 255 unless "Black background" is not set,
2223
the image does not have an inverted LUT and fewer than
2324
half the pixels have a value of zero, in which case
2425
the threshold is set to zero.
25-
<li> Thanks to 'pdd2110', added the Property.setSliceLabel(label) method. DOCUMENT
26+
<li> Thanks to 'pdd2110', added the Property.setSliceLabel(label)
27+
macro function. DOCUMENT
28+
<li> Thanks to 'John D.', added the GenericDialog.addButton() method
29+
(<a href="http://wsr.imagej.net/plugins/Button_Example.java">example</a>).
2630
<li> Thanks to 'Oodegard', fixed a bug that caused the
2731
"Auto-next slice" option of the point tool to not
2832
work as expected with hyperstacks.

0 commit comments

Comments
 (0)