diff --git a/src/main/java/fiji/plugin/trackmate/Settings.java b/src/main/java/fiji/plugin/trackmate/Settings.java index 65e9d0020..a49bba84c 100644 --- a/src/main/java/fiji/plugin/trackmate/Settings.java +++ b/src/main/java/fiji/plugin/trackmate/Settings.java @@ -303,17 +303,6 @@ public Settings copyOn( final ImagePlus newImp ) * METHODS */ - /** - * Returns a string of the name of the image without the extension, with the - * full path - * - * @return full name of the image without the extension - */ - public String getFileNameWithoutExtension() - { - return imageFolder + imageFileName.substring( 0, imageFileName.lastIndexOf( "." ) ); - } - /** * Returns a string description of the target image. * diff --git a/src/main/java/fiji/plugin/trackmate/action/ExportAllSpotsStatsAction.java b/src/main/java/fiji/plugin/trackmate/action/ExportAllSpotsStatsAction.java index e92a69e00..62d9e1f2b 100644 --- a/src/main/java/fiji/plugin/trackmate/action/ExportAllSpotsStatsAction.java +++ b/src/main/java/fiji/plugin/trackmate/action/ExportAllSpotsStatsAction.java @@ -33,6 +33,7 @@ import fiji.plugin.trackmate.SelectionModel; import fiji.plugin.trackmate.TrackMate; import fiji.plugin.trackmate.gui.displaysettings.DisplaySettings; +import fiji.plugin.trackmate.util.TMUtils; import fiji.plugin.trackmate.visualization.table.AllSpotsTableView; public class ExportAllSpotsStatsAction extends AbstractTMAction @@ -51,7 +52,7 @@ public class ExportAllSpotsStatsAction extends AbstractTMAction @Override public void execute( final TrackMate trackmate, final SelectionModel selectionModel, final DisplaySettings displaySettings, final Frame parent ) { - createSpotsTable( trackmate.getModel(), selectionModel, displaySettings, trackmate.getSettings().getFileNameWithoutExtension() ).render(); + createSpotsTable( trackmate.getModel(), selectionModel, displaySettings, TMUtils.getImagePathWithoutExtension( trackmate.getSettings() ) ).render(); } public static final AllSpotsTableView createSpotsTable( final Model model, final SelectionModel selectionModel, final DisplaySettings displaySettings, final String imageFileName ) diff --git a/src/main/java/fiji/plugin/trackmate/action/ExportStatsTablesAction.java b/src/main/java/fiji/plugin/trackmate/action/ExportStatsTablesAction.java index 539ea405f..bea9045bf 100644 --- a/src/main/java/fiji/plugin/trackmate/action/ExportStatsTablesAction.java +++ b/src/main/java/fiji/plugin/trackmate/action/ExportStatsTablesAction.java @@ -33,6 +33,7 @@ import fiji.plugin.trackmate.SelectionModel; import fiji.plugin.trackmate.TrackMate; import fiji.plugin.trackmate.gui.displaysettings.DisplaySettings; +import fiji.plugin.trackmate.util.TMUtils; import fiji.plugin.trackmate.visualization.table.TrackTableView; public class ExportStatsTablesAction extends AbstractTMAction @@ -57,7 +58,7 @@ public class ExportStatsTablesAction extends AbstractTMAction @Override public void execute( final TrackMate trackmate, final SelectionModel selectionModel, final DisplaySettings displaySettings, final Frame parent ) { - createTrackTables( trackmate.getModel(), selectionModel, displaySettings, trackmate.getSettings().getFileNameWithoutExtension() ).render(); + createTrackTables( trackmate.getModel(), selectionModel, displaySettings, TMUtils.getImagePathWithoutExtension( trackmate.getSettings() ) ).render(); } public static TrackTableView createTrackTables( final Model model, final SelectionModel selectionModel, final DisplaySettings displaySettings, final String imageFileName ) diff --git a/src/main/java/fiji/plugin/trackmate/action/TrackBranchAnalysis.java b/src/main/java/fiji/plugin/trackmate/action/TrackBranchAnalysis.java index 1a1f6adb5..bcdee4be4 100644 --- a/src/main/java/fiji/plugin/trackmate/action/TrackBranchAnalysis.java +++ b/src/main/java/fiji/plugin/trackmate/action/TrackBranchAnalysis.java @@ -33,6 +33,7 @@ import fiji.plugin.trackmate.SelectionModel; import fiji.plugin.trackmate.TrackMate; import fiji.plugin.trackmate.gui.displaysettings.DisplaySettings; +import fiji.plugin.trackmate.util.TMUtils; import fiji.plugin.trackmate.visualization.table.BranchTableView; public class TrackBranchAnalysis extends AbstractTMAction @@ -55,7 +56,7 @@ public class TrackBranchAnalysis extends AbstractTMAction @Override public void execute( final TrackMate trackmate, final SelectionModel selectionModel, final DisplaySettings displaySettings, final Frame parent ) { - createBranchTable( trackmate.getModel(), selectionModel, trackmate.getSettings().getFileNameWithoutExtension() ).render(); + createBranchTable( trackmate.getModel(), selectionModel, TMUtils.getImagePathWithoutExtension( trackmate.getSettings() ) ).render(); } public static final BranchTableView createBranchTable( final Model model, final SelectionModel selectionModel, final String imageFileName ) diff --git a/src/main/java/fiji/plugin/trackmate/util/TMUtils.java b/src/main/java/fiji/plugin/trackmate/util/TMUtils.java index e09f3a08d..25f707e45 100644 --- a/src/main/java/fiji/plugin/trackmate/util/TMUtils.java +++ b/src/main/java/fiji/plugin/trackmate/util/TMUtils.java @@ -66,6 +66,7 @@ public class TMUtils { private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat( "EEE, d MMM yyyy HH:mm:ss" ); + private static Context context; /* @@ -713,12 +714,12 @@ public static final Interval getInterval( final ImgPlus< ? > img, final Settings public static Context getContext() { final Context localContext = context; - if (localContext != null) + if ( localContext != null ) return localContext; - - synchronized (TMUtils.class) + + synchronized ( TMUtils.class ) { - if (context == null) + if ( context == null ) context = ( Context ) IJ.runPlugIn( "org.scijava.Context", "" ); return context; } @@ -842,6 +843,32 @@ public static double standardDeviation( final DoubleArray data ) return Math.sqrt( variance( data ) ); } + /** + * Returns a string of the name of the image without the extension, with the + * full path + * + * @return full name of the image without the extension + */ + public static String getImagePathWithoutExtension( final Settings settings ) + { + final String imageFolder = ( settings.imageFolder == null ) + ? System.getProperty( "user.home" ) + : settings.imageFolder; + + final String imageFileName = settings.imageFileName; + if ( imageFileName != null ) + { + final int lastIndexOf = imageFileName.lastIndexOf( "." ); + if ( lastIndexOf > 0 ) + return imageFolder + imageFileName.substring( 0, imageFileName.lastIndexOf( "." ) ); + return imageFolder + imageFileName; + } + else + { + return imageFolder + File.separator + "TrackMate"; + } + } + private TMUtils() {} }