Commit d7d3f33b authored by lombardo's avatar lombardo
Browse files

Replace IJ1 by IJ2 calls

parent 84650985
package de.mpicbg.scf.sandbox;
import ij.IJ;
import ij.ImagePlus;
//import ij.IJ;
//import ij.ImagePlus;
import java.util.concurrent.Future;
import net.imagej.Dataset;
import net.imagej.ImageJ;
import net.imagej.display.ImageDisplay;
import org.scijava.command.Command;
import org.scijava.command.CommandModule;
import org.scijava.command.DynamicCommand;
import org.scijava.log.LogService;
import org.scijava.module.Module;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
......@@ -18,21 +23,27 @@ import org.scijava.plugin.Plugin;
@Plugin(type = Command.class, menuPath = "SCF>test IJ2 command>testCancelReason")
public class testCancelReason extends DynamicCommand {
@Parameter LogService logService;
@Parameter(persist = false)
Dataset dataset;
//ImagePlus imp;
@Override
public void run() {
IJ.log("hello, image name is:"+ dataset.getName() );
//IJ.log("hello, image name is:"+ dataset.getName() );
logService.info("hello, image name is:"+ dataset.getName() );
}
@Override
public void cancel(){
IJ.log( getCancelReason() );
//IJ.log( getCancelReason() );
logService.info(getCancelReason() );
if ( dataset!=null )
IJ.log("script is canceled but image name is:"+ dataset.getName() );
{
//IJ.log("script is canceled but image name is:"+ dataset.getName() );
logService.info("script is canceled but image name is:"+ dataset.getName() );
}
}
......@@ -40,14 +51,38 @@ public class testCancelReason extends DynamicCommand {
public static void main(final String... args) throws Exception {
// Launch ImageJ as usual.
final ImageJ ij = net.imagej.Main.launch(args);
ij.ui().showUI();
ij.command().run(testCancelReason.class, true);
ij.log().setLevel(LogService.DEBUG);
// Launch the command without and with image open.
// run command with one image open
/* ij.log().info("1----------------------");
ij.ui().show(dataset);
final Future<CommandModule> future1 =
ij.command().run(testCancelReason.class, true);
// wait for the execution thread to complete
ij.module().waitFor(future1);
*/
// run command with no image open
/*
final Future<CommandModule> future2 =
ij.command().run(testCancelReason.class, true);
ImagePlus imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
imp.show();
// wait for the execution thread to complete
ij.module().waitFor(future2);
// run command with one image open
ij.log().info("3----------------------");
ij.ui().show(dataset);
final Future<CommandModule> future3 =
ij.command().run(testCancelReason.class, true);
// wait for the execution thread to complete
ij.module().waitFor(future3);
*/
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment