Search in sources :

Example 1 with VizmapReader

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

use of org.cytoscape.io.read.VizmapReader 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 3 with VizmapReader

use of org.cytoscape.io.read.VizmapReader 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 4 with VizmapReader

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

the class Cy2SessionReaderImpl method extractVizmap.

private void extractVizmap(InputStream is, String entryName) throws Exception {
    VizmapReader reader = vizmapReaderMgr.getReader(is, entryName);
    reader.run(taskMonitor);
    visualStyles.addAll(reader.getVisualStyles());
}
Also used : VizmapReader(org.cytoscape.io.read.VizmapReader)

Example 5 with VizmapReader

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

the class Cy3SessionReaderImpl method extractVizmap.

private void extractVizmap(InputStream is, String entryName) throws Exception {
    VizmapReader reader = vizmapReaderMgr.getReader(is, entryName);
    reader.run(taskMonitor);
    visualStyles.addAll(reader.getVisualStyles());
}
Also used : VizmapReader(org.cytoscape.io.read.VizmapReader)

Aggregations

VizmapReader (org.cytoscape.io.read.VizmapReader)5 VizmapReaderManager (org.cytoscape.io.read.VizmapReaderManager)3 File (java.io.File)1 URI (java.net.URI)1 URL (java.net.URL)1 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)1 LoadVizmapFileTaskFactory (org.cytoscape.task.read.LoadVizmapFileTaskFactory)1 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)1 ObservableTask (org.cytoscape.work.ObservableTask)1 Task (org.cytoscape.work.Task)1 TaskIterator (org.cytoscape.work.TaskIterator)1 TaskMonitor (org.cytoscape.work.TaskMonitor)1 TaskObserver (org.cytoscape.work.TaskObserver)1 TunableSetter (org.cytoscape.work.TunableSetter)1 SyncTunableHandlerFactory (org.cytoscape.work.internal.sync.SyncTunableHandlerFactory)1 SyncTunableMutatorFactory (org.cytoscape.work.internal.sync.SyncTunableMutatorFactory)1 TunableRecorderManager (org.cytoscape.work.internal.sync.TunableRecorderManager)1 TunableSetterImpl (org.cytoscape.work.internal.sync.TunableSetterImpl)1 Test (org.junit.Test)1