Skip to content

Commit

Permalink
Sends created bigdataviewer object into an object service
Browse files Browse the repository at this point in the history
This modification enables to retrieve bigdataviewers via the annotation @parameter for imagej2 styles commands
For object service to work testing purposes, this repo now needs the net.imagej:imagej.
  • Loading branch information
Nicolas Chiaruttini committed Nov 26, 2018
1 parent 669b37b commit 7c94c03
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
.settings
/target
/samples
/.idea
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,9 @@
<groupId>org.scijava</groupId>
<artifactId>vecmath</artifactId>
</dependency>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>imagej</artifactId>
</dependency>
</dependencies>
</project>
17 changes: 16 additions & 1 deletion src/main/java/bdv/ij/BigDataViewerPlugIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;

//import ij.ImageJ;
import net.imagej.ImageJ; // For objectService testing
import org.scijava.command.Command;
import org.scijava.object.ObjectService;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

import bdv.BigDataViewer;
Expand All @@ -23,6 +27,9 @@ public class BigDataViewerPlugIn implements Command
{
static String lastDatasetPath = "./export.xml";

@Parameter
ObjectService os;

@Override
public void run()
{
Expand Down Expand Up @@ -111,7 +118,8 @@ public boolean accept( final File dir, final String name )
try
{
lastDatasetPath = file.getAbsolutePath();
BigDataViewer.open( file.getAbsolutePath(), file.getName(), new ProgressWriterIJ(), ViewerOptions.options() );
BigDataViewer bdv = BigDataViewer.open( file.getAbsolutePath(), file.getName(), new ProgressWriterIJ(), ViewerOptions.options() );
os.addObject(bdv);
}
catch ( final Exception e )
{
Expand All @@ -125,4 +133,11 @@ private boolean isMac()
final String OS = System.getProperty( "os.name", "generic" ).toLowerCase( Locale.ENGLISH );
return ( OS.indexOf( "mac" ) >= 0 ) || ( OS.indexOf( "darwin" ) >= 0 );
}

public static void main( final String[] args )
{
final ImageJ ij = new ImageJ();
ij.ui().showUI();
ij.command().run(BigDataViewerPlugIn.class, true);
}
}

0 comments on commit 7c94c03

Please sign in to comment.