Search in sources :

Example 1 with VizmapReaderManager

use of org.cytoscape.io.read.VizmapReaderManager in project cytoscape-impl by cytoscape.

the class ImportDefaultVizmapTask method run.

@Override
public void run(final TaskMonitor taskMonitor) throws Exception {
    final VizmapReader reader;
    final VizmapReaderManager vizmapReaderMgr = servicesUtil.get(VizmapReaderManager.class);
    if (vizmapFile.exists() == false) {
        // get the file from resource
        final URL url = this.getClass().getClassLoader().getResource(VizMapperProxy.PRESET_VIZMAP_FILE);
        reader = vizmapReaderMgr.getReader(url.toURI(), url.getPath());
    } else {
        reader = vizmapReaderMgr.getReader(vizmapFile.toURI(), vizmapFile.getName());
    }
    logger.debug("Default vizmap file = " + vizmapFile.getName());
    if (reader == null)
        throw new NullPointerException("Failed to find Default Vizmap loader.");
    insertTasksAfterCurrentTask(reader, new AddVisualStylesTask(reader));
}
Also used : VizmapReader(org.cytoscape.io.read.VizmapReader) URL(java.net.URL) VizmapReaderManager(org.cytoscape.io.read.VizmapReaderManager)

Example 2 with VizmapReaderManager

use of org.cytoscape.io.read.VizmapReaderManager in project cytoscape-impl by cytoscape.

the class Cy3SessionReaderImplTest method setUp.

@Before
public void setUp() {
    InputStream is = mock(InputStream.class);
    GroupUtil groupUtil = mock(GroupUtil.class);
    SUIDUpdater suidUpdater = mock(SUIDUpdater.class);
    CyNetworkReaderManager netReaderMgr = mock(CyNetworkReaderManager.class);
    CyPropertyReaderManager propReaderMgr = mock(CyPropertyReaderManager.class);
    VizmapReaderManager vizmapReaderMgr = mock(VizmapReaderManager.class);
    CSVCyReaderFactory csvCyReaderFactory = mock(CSVCyReaderFactory.class);
    CyNetworkTableManager netTblMgr = mock(CyNetworkTableManager.class);
    CyRootNetworkManager rootNetMgr = mock(CyRootNetworkManager.class);
    EquationCompiler compiler = mock(EquationCompiler.class);
    CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyNetworkTableManager.class)).thenReturn(netTblMgr);
    when(serviceRegistrar.getService(CyRootNetworkManager.class)).thenReturn(rootNetMgr);
    when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
    ReadCache cache = new ReadCache(serviceRegistrar);
    reader = new Cy3SessionReaderImpl(is, cache, groupUtil, suidUpdater, netReaderMgr, propReaderMgr, vizmapReaderMgr, csvCyReaderFactory, serviceRegistrar);
    tblTestSupport = new TableTestSupport();
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) InputStream(java.io.InputStream) CyNetworkReaderManager(org.cytoscape.io.read.CyNetworkReaderManager) ReadCache(org.cytoscape.io.internal.util.ReadCache) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) GroupUtil(org.cytoscape.io.internal.util.GroupUtil) VizmapReaderManager(org.cytoscape.io.read.VizmapReaderManager) CyPropertyReaderManager(org.cytoscape.io.read.CyPropertyReaderManager) TableTestSupport(org.cytoscape.model.TableTestSupport) SUIDUpdater(org.cytoscape.io.internal.util.SUIDUpdater) CSVCyReaderFactory(org.cytoscape.io.internal.read.datatable.CSVCyReaderFactory) EquationCompiler(org.cytoscape.equations.EquationCompiler) Before(org.junit.Before)

Example 3 with VizmapReaderManager

use of org.cytoscape.io.read.VizmapReaderManager in project cytoscape-impl by cytoscape.

the class LoadVizmapFileTask method run.

@Override
public void run(final TaskMonitor taskMonitor) throws Exception {
    taskMonitor.setProgress(0.0);
    taskMonitor.setTitle("Load Styles from File");
    taskMonitor.setStatusMessage("Looking for a reader...");
    if (file == null)
        throw new NullPointerException("No file specified.");
    VizmapReaderManager readerManager = serviceRegistrar.getService(VizmapReaderManager.class);
    VizmapReader reader = readerManager.getReader(file.toURI(), file.getName());
    taskMonitor.setProgress(0.9);
    if (reader == null)
        throw new NullPointerException("Failed to find appropriate reader for file: " + file);
    addStyleTask = new AddVisualStylesTask(reader);
    insertTasksAfterCurrentTask(reader, addStyleTask);
    taskMonitor.setProgress(1.0);
}
Also used : VizmapReader(org.cytoscape.io.read.VizmapReader) VizmapReaderManager(org.cytoscape.io.read.VizmapReaderManager)

Example 4 with VizmapReaderManager

use of org.cytoscape.io.read.VizmapReaderManager 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)

Aggregations

VizmapReaderManager (org.cytoscape.io.read.VizmapReaderManager)4 VizmapReader (org.cytoscape.io.read.VizmapReader)3 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)2 File (java.io.File)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 URL (java.net.URL)1 EquationCompiler (org.cytoscape.equations.EquationCompiler)1 CSVCyReaderFactory (org.cytoscape.io.internal.read.datatable.CSVCyReaderFactory)1 GroupUtil (org.cytoscape.io.internal.util.GroupUtil)1 ReadCache (org.cytoscape.io.internal.util.ReadCache)1 SUIDUpdater (org.cytoscape.io.internal.util.SUIDUpdater)1 CyNetworkReaderManager (org.cytoscape.io.read.CyNetworkReaderManager)1 CyPropertyReaderManager (org.cytoscape.io.read.CyPropertyReaderManager)1 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)1 TableTestSupport (org.cytoscape.model.TableTestSupport)1 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)1 LoadVizmapFileTaskFactory (org.cytoscape.task.read.LoadVizmapFileTaskFactory)1 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)1 ObservableTask (org.cytoscape.work.ObservableTask)1