Skip to content

Commit

Permalink
2023.11.14 (1.54h20; Non-blocking yes/no/cancel dialogs)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Dec 15, 2023
1 parent 6f5f96f commit bf22ede
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 18 deletions.
2 changes: 1 addition & 1 deletion ij/ImageJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.54h";
public static final String BUILD = "16";
public static final String BUILD = "20";
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);
Expand Down
2 changes: 1 addition & 1 deletion ij/ImagePlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ else if (nScrollbars==0 && newStackSize>1)
boolean resetCurrentSlice = currentSlice>newStackSize;
if (resetCurrentSlice) setCurrentSlice(newStackSize);
ImageProcessor ip = newStack.getProcessor(currentSlice);
if (newStack.isVirtual()) // work around bug with virtual stacks that cache pixel data
if (newStack.isVirtual()) // work around bug with cached virtual stacks
ip = ip.duplicate();
boolean dimensionsChanged = width>0 && height>0 && (width!=ip.getWidth()||height!=ip.getHeight());
if (this.stack==null)
Expand Down
39 changes: 28 additions & 11 deletions ij/io/Opener.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,14 +445,7 @@ public ImagePlus openURL(String url) {
if (imp!=null)
return imp;
try {
String name = "";
int index = url.lastIndexOf('/');
if (index==-1)
index = url.lastIndexOf('\\');
if (index>0)
name = url.substring(index+1);
else
throw new MalformedURLException("Invalid URL: "+url);
String name = getUrlName(url);
if (url.indexOf(" ")!=-1)
url = url.replaceAll(" ", "%20");
URL u = new URL(url);
Expand All @@ -463,12 +456,12 @@ public ImagePlus openURL(String url) {
imp = openTiff(u.openStream(), name);
} else if (lurl.endsWith(".zip"))
imp = openZipUsingUrl(u);
else if (lurl.endsWith(".jpg") || lurl.endsWith(".jpeg") || lurl.endsWith(".gif"))
else if (lurl.endsWith(".jpg") || lurl.endsWith(".jpeg") || lurl.endsWith(".gif")||lurl.contains(".jpg?")||lurl.contains(".jpeg?"))
imp = openJpegOrGifUsingURL(name, u);
else if (lurl.endsWith(".dcm") || lurl.endsWith(".ima")) {
imp = (ImagePlus)IJ.runPlugIn("ij.plugin.DICOM", url);
if (imp!=null && imp.getWidth()==0) imp = null;
} else if (lurl.endsWith(".png"))
} else if (lurl.endsWith(".png")||lurl.contains(".png?"))
imp = openPngUsingURL(name, u);
else {
URLConnection uc = u.openConnection();
Expand All @@ -492,6 +485,29 @@ else if (type!=null && type.equals("image/png"))
}
}

private String getUrlName(String url) {
String origUrl = url;
String name = "";
int ndx = url.lastIndexOf(".jpeg?");
if (ndx>0)
url = url.substring(0, ndx+5);
else {
ndx = url.lastIndexOf(".jpg?");
if (ndx==-1)
ndx = url.lastIndexOf(".png?");
if (ndx>0)
url = url.substring(0, ndx+4);
}
int index = url.lastIndexOf('/');
if (index==-1)
index = url.lastIndexOf('\\');
if (index>0)
name = url.substring(index+1);
else
throw new IllegalArgumentException("Invalid URL: "+url);
return name;
}

/** Can't open imagej.nih.gov URLs due to encryption so redirect to imagej.net mirror. */
public static String updateUrl(String url) {
if (url==null || !url.contains("nih.gov"))
Expand Down Expand Up @@ -648,7 +664,8 @@ ImagePlus openDicomStack(ZipInputStream zis, ZipEntry entry) throws IOException
return imp;
}

ImagePlus openJpegOrGifUsingURL(String title, URL url) {
ImagePlus openJpegOrGifUsingURL(String title, URL url) {
if (IJ.debugMode) IJ.log("openJpegOrGifUsingURL: "+url);
if (url==null) return null;
Image img = Toolkit.getDefaultToolkit().createImage(url);
if (img!=null) {
Expand Down
11 changes: 11 additions & 0 deletions ij/macro/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -4109,6 +4109,9 @@ String doDialog() {
} else if (name.equals("addToSameRow")) {
interp.getParens();
gd.addToSameRow();
} else if (name.equals("enableYesNoCancel")) {
interp.getParens();
gd.enableYesNoCancel(" Yes ", " No ");
} else if (name.equals("setLocation")) {
gd.setLocation((int)getFirstArg(), (int)getLastArg());
} else if (name.equals("getLocation")) {
Expand Down Expand Up @@ -4145,6 +4148,14 @@ String doDialog() {
} else if (name.equals("getRadioButton")) {
interp.getParens();
return gd.getNextRadioButton();
} else if (name.equals("getYesNoCancel")) {
interp.getParens();
String result = "no";
if (gd.wasCanceled())
result = "cancel";
else if (gd.wasOKed())
result = "yes";
return result;
} else
interp.error("Unrecognized Dialog function "+name);
} catch (IndexOutOfBoundsException e) {
Expand Down
7 changes: 6 additions & 1 deletion ij/plugin/URLOpener.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ public class URLOpener implements PlugIn {
/** If 'urlOrName' is a URL, opens the image at that URL. If it is
a file name, opens the image with that name from the 'images.location'
URL in IJ_Props.txt. If it is blank, prompts for an image
URL and open the specified image. */
URL and open the specified image.
http://co3d-icc-review-progqi.oss.eu-west-0.prod-cloud-ocb.orange-business.com/gaston.jpeg?AWSAccessKeyId=S3BC6CQHTB5IZNVBAR8P&Expires=1702508400&Signature=%2BjZBuG6gArIByiyDOVNZvnFnqtg%3D
*/
public void run(String urlOrName) {
if (IJ.debugMode) IJ.log("URLOpener.run: "+urlOrName);
if (!urlOrName.equals("")) {
if (urlOrName.equals("cache"))
cacheSampleImages();
Expand Down Expand Up @@ -108,6 +111,8 @@ private static String imageURL(String urlOrName) {
}

boolean noExtension(String url) {
if (url.contains(".jpg?")||url.contains(".jpeg?")||url.contains(".png?"))
return false;
int lastSlash = url.lastIndexOf("/");
if (lastSlash==-1) lastSlash = 0;
int lastDot = url.lastIndexOf(".");
Expand Down
5 changes: 3 additions & 2 deletions ij/process/ByteStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ public ByteStatistics(ImageProcessor ip) {
/** Constructs a ByteStatistics object from a ByteProcessor using
the specified measurement and calibration. */
public ByteStatistics(ImageProcessor ip, int mOptions, Calibration cal) {
ByteProcessor bp = (ByteProcessor)ip;
histogram = bp.getHistogram();
if (ip.getBitDepth()!=8)
throw new IllegalArgumentException("8-bit image required");
histogram = ip.getHistogram();
setup(ip, cal);
double minT = ip.getMinThreshold();
int minThreshold,maxThreshold;
Expand Down
10 changes: 8 additions & 2 deletions release-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</head>
<body>

<li> <u>1.54h16 08 December 2023</u>
<li> <u>1.54h20 14 December 2023</u>
<ul>
<li> Thanks to Michael Schmid, improved the fidelity of
the RGB to indexed color conversion done by
Expand All @@ -16,6 +16,9 @@
<li> Thanks to 'mandamanta', a warning is displayed in the "Log"
window if no particles are detected by the particle analyzer
when its running in batch mode.
<li> Thanks to Philippe Carl, added the Dialog.enableYesNoCancel
and Dialog.getYesNoCancel macro functions
(<a href="http://wsr.imagej.net/macros/YesNoCancelDialog.ijm">example</a>,
<li> Thanks to Michael Schmid, the Plot.update() macro function
now works for plots that are not under construction.
<li> Thanks to Stein Rorvik, fixed bug where use of a modifier key
Expand All @@ -34,10 +37,13 @@
<i>Image&gt;Color&gt;Show LUT</i>
bugs.
<li> Thanks to Michael Schmid, fixed bug with virtual stacks
that cache pixel data.
that cache pixel data
(<a href="http://wsr.imagej.net/plugins/Test_Virtual_Stack.java">example</a>).
<li> Thanks to Rodrigo Goncalves, fixed bug that caused the
Color Thresholder's "Original" button to not work as
expected.
<li> Thanks to Etienne Monier, fixed bug with opening image URLs that
include access credentials.
<li> Thanks to Nick Condon, fixed a 1.53 regression that made the
Plot.getValues() macro function slower.
<li> Thanks to Stein Rorvik, fixed a 1.54e regression with the
Expand Down

0 comments on commit bf22ede

Please sign in to comment.