Skip to content

Commit

Permalink
export table filename
Browse files Browse the repository at this point in the history
  • Loading branch information
gletort committed Oct 9, 2023
1 parent 619b03b commit e424213
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 17 deletions.
9 changes: 9 additions & 0 deletions src/main/java/fiji/plugin/trackmate/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,15 @@ 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ 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 ).render();
createSpotsTable( trackmate.getModel(), selectionModel, displaySettings, trackmate.getSettings().getFileNameWithoutExtension() ).render();
}

public static final AllSpotsTableView createSpotsTable( final Model model, final SelectionModel selectionModel, final DisplaySettings displaySettings )
public static final AllSpotsTableView createSpotsTable( final Model model, final SelectionModel selectionModel, final DisplaySettings displaySettings, final String imageFileName )
{
return new AllSpotsTableView( model, selectionModel, displaySettings );
return new AllSpotsTableView( model, selectionModel, displaySettings, imageFileName );
}

// Invisible because called on the view config panel.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ 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 ).render();
createTrackTables( trackmate.getModel(), selectionModel, displaySettings, trackmate.getSettings().getFileNameWithoutExtension() ).render();
}

public static TrackTableView createTrackTables( final Model model, final SelectionModel selectionModel, final DisplaySettings displaySettings )
public static TrackTableView createTrackTables( final Model model, final SelectionModel selectionModel, final DisplaySettings displaySettings, final String imageFileName )
{
return new TrackTableView( model, selectionModel, displaySettings );
return new TrackTableView( model, selectionModel, displaySettings, imageFileName );
}

// Invisible because called on the view config panel.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ 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 ).render();
createBranchTable( trackmate.getModel(), selectionModel, trackmate.getSettings().getFileNameWithoutExtension() ).render();
}

public static final BranchTableView createBranchTable( final Model model, final SelectionModel selectionModel )
public static final BranchTableView createBranchTable( final Model model, final SelectionModel selectionModel, final String imageFileName )
{
return new BranchTableView( model, selectionModel );
return new BranchTableView( model, selectionModel, imageFileName );
}

@Plugin( type = TrackMateActionFactory.class, enabled = true )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class AllSpotsTableView extends JFrame implements TrackMateModelView, Mod

private static final String KEY = "SPOT_TABLE";

public static String selectedFile = TrackTableView.selectedFile;
private String selectedFile = System.getProperty( "user.home" ) + File.separator + "spots.csv";

private final Model model;

Expand All @@ -88,13 +88,13 @@ public class AllSpotsTableView extends JFrame implements TrackMateModelView, Mod

private final SelectionModel selectionModel;

public AllSpotsTableView( final Model model, final SelectionModel selectionModel, final DisplaySettings ds )
public AllSpotsTableView( final Model model, final SelectionModel selectionModel, final DisplaySettings ds, final String imageFileName )
{
super( "All spots table" );
setIconImage( TRACKMATE_ICON.getImage() );
this.model = model;
this.selectionModel = selectionModel;

this.selectedFile = imageFileName+"_spots.csv";
/*
* GUI.
*/
Expand Down Expand Up @@ -154,6 +154,7 @@ public void windowClosing( final java.awt.event.WindowEvent e )

public void exportToCsv()
{

final File file = FileChooser.chooseFile(
this,
selectedFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,19 @@ public class BranchTableView extends JFrame implements TrackMateModelView

private static final String KEY = "SPOT_TABLE";

public static String selectedFile = TrackTableView.selectedFile;
private String selectedFile = System.getProperty( "user.home" ) + File.separator + "branchs.csv";

private final Model model;

private final TablePanel< Branch > branchTable;

public BranchTableView( final Model model, final SelectionModel selectionModel )
public BranchTableView( final Model model, final SelectionModel selectionModel, final String imageFileName )
{
super( "Branch table" );
setIconImage( TRACKMATE_ICON.getImage() );
this.model = model;
this.selectedFile = imageFileName+"_branchs.csv";


/*
* GUI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class TrackTableView extends JFrame implements TrackMateModelView, ModelC

private static final String KEY = "TRACK_TABLES";

public static String selectedFile = System.getProperty( "user.home" ) + File.separator + "export.csv";
private String selectedFile = System.getProperty( "user.home" ) + File.separator + "tracks.csv";

private final Model model;

Expand All @@ -97,12 +97,14 @@ public class TrackTableView extends JFrame implements TrackMateModelView, ModelC

private final SelectionModel selectionModel;

public TrackTableView( final Model model, final SelectionModel selectionModel, final DisplaySettings ds )
public TrackTableView( final Model model, final SelectionModel selectionModel, final DisplaySettings ds, final String imageFileName )
{
super( "Track tables" );
setIconImage( TRACKMATE_ICON.getImage() );
this.model = model;
this.selectionModel = selectionModel;
this.selectedFile = imageFileName+"_tracks.csv";


/*
* GUI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public static void main( final String[] args ) throws ClassNotFoundException, In
final SelectionModel selectionModel = new SelectionModel( model );
final DisplaySettings ds = reader.getDisplaySettings();
model.getSpots().iterable( 1, true ).forEach( selectionModel::addSpotToSelection );
final String exportFile = System.getProperty( "user.home" ) + File.separator + "test";

new TrackTableView( model, selectionModel, ds ).render();
new TrackTableView( model, selectionModel, ds, exportFile ).render();
}
}

0 comments on commit e424213

Please sign in to comment.