Search in sources :

Example 51 with CyServiceRegistrar

use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.

the class LoadVizmapFileTaskFactoryTest method testObserver.

@Test
public void testObserver() throws Exception {
    VizmapReaderManager vizmapReaderMgr = mock(VizmapReaderManager.class);
    VizmapReader reader = mock(VizmapReader.class);
    when(vizmapReaderMgr.getReader(any(URI.class), any(String.class))).thenReturn(reader);
    VisualMappingManager vmMgr = mock(VisualMappingManager.class);
    SynchronousTaskManager<?> syncTaskManager = mock(SynchronousTaskManager.class);
    SyncTunableMutatorFactory mutatorFactory = new SyncTunableMutatorFactory(new SyncTunableHandlerFactory());
    TunableRecorderManager recorderManager = new TunableRecorderManager();
    TunableSetter tunableSetter = new TunableSetterImpl(mutatorFactory, recorderManager);
    CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(VizmapReaderManager.class)).thenReturn(vizmapReaderMgr);
    when(serviceRegistrar.getService(VisualMappingManager.class)).thenReturn(vmMgr);
    when(serviceRegistrar.getService(SynchronousTaskManager.class)).thenReturn(syncTaskManager);
    when(serviceRegistrar.getService(TunableSetter.class)).thenReturn(tunableSetter);
    LoadVizmapFileTaskFactory factory = new LoadVizmapFileTaskFactoryImpl(serviceRegistrar);
    File file = new File("");
    TaskObserver observer = mock(TaskObserver.class);
    TaskIterator iterator = factory.createTaskIterator(file, observer);
    TaskMonitor taskMonitor = mock(TaskMonitor.class);
    while (iterator.hasNext()) {
        Task t = iterator.next();
        t.run(taskMonitor);
        if (t instanceof ObservableTask)
            observer.taskFinished((ObservableTask) t);
    }
    verify(observer, times(1)).taskFinished(any(ObservableTask.class));
}
Also used : Task(org.cytoscape.work.Task) ObservableTask(org.cytoscape.work.ObservableTask) SyncTunableHandlerFactory(org.cytoscape.work.internal.sync.SyncTunableHandlerFactory) VizmapReader(org.cytoscape.io.read.VizmapReader) URI(java.net.URI) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) VizmapReaderManager(org.cytoscape.io.read.VizmapReaderManager) TunableSetter(org.cytoscape.work.TunableSetter) LoadVizmapFileTaskFactory(org.cytoscape.task.read.LoadVizmapFileTaskFactory) TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) TunableRecorderManager(org.cytoscape.work.internal.sync.TunableRecorderManager) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) SyncTunableMutatorFactory(org.cytoscape.work.internal.sync.SyncTunableMutatorFactory) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) TunableSetterImpl(org.cytoscape.work.internal.sync.TunableSetterImpl) File(java.io.File) Test(org.junit.Test)

Example 52 with CyServiceRegistrar

use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.

the class CyActivator method start.

@Override
public void start(BundleContext bc) {
    final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
    startSpacial(bc, serviceRegistrar);
    startCustomGraphicsMgr(bc, serviceRegistrar);
    startCharts(bc, serviceRegistrar);
    startGradients(bc, serviceRegistrar);
    startPresentationImpl(bc, serviceRegistrar);
}
Also used : CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar)

Example 53 with CyServiceRegistrar

use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.

the class CyActivator method start.

@Override
public void start(BundleContext bc) {
    final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
    InterpreterImpl interpreter = new InterpreterImpl();
    EquationParserImpl parser = new EquationParserImpl(serviceRegistrar);
    EquationCompilerImpl compiler = new EquationCompilerImpl(parser);
    registerService(bc, compiler, EquationCompiler.class, new Properties());
    registerService(bc, interpreter, Interpreter.class, new Properties());
    registerService(bc, parser, EquationParser.class, new Properties());
    // For dynamically add functions.
    registerServiceListener(bc, parser::registerFunctionService, parser::unregisterFunctionService, Function.class);
}
Also used : InterpreterImpl(org.cytoscape.equations.internal.interpreter.InterpreterImpl) Properties(java.util.Properties) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar)

Example 54 with CyServiceRegistrar

use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.

the class CyActivator method start.

@Override
public void start(BundleContext bc) {
    final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
    TransformerManagerImpl transformerManager = new TransformerManagerImpl();
    registerService(bc, transformerManager, TransformerManager.class, new Properties());
    registerServiceListener(bc, transformerManager::registerTransformerSource, transformerManager::unregisterTransformerSource, TransformerSource.class);
    registerServiceListener(bc, transformerManager::registerFilterFactory, transformerManager::unregisterFilterFactory, FilterFactory.class);
    registerServiceListener(bc, transformerManager::registerElementTransformerFactory, transformerManager::unregisterElementTransformerFactory, ElementTransformerFactory.class);
    registerServiceListener(bc, transformerManager::registerHolisticTransformerFactory, transformerManager::unregisterHolisticTransformerFactory, HolisticTransformerFactory.class);
    TransformerViewManager transformerViewManager = new TransformerViewManager(transformerManager);
    registerServiceListener(bc, transformerViewManager::registerTransformerViewFactory, transformerViewManager::unregisterTransformerViewFactory, TransformerViewFactory.class);
    registerService(bc, new CyNetworkSource(), TransformerSource.class, new Properties());
    // Filters
    registerService(bc, new DegreeFilterFactory(), FilterFactory.class, new Properties());
    registerService(bc, new ColumnFilterFactory(), FilterFactory.class, new Properties());
    registerService(bc, new TopologyFilterFactory(), FilterFactory.class, new Properties());
    registerService(bc, new CompositeFilterFactory<CyNetwork, CyIdentifiable>(CyNetwork.class, CyIdentifiable.class), FilterFactory.class, new Properties());
    // Transformers
    registerService(bc, new InteractionTransformerFactory(), ElementTransformerFactory.class, new Properties());
    registerService(bc, new AdjacencyTransformerFactory(), ElementTransformerFactory.class, new Properties());
    ModelMonitor modelMonitor = new ModelMonitor();
    registerAllServices(bc, modelMonitor, new Properties());
    ValidationManager validationManager = new ValidationManager();
    registerAllServices(bc, validationManager, new Properties());
    FilterPanelStyle style = new FlatStyle();
    registerService(bc, new DegreeFilterViewFactory(style, modelMonitor), TransformerViewFactory.class, new Properties());
    registerService(bc, new ColumnFilterViewFactory(style, modelMonitor, serviceRegistrar), TransformerViewFactory.class, new Properties());
    registerService(bc, new TopologyFilterViewFactory(style), TransformerViewFactory.class, TopologyFilterViewFactory.getServiceProperties());
    registerService(bc, new InteractionTransformerViewFactory(style), TransformerViewFactory.class, new Properties());
    registerService(bc, new AdjacencyTransformerViewFactory(style, serviceRegistrar), TransformerViewFactory.class, AdjacencyTransformerViewFactory.getServiceProperties());
    LazyWorkQueue queue = new LazyWorkQueue();
    FilterIO filterIo = new FilterIO(serviceRegistrar);
    FilterWorker filterWorker = new FilterWorker(queue, serviceRegistrar);
    FilterPanelController filterPanelController = new FilterPanelController(transformerManager, transformerViewManager, validationManager, filterWorker, modelMonitor, filterIo, style, serviceRegistrar);
    FilterPanel filterPanel = new FilterPanel(filterPanelController, filterWorker, serviceRegistrar);
    TransformerWorker transformerWorker = new TransformerWorker(queue, transformerManager, serviceRegistrar);
    TransformerPanelController transformerPanelController = new TransformerPanelController(transformerManager, transformerViewManager, validationManager, filterPanelController, transformerWorker, filterIo, style, serviceRegistrar);
    TransformerPanel transformerPanel = new TransformerPanel(transformerPanelController, transformerWorker, serviceRegistrar);
    CytoPanelComponent selectPanel = new FilterCytoPanelComponent(transformerViewManager, modelMonitor, filterPanel, transformerPanel);
    registerService(bc, selectPanel, CytoPanelComponent.class, new Properties());
    FilterSettingsManager settingsManager = new FilterSettingsManager(filterPanel, transformerPanel, filterIo);
    registerService(bc, settingsManager, SessionAboutToBeSavedListener.class, new Properties());
    registerService(bc, settingsManager, SessionAboutToBeLoadedListener.class, new Properties());
    registerService(bc, settingsManager, SessionLoadedListener.class, new Properties());
    // new TransformerPanelManager API
    {
        Properties props = new Properties();
        props.setProperty("service.type", "manager");
        props.setProperty("container.type", "filter");
        registerService(bc, filterPanel, TransformerContainer.class, props);
    }
    {
        Properties props = new Properties();
        props.setProperty("service.type", "manager");
        props.setProperty("container.type", "chain");
        registerService(bc, transformerPanel, TransformerContainer.class, props);
    }
    // commands
    {
        Properties props = new Properties();
        props.setProperty(COMMAND, "import");
        props.setProperty(COMMAND_NAMESPACE, "filter");
        props.setProperty(COMMAND_DESCRIPTION, "Import filter JSON from a file.");
        props.setProperty(COMMAND_LONG_DESCRIPTION, "Import filter JSON from a file.");
        registerService(bc, new ImportNamedTransformersTaskFactory(filterIo, filterPanel), TaskFactory.class, props);
    }
    {
        Properties props = new Properties();
        props.setProperty(COMMAND, "export");
        props.setProperty(COMMAND_NAMESPACE, "filter");
        props.setProperty(COMMAND_DESCRIPTION, "Export filter JSON to a file.");
        props.setProperty(COMMAND_LONG_DESCRIPTION, "Export filter JSON to a file.");
        registerService(bc, new ExportNamedTransformersTaskFactory(filterIo, filterPanelController), TaskFactory.class, props);
    }
}
Also used : TransformerViewManager(org.cytoscape.filter.internal.view.TransformerViewManager) InteractionTransformerFactory(org.cytoscape.filter.internal.transformers.interaction.InteractionTransformerFactory) CyNetwork(org.cytoscape.model.CyNetwork) ServiceProperties(org.cytoscape.work.ServiceProperties) Properties(java.util.Properties) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) FilterPanel(org.cytoscape.filter.internal.view.FilterPanel) FilterPanelStyle(org.cytoscape.filter.internal.view.look.FilterPanelStyle) ExportNamedTransformersTaskFactory(org.cytoscape.filter.internal.tasks.ExportNamedTransformersTaskFactory) AdjacencyTransformerFactory(org.cytoscape.filter.internal.transformers.adjacency.AdjacencyTransformerFactory) LazyWorkQueue(org.cytoscape.filter.internal.work.LazyWorkQueue) TransformerManagerImpl(org.cytoscape.filter.internal.work.TransformerManagerImpl) ColumnFilterFactory(org.cytoscape.filter.internal.filters.column.ColumnFilterFactory) CyIdentifiable(org.cytoscape.model.CyIdentifiable) ValidationManager(org.cytoscape.filter.internal.work.ValidationManager) AdjacencyTransformerViewFactory(org.cytoscape.filter.internal.transformers.adjacency.AdjacencyTransformerViewFactory) ColumnFilterViewFactory(org.cytoscape.filter.internal.filters.column.ColumnFilterViewFactory) ImportNamedTransformersTaskFactory(org.cytoscape.filter.internal.tasks.ImportNamedTransformersTaskFactory) TopologyFilterFactory(org.cytoscape.filter.internal.filters.topology.TopologyFilterFactory) InteractionTransformerViewFactory(org.cytoscape.filter.internal.transformers.interaction.InteractionTransformerViewFactory) DegreeFilterFactory(org.cytoscape.filter.internal.filters.degree.DegreeFilterFactory) TopologyFilterViewFactory(org.cytoscape.filter.internal.filters.topology.TopologyFilterViewFactory) TransformerPanelController(org.cytoscape.filter.internal.view.TransformerPanelController) TransformerContainer(org.cytoscape.filter.TransformerContainer) TransformerPanel(org.cytoscape.filter.internal.view.TransformerPanel) FlatStyle(org.cytoscape.filter.internal.view.look.FlatStyle) FilterWorker(org.cytoscape.filter.internal.work.FilterWorker) DegreeFilterViewFactory(org.cytoscape.filter.internal.filters.degree.DegreeFilterViewFactory) TaskFactory(org.cytoscape.work.TaskFactory) ExportNamedTransformersTaskFactory(org.cytoscape.filter.internal.tasks.ExportNamedTransformersTaskFactory) ImportNamedTransformersTaskFactory(org.cytoscape.filter.internal.tasks.ImportNamedTransformersTaskFactory) FilterPanelController(org.cytoscape.filter.internal.view.FilterPanelController) TransformerWorker(org.cytoscape.filter.internal.work.TransformerWorker) CytoPanelComponent(org.cytoscape.application.swing.CytoPanelComponent)

Example 55 with CyServiceRegistrar

use of org.cytoscape.service.util.CyServiceRegistrar in project cytoscape-impl by cytoscape.

the class TestCyGroupFactory method getFactory.

public static CyGroupFactory getFactory() {
    final DummyCyEventHelper eventHelper = new DummyCyEventHelper();
    final VisualMappingManager vmMgr = mock(VisualMappingManager.class);
    final CyNetworkViewManager netViewMgr = mock(CyNetworkViewManager.class);
    final CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
    when(serviceRegistrar.getService(VisualMappingManager.class)).thenReturn(vmMgr);
    when(serviceRegistrar.getService(CyNetworkViewManager.class)).thenReturn(netViewMgr);
    final CyGroupManagerImpl mgr = new CyGroupManagerImpl(serviceRegistrar);
    final LockedVisualPropertiesManager lvpMgr = new LockedVisualPropertiesManager(serviceRegistrar);
    final CyGroupFactoryImpl groupFactory = new CyGroupFactoryImpl(mgr, lvpMgr);
    return groupFactory;
}
Also used : CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) CyGroupManagerImpl(org.cytoscape.group.internal.CyGroupManagerImpl) LockedVisualPropertiesManager(org.cytoscape.group.internal.LockedVisualPropertiesManager) DummyCyEventHelper(org.cytoscape.event.DummyCyEventHelper) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) CyGroupFactoryImpl(org.cytoscape.group.internal.CyGroupFactoryImpl) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar)

Aggregations

CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)62 Properties (java.util.Properties)32 CyEventHelper (org.cytoscape.event.CyEventHelper)14 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)13 CyApplicationManager (org.cytoscape.application.CyApplicationManager)12 UndoSupport (org.cytoscape.work.undo.UndoSupport)12 TaskIterator (org.cytoscape.work.TaskIterator)11 CyNetwork (org.cytoscape.model.CyNetwork)10 Task (org.cytoscape.work.Task)10 Before (org.junit.Before)10 Test (org.junit.Test)10 CyNetworkManager (org.cytoscape.model.CyNetworkManager)7 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)7 TaskFactory (org.cytoscape.work.TaskFactory)7 CyGroupManager (org.cytoscape.group.CyGroupManager)6 CyNetworkFactory (org.cytoscape.model.CyNetworkFactory)6 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)6 CyNetworkNaming (org.cytoscape.session.CyNetworkNaming)6 RenderingEngineManager (org.cytoscape.view.presentation.RenderingEngineManager)6 CyNetworkView (org.cytoscape.view.model.CyNetworkView)5