Search in sources :

Example 1 with Context

use of org.scijava.Context in project imagej-omero by imagej.

the class OmeroIT method setup.

@Before
public void setup() {
    client = new omero.client(OMERO_SERVER, OMERO_PORT);
    cred = new OMEROCredentials();
    cred.setServer(OMERO_SERVER);
    cred.setPort(OMERO_PORT);
    cred.setUser(OMERO_USER);
    cred.setPassword(OMERO_PASSWORD);
    context = new Context();
    omero = context.getService(OMEROService.class);
}
Also used : Context(org.scijava.Context) OMEROService(net.imagej.omero.OMEROService) OMEROCredentials(net.imagej.omero.OMEROCredentials) Before(org.junit.Before)

Example 2 with Context

use of org.scijava.Context in project imagej-omero by imagej.

the class Main method main.

public static void main(final String... args) {
    final Context c = new Context();
    c.service(UIService.class).showUI();
    c.service(CommandService.class).run(OpenImageFromOMERO.class, true);
}
Also used : Context(org.scijava.Context) CommandService(org.scijava.command.CommandService) UIService(org.scijava.ui.UIService)

Example 3 with Context

use of org.scijava.Context in project imagej-omero by imagej.

the class ScriptGeneratorTest method testGenerateAll.

@Test
public void testGenerateAll() throws IOException {
    // create a context with a minimal command set
    final PluginIndex pluginIndex = new PluginIndex() {

        @Override
        public void discover() {
            super.discover();
            removeAll(getPlugins(Command.class));
            add(pluginInfo(FileNew.class));
            add(pluginInfo(FileOpen.class));
            add(pluginInfo(FileSave.class));
            add(pluginInfo(FileExit.class));
            add(pluginInfo(Lion.class));
            add(pluginInfo(Tiger.class));
            add(pluginInfo(Bear.class));
        }
    };
    final ArrayList<Class<? extends Service>> classes = new ArrayList<Class<? extends Service>>();
    classes.add(AppService.class);
    classes.add(CommandService.class);
    classes.add(MenuService.class);
    final Context context = new Context(classes, pluginIndex);
    final ScriptGenerator scriptGen = new ScriptGenerator(context);
    final File tempDir = TestUtils.createTemporaryDirectory("script-generator-");
    final File libDir = new File(tempDir, "lib");
    final File scriptsDir = new File(libDir, "scripts");
    assertTrue(scriptsDir.mkdirs());
    final int returnCode = scriptGen.generateAll(tempDir);
    context.dispose();
    assertEquals(0, returnCode);
    final File imagejDir = new File(scriptsDir, "imagej");
    assertTrue(imagejDir.isDirectory());
    final File fileDir = new File(imagejDir, "File");
    assertTrue(fileDir.isDirectory());
    final File animalsDir = new File(imagejDir, "\ufeffAnimals");
    assertTrue(animalsDir.isDirectory());
    assertTrue(new File(fileDir, "New.py").exists());
    assertTrue(new File(fileDir, "\ufeffOpen.py").exists());
    assertTrue(new File(fileDir, "\ufeff\ufeffSave.py").exists());
    assertTrue(new File(fileDir, "\ufeff\ufeff\ufeffExit.py").exists());
    assertTrue(new File(animalsDir, "Lion.py").exists());
    assertTrue(new File(animalsDir, "\ufeffTiger.py").exists());
    assertTrue(new File(animalsDir, "\ufeff\ufeffBear.py").exists());
    FileUtils.deleteRecursively(tempDir);
}
Also used : Context(org.scijava.Context) ArrayList(java.util.ArrayList) CommandService(org.scijava.command.CommandService) AppService(org.scijava.app.AppService) Service(org.scijava.service.Service) MenuService(org.scijava.menu.MenuService) PluginIndex(org.scijava.plugin.PluginIndex) Command(org.scijava.command.Command) File(java.io.File) Test(org.junit.Test)

Example 4 with Context

use of org.scijava.Context in project imagej-ops by imagej.

the class SliceTest method setUp.

@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);
    for (final Cursor<ByteType> cur = in.cursor(); cur.hasNext(); ) {
        cur.fwd();
        cur.get().set((byte) cur.getIntPosition(2));
    }
}
Also used : Context(org.scijava.Context) OpService(net.imagej.ops.OpService) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) ByteType(net.imglib2.type.numeric.integer.ByteType) Before(org.junit.Before)

Example 5 with Context

use of org.scijava.Context in project imagej-ops by imagej.

the class Main method main.

// -- Main method --
public static void main(final String[] args) throws IOException {
    final Context context = new Context(OpService.class);
    final OpService ops = context.getService(OpService.class);
    new EvaluatorConsole(new OpEvaluator(ops)).showConsole();
}
Also used : Context(org.scijava.Context) OpEvaluator(net.imagej.ops.eval.OpEvaluator) EvaluatorConsole(org.scijava.parse.eval.EvaluatorConsole)

Aggregations

Context (org.scijava.Context)6 File (java.io.File)2 Before (org.junit.Before)2 Test (org.junit.Test)2 CommandService (org.scijava.command.CommandService)2 ArrayList (java.util.ArrayList)1 OMEROCredentials (net.imagej.omero.OMEROCredentials)1 OMEROService (net.imagej.omero.OMEROService)1 OpService (net.imagej.ops.OpService)1 OpEvaluator (net.imagej.ops.eval.OpEvaluator)1 ByteType (net.imglib2.type.numeric.integer.ByteType)1 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)1 AppService (org.scijava.app.AppService)1 Command (org.scijava.command.Command)1 MenuService (org.scijava.menu.MenuService)1 EvaluatorConsole (org.scijava.parse.eval.EvaluatorConsole)1 PluginIndex (org.scijava.plugin.PluginIndex)1 ScriptModule (org.scijava.script.ScriptModule)1 ScriptService (org.scijava.script.ScriptService)1 Service (org.scijava.service.Service)1