Skip to content

Commit 36ca862

Browse files
committed
ShollTreeCmd: Improvements to bulk saving of files
1 parent 7e90662 commit 36ca862

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/main/java/sc/fiji/snt/SNTUtils.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ public static String stripExtension(final String filename) {
233233
return (lastDot > 0) ? filename.substring(0, lastDot) : filename;
234234
}
235235

236+
public static File getUniquelySuffixedTifFile(final File referenceFile) {
237+
if (referenceFile != null && !referenceFile.isDirectory() && !referenceFile.getName().endsWith(".tif")) {
238+
return getUniquelySuffixedFile(new File(referenceFile.getAbsolutePath() + ".tif"));
239+
}
240+
return getUniquelySuffixedFile(referenceFile);
241+
}
242+
236243
public static File getUniquelySuffixedFile(final File referenceFile) {
237244
if (referenceFile.exists()) {
238245
final String extension = "." + FileUtils.getExtension(referenceFile);

src/main/java/sc/fiji/snt/analysis/sholl/gui/ShollPlot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ public boolean save(String filepath) {
492492
public boolean save(final File file) {
493493
if (file == null) return false;
494494
final File outFile = (file.isDirectory())
495-
? SNTUtils.getUniquelySuffixedFile(new File(file, getImagePlus().getTitle()))
495+
? SNTUtils.getUniquelySuffixedTifFile(new File(file, getImagePlus().getTitle()))
496496
: file;
497497
return IJ.saveAsTiff(getImagePlus(), outFile.getAbsolutePath());
498498
}

src/main/java/sc/fiji/snt/analysis/sholl/gui/ShollTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public boolean saveSilently(final File file) { // csv extension appended as need
348348
if (file.isDirectory()) {
349349
String fName = getTitle();
350350
if (fName == null || fName.trim().isEmpty())
351-
fName = "Sholl_Table.csv";
351+
fName = "Sholl_Table-1.csv";
352352
savedFile = SNTUtils.getUniquelySuffixedFile(new File(file, fName));
353353
} else {
354354
savedFile = file;

src/main/java/sc/fiji/snt/plugin/ShollAnalysisTreeCmd.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ else if (output instanceof ShollTable) {
836836
}
837837
else if (output instanceof ImagePlus) {
838838
final ImagePlus imp = (ImagePlus)output;
839-
final File outFile = SNTUtils.getUniquelySuffixedFile(new File(saveDir, imp.getTitle()));
839+
final File outFile = SNTUtils.getUniquelySuffixedTifFile(new File(saveDir, imp.getTitle()));
840840
if (!IJ.saveAsTiff(imp, outFile.getAbsolutePath())) ++failures;
841841
}
842842
}
@@ -853,10 +853,11 @@ private ShollPlot showOrRebuildPlot(ShollPlot plot,
853853
final ShollStats stats)
854854
{
855855
if (plot != null && plot.isVisible() && !plot.isFrozen()) {
856-
plot.rebuild(stats);
857-
showStatus("Plot updated...");
856+
// TODO: Check why plot#rebuild keeps reference to old plot#ImagePlus
857+
// plot.rebuild(stats); showStatus("Plot updated...");
858+
plot.getImagePlus().close(); // Dispose image for now, until plot#rebuild is not patched
858859
}
859-
else {
860+
{
860861
plot = new ShollPlot(stats, false);
861862
plot.show();
862863
}

0 commit comments

Comments
 (0)