- *
- *
+ * Demos how to log the current mouse position and how to install this behaviour on a Bdv window.
+ * Press Ctrl+D in Bdv and see the current mouse position being logged.
* Author: @haesleinhuepf
* 12 2019
*/
public class LogMousePositionDemo {
- static ImageJ ij;
-
public static
- *
- *
- * Author: Nicolas Chiaruttini
- * 01 2020
+ * Example of an orthoviewer for BigDataViewer
+ * Press Ctrl+S to toggle ON and OFF the view synchronisation between the three windows.
+ * (they are stacked on top of each others when starting the demo)
+ *
+ * @author Nicolas Chiaruttini
+ * Date: 01/2020
*/
public class OrthoViewDemo {
static boolean isSynchronizing;
- static ImageJ ij;
-
- @SuppressWarnings("GrazieInspection")
public static void main(String[] args) {
// Create the ImageJ application context with all available services; necessary for SourceAndConverterServices creation
- ij = new ImageJ();
- TestHelper.startFiji(ij);//ij.ui().showUI();
+ ImageJ ij = new ImageJ();
+ TestHelper.startFiji(ij);
+ // Gets both services
SourceAndConverterBdvDisplayService bdvDisplayService = ij.get(SourceAndConverterBdvDisplayService.class);
SourceAndConverterService sourceService = ij.get(SourceAndConverterService.class);
- // Makes BDV Source
- System.out.println(VersionUtils.getVersion(BigWarp.class));
-
new SpimDataFromXmlImporter( "src/test/resources/mri-stack.xml" ).run();
- //Source source = new RandomAccessibleIntervalSource(rai, Util.getTypeFromInterval(rai), "blobs");
- //SourceAndConverter sac = SourceAndConverterUtils.createSourceAndConverter(source);
-
- // Creates a BdvHandle
+ // Creates three Bdv windows
BdvHandle bdvHandleX = bdvDisplayService.getNewBdv();
- // Creates a BdvHandle
BdvHandle bdvHandleY = bdvDisplayService.getNewBdv();
- // Creates a BdvHandles
BdvHandle bdvHandleZ = bdvDisplayService.getNewBdv();
BdvHandle[] bdvhs = new BdvHandle[]{bdvHandleX,bdvHandleY,bdvHandleZ};
@@ -93,8 +80,9 @@ public static void main(String[] args) {
ViewerOrthoSyncStarter syncstart = new ViewerOrthoSyncStarter(
new ViewerAdapter(bdvHandleX),
- new ViewerAdapter(bdvHandleY),new ViewerAdapter(bdvHandleZ), false);
- ViewerTransformSyncStopper syncstop = new ViewerTransformSyncStopper(syncstart.getSynchronizers(), null);
+ new ViewerAdapter(bdvHandleY),
+ new ViewerAdapter(bdvHandleZ), true);
+ ViewerTransformSyncStopper syncstop = new ViewerTransformSyncStopper(syncstart.getSynchronizers(), syncstart.getTimeSynchronizers());
syncstart.run();
isSynchronizing = true;
@@ -120,13 +108,4 @@ public static void main(String[] args) {
}
- @Test
- public void demoRunOk() {
- main(new String[]{""});
- }
-
- @After
- public void closeFiji() {
- TestHelper.closeFijiAndBdvs(ij);
- }
}
diff --git a/src/test/src/sc/fiji/bdvpg/bdv/navigate/ViewTransformSetAndLogDemo.java b/src/test/src/sc/fiji/bdvpg/demos/bdv/navigate/ViewTransformSetAndLogDemo.java
similarity index 93%
rename from src/test/src/sc/fiji/bdvpg/bdv/navigate/ViewTransformSetAndLogDemo.java
rename to src/test/src/sc/fiji/bdvpg/demos/bdv/navigate/ViewTransformSetAndLogDemo.java
index 21c0926c..0f21789b 100644
--- a/src/test/src/sc/fiji/bdvpg/bdv/navigate/ViewTransformSetAndLogDemo.java
+++ b/src/test/src/sc/fiji/bdvpg/demos/bdv/navigate/ViewTransformSetAndLogDemo.java
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
-package sc.fiji.bdvpg.bdv.navigate;
+package sc.fiji.bdvpg.demos.bdv.navigate;
import bdv.util.BdvHandle;
import bdv.util.RandomAccessibleIntervalSource;
@@ -41,10 +41,11 @@
import net.imglib2.type.numeric.integer.UnsignedByteType;
import net.imglib2.util.Util;
import net.imglib2.view.Views;
-import org.junit.After;
-import org.junit.Test;
import sc.fiji.bdvpg.TestHelper;
import sc.fiji.bdvpg.bdv.BdvHandleHelper;
+import sc.fiji.bdvpg.bdv.navigate.ViewerTransformAdjuster;
+import sc.fiji.bdvpg.bdv.navigate.ViewerTransformChanger;
+import sc.fiji.bdvpg.bdv.navigate.ViewerTransformLogger;
import sc.fiji.bdvpg.behaviour.ClickBehaviourInstaller;
import sc.fiji.bdvpg.services.SourceAndConverterServices;
import sc.fiji.bdvpg.sourceandconverter.SourceAndConverterHelper;
@@ -59,12 +60,11 @@
*/
public class ViewTransformSetAndLogDemo {
- static ImageJ ij;
public static void main(String[] args) {
// Create the ImageJ application context with all available services; necessary for SourceAndConverterServices creation
- ij = new ImageJ();
+ ImageJ ij = new ImageJ();
TestHelper.startFiji(ij);//ij.ui().showUI();
// load and convert an image
@@ -108,13 +108,4 @@ public static void main(String[] args) {
}
- @Test
- public void demoRunOk() {
- main(new String[]{""});
- }
-
- @After
- public void closeFiji() {
- TestHelper.closeFijiAndBdvs(ij);
- }
}
diff --git a/src/test/src/sc/fiji/bdvpg/bdv/navigate/ViewTransformSynchronizationDemo.java b/src/test/src/sc/fiji/bdvpg/demos/bdv/navigate/ViewTransformSynchronizationDemo.java
similarity index 93%
rename from src/test/src/sc/fiji/bdvpg/bdv/navigate/ViewTransformSynchronizationDemo.java
rename to src/test/src/sc/fiji/bdvpg/demos/bdv/navigate/ViewTransformSynchronizationDemo.java
index 61b56301..b0ed55d1 100644
--- a/src/test/src/sc/fiji/bdvpg/bdv/navigate/ViewTransformSynchronizationDemo.java
+++ b/src/test/src/sc/fiji/bdvpg/demos/bdv/navigate/ViewTransformSynchronizationDemo.java
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
-package sc.fiji.bdvpg.bdv.navigate;
+package sc.fiji.bdvpg.demos.bdv.navigate;
import bdv.util.BdvHandle;
import bdv.util.RandomAccessibleIntervalSource;
@@ -40,9 +40,8 @@
import net.imglib2.type.numeric.integer.UnsignedByteType;
import net.imglib2.util.Util;
import net.imglib2.view.Views;
-import org.junit.After;
-import org.junit.Test;
import sc.fiji.bdvpg.TestHelper;
+import sc.fiji.bdvpg.bdv.navigate.ViewerTransformAdjuster;
import sc.fiji.bdvpg.behaviour.ClickBehaviourInstaller;
import sc.fiji.bdvpg.services.SourceAndConverterServices;
import sc.fiji.bdvpg.sourceandconverter.SourceAndConverterHelper;
@@ -62,12 +61,10 @@ public class ViewTransformSynchronizationDemo {
static boolean isSynchronizing;
- static ImageJ ij;
-
public static void main(String[] args) {
// Create the ImageJ application context with all available services; necessary for SourceAndConverterServices creation
- ij = new ImageJ();
+ ImageJ ij = new ImageJ();
TestHelper.startFiji(ij);//ij.ui().showUI();
// load and convert an image
@@ -115,14 +112,4 @@ public static void main(String[] args) {
}
- @Test
- public void demoRunOk() {
- main(new String[]{""});
- }
-
- @After
- public void closeFiji() {
- TestHelper.closeFijiAndBdvs(ij);
- }
-
}
diff --git a/src/test/src/sc/fiji/bdvpg/bdv/navigate/ViewerTransformAdjusterDemo.java b/src/test/src/sc/fiji/bdvpg/demos/bdv/navigate/ViewerTransformAdjusterDemo.java
similarity index 90%
rename from src/test/src/sc/fiji/bdvpg/bdv/navigate/ViewerTransformAdjusterDemo.java
rename to src/test/src/sc/fiji/bdvpg/demos/bdv/navigate/ViewerTransformAdjusterDemo.java
index 855df132..5b5f8107 100644
--- a/src/test/src/sc/fiji/bdvpg/bdv/navigate/ViewerTransformAdjusterDemo.java
+++ b/src/test/src/sc/fiji/bdvpg/demos/bdv/navigate/ViewerTransformAdjusterDemo.java
@@ -26,14 +26,13 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
-package sc.fiji.bdvpg.bdv.navigate;
+package sc.fiji.bdvpg.demos.bdv.navigate;
import bdv.util.BdvHandle;
import mpicbg.spim.data.generic.AbstractSpimData;
import net.imagej.ImageJ;
-import org.junit.After;
-import org.junit.Test;
import sc.fiji.bdvpg.TestHelper;
+import sc.fiji.bdvpg.bdv.navigate.ViewerTransformAdjuster;
import sc.fiji.bdvpg.services.SourceAndConverterServices;
import sc.fiji.bdvpg.spimdata.importer.SpimDataFromXmlImporter;
@@ -47,12 +46,11 @@
*/
public class ViewerTransformAdjusterDemo
{
- static ImageJ ij;
public static void main(String[] args)
{
// Create the ImageJ application context with all available services; necessary for SourceAndConverterServices creation
- ij = new ImageJ();
- TestHelper.startFiji(ij);//ij.ui().showUI();
+ ImageJ ij = new ImageJ();
+ TestHelper.startFiji(ij);
// Gets active BdvHandle instance
BdvHandle bdvHandle = SourceAndConverterServices.getBdvDisplayService().getActiveBdv();
@@ -84,13 +82,4 @@ public static void main(String[] args)
new ViewerTransformAdjuster(bdvHandle, SourceAndConverterServices.getSourceAndConverterService().getSourceAndConverterFromSpimdata(asd).get(0)).run();
}
- @Test
- public void demoRunOk() {
- main(new String[]{""});
- }
-
- @After
- public void closeFiji() {
- TestHelper.closeFijiAndBdvs(ij);
- }
}
diff --git a/src/test/src/sc/fiji/bdvpg/bvv/BvvDemo.java b/src/test/src/sc/fiji/bdvpg/demos/bvv/BvvDemo.java
similarity index 96%
rename from src/test/src/sc/fiji/bdvpg/bvv/BvvDemo.java
rename to src/test/src/sc/fiji/bdvpg/demos/bvv/BvvDemo.java
index fee992e6..f73eb941 100644
--- a/src/test/src/sc/fiji/bdvpg/bvv/BvvDemo.java
+++ b/src/test/src/sc/fiji/bdvpg/demos/bvv/BvvDemo.java
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
-package sc.fiji.bdvpg.bvv;
+package sc.fiji.bdvpg.demos.bvv;
import bdv.util.BdvFunctions;
import bvv.vistools.BvvFunctions;
@@ -39,10 +39,9 @@
import java.util.Random;
public class BvvDemo {
- static ImageJ ij;
public static void main(String... args) {
// Create the ImageJ application context with all available services; necessary for SourceAndConverterServices creation
- ij = new ImageJ();
+ ImageJ ij = new ImageJ();
ij.ui().showUI();
Random random = new Random();
diff --git a/src/test/src/sc/fiji/bdvpg/scijavacommand/BdvScijavaCommandDemo.java b/src/test/src/sc/fiji/bdvpg/scijava/command/BdvScijavaCommandDemo.java
similarity index 95%
rename from src/test/src/sc/fiji/bdvpg/scijavacommand/BdvScijavaCommandDemo.java
rename to src/test/src/sc/fiji/bdvpg/scijava/command/BdvScijavaCommandDemo.java
index 975ab16d..b53e5e83 100644
--- a/src/test/src/sc/fiji/bdvpg/scijavacommand/BdvScijavaCommandDemo.java
+++ b/src/test/src/sc/fiji/bdvpg/scijava/command/BdvScijavaCommandDemo.java
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
-package sc.fiji.bdvpg.scijavacommand;
+package sc.fiji.bdvpg.scijava.command;
import bdv.ui.BdvDefaultCards;
import bdv.util.BdvHandle;
@@ -38,8 +38,6 @@
import sc.fiji.bdvpg.scijava.BdvScijavaHelper;
import sc.fiji.bdvpg.scijava.ScijavaSwingUI;
import sc.fiji.bdvpg.scijava.services.SourceAndConverterBdvDisplayService;
-import sc.fiji.bdvpg.scijava.services.SourceAndConverterService;
-import sc.fiji.bdvpg.services.SourceAndConverterServices;
public class BdvScijavaCommandDemo {
static ImageJ ij;
diff --git a/src/test/src/sc/fiji/bdvpg/scijavacommand/BdvZoom.java b/src/test/src/sc/fiji/bdvpg/scijava/command/BdvZoom.java
similarity index 98%
rename from src/test/src/sc/fiji/bdvpg/scijavacommand/BdvZoom.java
rename to src/test/src/sc/fiji/bdvpg/scijava/command/BdvZoom.java
index 033fad1c..30d8c17f 100644
--- a/src/test/src/sc/fiji/bdvpg/scijavacommand/BdvZoom.java
+++ b/src/test/src/sc/fiji/bdvpg/scijava/command/BdvZoom.java
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
-package sc.fiji.bdvpg.scijavacommand;
+package sc.fiji.bdvpg.scijava.command;
import bdv.util.BdvHandle;
import org.scijava.command.Command;
diff --git a/src/test/src/sc/fiji/bdvpg/scijavacommand/RenameBdv.java b/src/test/src/sc/fiji/bdvpg/scijava/command/RenameBdv.java
similarity index 98%
rename from src/test/src/sc/fiji/bdvpg/scijavacommand/RenameBdv.java
rename to src/test/src/sc/fiji/bdvpg/scijava/command/RenameBdv.java
index eca6cd09..48fb0397 100644
--- a/src/test/src/sc/fiji/bdvpg/scijavacommand/RenameBdv.java
+++ b/src/test/src/sc/fiji/bdvpg/scijava/command/RenameBdv.java
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
-package sc.fiji.bdvpg.scijavacommand;
+package sc.fiji.bdvpg.scijava.command;
import bdv.util.BdvHandle;
import org.scijava.command.Command;
diff --git a/src/test/src/sc/fiji/bdvpg/scijavacommand/TestInteractiveCommand.java b/src/test/src/sc/fiji/bdvpg/scijava/command/TestInteractiveCommand.java
similarity index 98%
rename from src/test/src/sc/fiji/bdvpg/scijavacommand/TestInteractiveCommand.java
rename to src/test/src/sc/fiji/bdvpg/scijava/command/TestInteractiveCommand.java
index 156c9b90..5b43d3e1 100644
--- a/src/test/src/sc/fiji/bdvpg/scijavacommand/TestInteractiveCommand.java
+++ b/src/test/src/sc/fiji/bdvpg/scijava/command/TestInteractiveCommand.java
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
-package sc.fiji.bdvpg.scijavacommand;
+package sc.fiji.bdvpg.scijava.command;
import net.imagej.ImageJ;
import org.scijava.command.Command;
diff --git a/src/test/src/sc/fiji/bdvpg/scijavacommand/TestWidgetDemoCommand.java b/src/test/src/sc/fiji/bdvpg/scijava/command/TestWidgetDemoCommand.java
similarity index 98%
rename from src/test/src/sc/fiji/bdvpg/scijavacommand/TestWidgetDemoCommand.java
rename to src/test/src/sc/fiji/bdvpg/scijava/command/TestWidgetDemoCommand.java
index f0054480..0ac67d37 100644
--- a/src/test/src/sc/fiji/bdvpg/scijavacommand/TestWidgetDemoCommand.java
+++ b/src/test/src/sc/fiji/bdvpg/scijava/command/TestWidgetDemoCommand.java
@@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
-package sc.fiji.bdvpg.scijavacommand;
+package sc.fiji.bdvpg.scijava.command;
import bdv.viewer.SourceAndConverter;
import ij.IJ;
diff --git a/src/test/src/sc/fiji/bdvpg/tests/TestBdvCommands.java b/src/test/src/sc/fiji/bdvpg/tests/TestBdvCommands.java
new file mode 100644
index 00000000..822d7bd5
--- /dev/null
+++ b/src/test/src/sc/fiji/bdvpg/tests/TestBdvCommands.java
@@ -0,0 +1,67 @@
+package sc.fiji.bdvpg.tests;
+
+import bdv.util.BdvHandle;
+import bdv.viewer.SourceAndConverter;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.scijava.Context;
+import org.scijava.command.CommandService;
+import org.scijava.script.ScriptService;
+import org.scijava.ui.UIService;
+import org.scijava.ui.swing.SwingUI;
+import sc.fiji.bdvpg.scijava.command.bdv.BdvCreatorCommand;
+import sc.fiji.bdvpg.scijava.services.SourceAndConverterBdvDisplayService;
+import sc.fiji.bdvpg.scijava.services.SourceAndConverterService;
+
+import java.util.concurrent.ExecutionException;
+
+public class TestBdvCommands {
+ Context ctx;
+
+ SourceAndConverterService sourceService;
+ SourceAndConverterBdvDisplayService sourceDisplayService;
+ CommandService commandService;
+ @Before
+ public void startFiji() {
+ // Initializes static SourceService
+ ctx = new Context();
+ // Show UI
+ ctx.service(UIService.class).showUI(SwingUI.NAME);
+
+ sourceDisplayService = ctx.getService(SourceAndConverterBdvDisplayService.class);
+
+ sourceService = ctx.getService(SourceAndConverterService.class);
+
+ commandService = ctx.getService(CommandService.class);
+ }
+
+ @Test
+ public void testBdvCreatorCommand() throws ExecutionException, InterruptedException {
+ commandService.run(BdvCreatorCommand.class,true).get();
+ Assert.assertEquals("Error - there should be one bdv created", 1, sourceDisplayService.getDisplays().size() );
+ }
+
+ @Test
+ public void testBdvCreatorIJ1Macro() throws ExecutionException, InterruptedException{
+ ctx.getService(ScriptService.class).run("dummy.ijm",
+ "run(\"BDV - Create empty BDV window\");", true).get();
+ Assert.assertEquals("Error - there should be one bdv created", 1, sourceDisplayService.getDisplays().size() );
+ }
+
+
+ @After
+ public void closeFiji() {
+
+ // Closes bdv windows
+ sourceDisplayService.getDisplays().forEach(BdvHandle::close);
+
+ // Clears all sources
+ sourceService.remove(sourceService.getSourceAndConverters().toArray(new SourceAndConverter[0]));
+
+ // Closes context
+ ctx.close();
+ }
+
+}
diff --git a/src/test/src/sc/fiji/bdvpg/tests/TestSourcesCommands.java b/src/test/src/sc/fiji/bdvpg/tests/TestSourcesCommands.java
new file mode 100644
index 00000000..d291a135
--- /dev/null
+++ b/src/test/src/sc/fiji/bdvpg/tests/TestSourcesCommands.java
@@ -0,0 +1,135 @@
+package sc.fiji.bdvpg.tests;
+
+import bdv.util.BdvHandle;
+import bdv.viewer.SourceAndConverter;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.scijava.Context;
+import org.scijava.command.CommandService;
+import org.scijava.script.ScriptService;
+import org.scijava.ui.UIService;
+import org.scijava.ui.swing.SwingUI;
+import sc.fiji.bdvpg.scijava.command.source.NewSourceCommand;
+import sc.fiji.bdvpg.scijava.command.source.SourcesRemoverCommand;
+import sc.fiji.bdvpg.scijava.services.SourceAndConverterBdvDisplayService;
+import sc.fiji.bdvpg.scijava.services.SourceAndConverterService;
+import sc.fiji.bdvpg.spimdata.importer.SpimDataFromXmlImporter;
+
+import java.util.concurrent.ExecutionException;
+
+public class TestSourcesCommands {
+ Context ctx;
+
+ SourceAndConverterService sourceService;
+ SourceAndConverterBdvDisplayService sourceDisplayService;
+ CommandService commandService;
+ @Before
+ public void startFiji() {
+ // Initializes static SourceService
+ ctx = new Context();
+ // Show UI
+ ctx.service(UIService.class).showUI(SwingUI.NAME);
+
+ sourceDisplayService = ctx.getService(SourceAndConverterBdvDisplayService.class);
+ sourceService = ctx.getService(SourceAndConverterService.class);
+ commandService = ctx.getService(CommandService.class);
+
+ // Open two example sources
+ new SpimDataFromXmlImporter("src/test/resources/mri-stack.xml").get();
+ new SpimDataFromXmlImporter("src/test/resources/demoSlice.xml").get();
+
+ }
+
+ @Test(timeout=5000)
+ public void testSourceDeleteCommand() throws ExecutionException, InterruptedException {
+ Assert.assertEquals("Error - there should be two sources at the beginning of the test", 2, sourceService.getSourceAndConverters().size() );
+ commandService.run(SourcesRemoverCommand.class,true, "sacs", "mri-stack.xml").get();
+ Assert.assertEquals("Error - there should be one source left", 1, sourceService.getSourceAndConverters().size());
+ }
+
+ @Test(timeout=5000)
+ public void testSourceDeleteIJ1Macro() throws ExecutionException, InterruptedException{
+ ctx.getService(ScriptService.class).run("dummy.ijm",
+ "run(\"Delete Sources\", \"sacs=[mri-stack.xml]\");", true).get();
+ Assert.assertEquals("Error - there should be one source left", 1, sourceService.getSourceAndConverters().size() );
+ }
+
+ @Test(timeout=5000)
+ public void testSourceDeleteNestedPathCommand() throws ExecutionException, InterruptedException {
+ Assert.assertEquals("Error - there should be two sources at the beginning of the test", 2, sourceService.getSourceAndConverters().size() );
+ commandService.run(SourcesRemoverCommand.class,true, "sacs", "mri-stack.xml>Channel>1").get();
+ Assert.assertEquals("Error - there should be one source left", 1, sourceService.getSourceAndConverters().size());
+ }
+
+ @Test(timeout=5000)
+ public void testSourceDeleteNestedPathIJ1Macro() throws ExecutionException, InterruptedException {
+ Assert.assertEquals("Error - there should be two sources at the beginning of the test", 2, sourceService.getSourceAndConverters().size() );
+ ctx.getService(ScriptService.class).run("dummy.ijm",
+ "run(\"Delete Sources\", \"sacs=[mri-stack.xml>Channel>1]\");", true).get();
+ Assert.assertEquals("Error - there should be one source left", 1, sourceService.getSourceAndConverters().size());
+ }
+
+ /*
+ // Splitting by comma is not supported and could be a bad idea. Let's refrain from it until it becomes absolutely necessary
+ The workaround is to run several times the deletion on the different paths manually
+ @Test(timeout=5000)
+ public void testMultipleSourcesDeleteCommand() throws ExecutionException, InterruptedException {
+ Assert.assertEquals("Error - there should be two sources at the beginning of the test", 2, sourceService.getSourceAndConverters().size() );
+ commandService.run(SourcesRemoverCommand.class,true, "sacs", "mri-stack.xml, demoSlice.xml").get();
+ Assert.assertEquals("Error - there should be one source left", 1, sourceService.getSourceAndConverters().size());
+ }
+
+ @Test(timeout=5000)
+ public void testMultipleSourcesDeleteIJ1Macro() throws ExecutionException, InterruptedException {
+ Assert.assertEquals("Error - there should be two sources at the beginning of the test", 2, sourceService.getSourceAndConverters().size() );
+ ctx.getService(ScriptService.class).run("dummy.ijm",
+ "run(\"Delete Sources\", \"sacs=[mri-stack.xml, demoSlice.xml]\");", true).get();
+ Assert.assertEquals("Error - there should be one source left", 1, sourceService.getSourceAndConverters().size());
+ }*/
+
+ //NewSourceCommand
+ @Test(timeout=5000)
+ public void testNewSourceCommand() throws ExecutionException, InterruptedException {
+ Assert.assertEquals("Error - there should be two sources at the beginning of the test", 2, sourceService.getSourceAndConverters().size());
+ commandService.run(NewSourceCommand.class,true,
+ "model", "mri-stack.xml>Channel>1",
+ "name", "model",
+ "voxsizex",1,
+ "voxsizey",1,
+ "voxsizez",1,
+ "timepoint",0).get();
+ Assert.assertEquals("Error - there should three sources after one is created", 3, sourceService.getSourceAndConverters().size());
+ }
+
+ @Test(timeout=5000)
+ public void testNewSourceIJ1Macro() throws ExecutionException, InterruptedException {
+ Assert.assertEquals("Error - there should be two sources at the beginning of the test", 2, sourceService.getSourceAndConverters().size());
+ //New Source Based on Model Source
+ ctx.getService(ScriptService.class).run("dummy.ijm",
+ "run(\"New Source Based on Model Source\", \""+
+ "model=[mri-stack.xml>Channel>1] " +
+ "name=model " +
+ "voxsizex=1 " +
+ "voxsizey=1 " +
+ "voxsizez=1 " +
+ "timepoint=0 " +
+ "\");", true).get();
+ Assert.assertEquals("Error - there should three sources after one is created", 3, sourceService.getSourceAndConverters().size());
+ }
+
+ @After
+ public void closeFiji() {
+
+ // Closes bdv windows
+ sourceDisplayService.getDisplays().forEach(BdvHandle::close);
+
+ // Clears all sources
+ sourceService.remove(sourceService.getSourceAndConverters().toArray(new SourceAndConverter[0]));
+
+ // Closes context
+ ctx.close();
+ }
+
+}