Java Code Examples for org.scijava.Context#service()

The following examples show how to use org.scijava.Context#service() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScijavaKernel.java    From scijava-jupyter-kernel with Apache License 2.0 6 votes vote down vote up
public static void main(String... args) {
final Context context = new Context();

// Remove the Display and Results post-processors to prevent output
// windows from being displayed
final PluginService pluginService = context.service(PluginService.class);
final PluginInfo<SciJavaPlugin> display = pluginService.getPlugin(DisplayPostprocessor.class);
final PluginInfo<SciJavaPlugin> results = pluginService.getPlugin(ResultsPostprocessor.class);
pluginService.removePlugin(display);
pluginService.removePlugin(results);

JupyterService jupyter = context.service(JupyterService.class);
jupyter.runKernel(args);

context.dispose();
   }
 
Example 2
Source File: SliceTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
@Before
public void setUp() {
	context = new Context(OpService.class);
	ops = context.service(OpService.class);

	in = ArrayImgs.bytes(20, 20, 21);
	out = ArrayImgs.bytes(20, 20, 21);

	// fill array img with values (plane position = value in px);

	for (final Cursor<ByteType> cur = in.cursor(); cur.hasNext();) {
		cur.fwd();
		cur.get().set((byte) cur.getIntPosition(2));
	}
}
 
Example 3
Source File: InstallScijavaKernel.java    From scijava-jupyter-kernel with Apache License 2.0 5 votes vote down vote up
public static void main(String... args) {
    Context context = new Context();

    LogService log = context.service(LogService.class);
    log.setLevel(LogLevel.INFO);

    JupyterService jupyter = context.service(JupyterService.class);
    jupyter.installKernel(args);

    context.dispose();
}
 
Example 4
Source File: TestRunKernel.java    From scijava-jupyter-kernel with Apache License 2.0 5 votes vote down vote up
public static void main(final String[] args) {

        // Warning : if run from your IDE the classpath won't be set to your Fiji installation
        Context context = new Context();
        JupyterService jupyter = context.service(JupyterService.class);
        jupyter.runKernel("jython", "info", "");
        context.dispose();
    }
 
Example 5
Source File: SciView.java    From sciview with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Static launching method
 */
public static SciView create() throws Exception {
    SceneryBase.xinitThreads();

    System.setProperty( "scijava.log.level:sc.iview", "debug" );
    Context context = new Context( ImageJService.class, SciJavaService.class, SCIFIOService.class, ThreadService.class);

    SciViewService sciViewService = context.service( SciViewService.class );
    SciView sciView = sciViewService.getOrCreateActiveSciView();

    return sciView;
}
 
Example 6
Source File: REPLEditor.java    From sciview with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private ThreadService threadService() {
  // HACK: Get the SciJava context from the REPL.
  // This can be fixed if/when the REPL offers a getter for it.
  final Context ctx = (Context) ClassUtils.getValue(//
          Types.field(repl.getClass(), "context"), repl);
  return ctx.service(ThreadService.class);
}
 
Example 7
Source File: SciViewTest.java    From sciview with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void nestedNodeDeletionTest() throws Exception {
    SceneryBase.xinitThreads();

    System.setProperty( "scijava.log.level:sc.iview", "debug" );
    Context context = new Context( ImageJService.class, SciJavaService.class, SCIFIOService.class, ThreadService.class);

    SciViewService sciViewService = context.service( SciViewService.class );
    SciView sciView = sciViewService.getOrCreateActiveSciView();

    Group group = new Group();

    final Material material = new Material();
    material.setAmbient( new Vector3f( 1.0f, 0.0f, 0.0f ) );
    material.setDiffuse( new Vector3f( 1.0f, 0.0f, 0.0f ) );
    material.setSpecular( new Vector3f( 1.0f, 1.0f, 1.0f ) );

    final Sphere sphere = new Sphere( 1, 20 );
    sphere.setMaterial( material );
    sphere.setPosition( JOMLVector3.convert( new JOMLVector3(0,0,0) ) );
    //sphere.setParent(group);
    group.addChild(sphere);
    sciView.addNode(group);

    Assert.assertEquals( sciView.getAllSceneNodes().length, 7 );

    sciView.deleteNode(group);

    Assert.assertEquals( sciView.getAllSceneNodes().length, 6 );

    sciView.closeWindow();
}
 
Example 8
Source File: SciViewTest.java    From sciview with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void nodeDeletionTest() throws Exception {
    SceneryBase.xinitThreads();

    System.setProperty( "scijava.log.level:sc.iview", "debug" );
    Context context = new Context( ImageJService.class, SciJavaService.class, SCIFIOService.class, ThreadService.class);

    SciViewService sciViewService = context.service( SciViewService.class );
    SciView sciView = sciViewService.getOrCreateActiveSciView();

    Node sphere = sciView.addSphere();

    Assert.assertEquals( sciView.getAllSceneNodes().length, 7 );

    sciView.deleteNode(sphere);

    Assert.assertEquals( sciView.getAllSceneNodes().length, 6 );

    sciView.closeWindow();
}
 
Example 9
Source File: TestInstallKernel.java    From scijava-jupyter-kernel with Apache License 2.0 3 votes vote down vote up
public static void main(String... args) {

        String pythonBinaryPath = "/home/hadim/local/conda/bin/python";

        Context context = new Context();
        JupyterService jupyter = context.service(JupyterService.class);
        ScriptService scriptService = context.service(ScriptService.class);
        
        //jupyter.installKernel("groovy", "info", pythonBinaryPath);
        
        System.out.println(scriptService.getLanguages());
        
        context.dispose();

    }