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