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));
}
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();
}
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);
}
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));
}
Aggregations