Skip to content

Commit

Permalink
Improve default table names when exporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
tinevez committed Oct 9, 2023
1 parent dfc2659 commit 72192e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
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";

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

private final Model model;

Expand All @@ -94,7 +94,7 @@ public AllSpotsTableView( final Model model, final SelectionModel selectionModel
setIconImage( TRACKMATE_ICON.getImage() );
this.model = model;
this.selectionModel = selectionModel;
this.selectedFile = imageFileName + "_spots.csv";
this.selectedFile = imageFileName + "_allspots.csv";

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

private static final String KEY = "SPOT_TABLE";

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

private final Model model;

Expand All @@ -88,7 +88,7 @@ public BranchTableView( final Model model, final SelectionModel selectionModel,
super( "Branch table" );
setIconImage( TRACKMATE_ICON.getImage() );
this.model = model;
this.selectedFile = imageFileName + "_branchs.csv";
this.selectedFile = imageFileName + "_branches.csv";

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

private static final String KEY = "TRACK_TABLES";

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

private final Model model;

private final TablePanel< Spot > spotTable;
Expand All @@ -97,13 +95,15 @@ public class TrackTableView extends JFrame implements TrackMateModelView, ModelC

private final SelectionModel selectionModel;

public TrackTableView( final Model model, final SelectionModel selectionModel, final DisplaySettings ds, final String imageFileName )
private String imagePath;

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

/*
* GUI.
Expand Down Expand Up @@ -180,16 +180,24 @@ public void windowClosing( final java.awt.event.WindowEvent e )

private void exportToCsv( final int index )
{
final int lastIndexOf = imagePath.lastIndexOf( '_' );
if ( lastIndexOf > 0 )
imagePath = imagePath.substring( 0, lastIndexOf );

final TablePanel< ? > table;
String selectedFile;
switch ( index )
{
case 0:
selectedFile = imagePath + "_spots.csv";
table = spotTable;
break;
case 1:
selectedFile = imagePath + "_edges.csv";
table = edgeTable;
break;
case 2:
selectedFile = imagePath + "_tracks.csv";
table = trackTable;
break;
default:
Expand All @@ -216,6 +224,7 @@ private void exportToCsv( final int index )
model.getLogger().error( "Problem exporting to file "
+ file + "\n" + e.getMessage() );
}
imagePath = selectedFile;
}

public static final TablePanel< Integer > createTrackTable( final Model model, final DisplaySettings ds )
Expand Down

0 comments on commit 72192e9

Please sign in to comment.