use of org.cytoscape.application.NetworkViewRenderer in project cytoscape-impl by cytoscape.
the class NewEmptyNetworkTask method run.
@Override
public void run(final TaskMonitor tm) {
tm.setProgress(0.0);
final String networkCollectionName = rootNetworkList.getSelectedValue();
if (networkCollectionName == null || networkCollectionName.equalsIgnoreCase(CRERATE_NEW_COLLECTION_STRING)) {
// This is a new network collection, create a root network and a subnetwork, which is a base subnetwork
subNetwork = (CySubNetwork) netFactory.createNetwork();
} else {
// Add a new subNetwork to the given collection
subNetwork = this.name2RootMap.get(networkCollectionName).addSubNetwork();
}
tm.setProgress(0.2);
final String networkName = namingUtil.getSuggestedNetworkTitle(name);
subNetwork.getRow(subNetwork).set(CyNetwork.NAME, networkName);
if (networkCollectionName == null || networkCollectionName.equalsIgnoreCase(CRERATE_NEW_COLLECTION_STRING)) {
// Set the name of new root network
final CyNetwork rootNetwork = subNetwork.getRootNetwork();
rootNetwork.getRow(rootNetwork).set(CyNetwork.NAME, networkName);
}
NetworkViewRenderer nvRenderer = null;
try {
nvRenderer = renderers.getSelectedValue();
} catch (ClassCastException cce) {
tm.showMessage(TaskMonitor.Level.WARN, "Unknown renderer: " + renderers.getSelectedValue() + " using default renderer.");
}
if (nvRenderer == null)
nvRenderer = appMgr.getDefaultNetworkViewRenderer();
final CyNetworkViewFactory netViewFactory = nvRenderer.getNetworkViewFactory();
tm.setProgress(0.4);
view = netViewFactory.createNetworkView(subNetwork);
tm.setProgress(0.6);
netMgr.addNetwork(subNetwork, false);
appMgr.setCurrentNetwork(subNetwork);
tm.setProgress(0.8);
// get the current style before registering the view!
final VisualStyle style = vmMgr.getCurrentVisualStyle();
netViewMgr.addNetworkView(view);
tm.setProgress(0.9);
applyVisualStyle(style);
tm.setProgress(1.0);
}
use of org.cytoscape.application.NetworkViewRenderer in project cytoscape-impl by cytoscape.
the class CombineReaderAndMappingTask method run.
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
this.taskMonitor = taskMonitor;
// Pass the tunable values from this task to the helper task
final String rootNetName = getRootNetworkList().getSelectedValue();
final String targetColumn = getTargetColumnList().getSelectedValue();
final NetworkViewRenderer renderer = getNetworkViewRendererList().getSelectedValue();
if (rootNetName != null) {
ListSingleSelection<String> ls = new ListSingleSelection<>(Collections.singletonList(rootNetName));
ls.setSelectedValue(rootNetName);
collectionHelper.setRootNetworkList(ls);
} else {
collectionHelper.setRootNetworkList(new ListSingleSelection<>(Collections.emptyList()));
collectionHelper.setTargetColumnList(new ListSingleSelection<>(Collections.emptyList()));
}
if (targetColumn != null) {
ListSingleSelection<String> ls = new ListSingleSelection<>(Collections.singletonList(targetColumn));
ls.setSelectedValue(targetColumn);
collectionHelper.setTargetColumnList(ls);
}
if (renderer != null) {
ListSingleSelection<NetworkViewRenderer> ls = new ListSingleSelection<>(Collections.singletonList(renderer));
ls.setSelectedValue(renderer);
collectionHelper.setNetworkViewRendererList(ls);
}
// Run the helper task
collectionHelper.run(taskMonitor);
// Run the Import task
importTask.setNodeMap(collectionHelper.getNodeMap());
importTask.setRootNetwork(collectionHelper.getRootNetwork());
importTask.setNetworkViewFactory(collectionHelper.getNetworkViewFactory());
importTask.run(taskMonitor);
}
use of org.cytoscape.application.NetworkViewRenderer in project cytoscape-impl by cytoscape.
the class DefaultNetworkViewFactory method createNetworkView.
@Override
public CyNetworkView createNetworkView(CyNetwork network) {
NetworkViewRenderer renderer = applicationManager.getDefaultNetworkViewRenderer();
CyNetworkViewFactory viewFactory = renderer.getNetworkViewFactory();
return viewFactory.createNetworkView(network);
}
use of org.cytoscape.application.NetworkViewRenderer in project cytoscape-impl by cytoscape.
the class CyApplicationManagerImplTest method testGetDefaultViewRenderer.
@Test
public void testGetDefaultViewRenderer() {
NetworkViewRenderer renderer1 = mock(NetworkViewRenderer.class);
when(renderer1.getId()).thenReturn("C");
NetworkViewRenderer renderer2 = mock(NetworkViewRenderer.class);
when(renderer2.getId()).thenReturn("B");
NetworkViewRenderer renderer3 = mock(NetworkViewRenderer.class);
when(renderer3.getId()).thenReturn("A");
appMgr.addNetworkViewRenderer(renderer1, Collections.EMPTY_MAP);
appMgr.addNetworkViewRenderer(renderer2, Collections.EMPTY_MAP);
appMgr.addNetworkViewRenderer(renderer3, Collections.EMPTY_MAP);
assertEquals(3, appMgr.getNetworkViewRendererSet().size());
assertEquals(renderer1, appMgr.getDefaultNetworkViewRenderer());
}
use of org.cytoscape.application.NetworkViewRenderer in project cytoscape-impl by cytoscape.
the class VisualStyleTest method setUp.
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
NetworkViewTestSupport nvts = new NetworkViewTestSupport();
network = nvts.getNetworkFactory().createNetwork();
node1 = network.addNode();
node2 = network.addNode();
node3 = network.addNode();
edge = network.addEdge(node1, node2, true);
CyTable nodeTable = network.getDefaultNodeTable();
nodeTable.createColumn(attrName, String.class, true);
nodeTable.getRow(node1.getSUID()).set(attrName, "red");
nodeTable.getRow(node2.getSUID()).set(attrName, "green");
nodeTable.getRow(node3.getSUID()).set(attrName, "foo");
networkView = nvts.getNetworkViewFactory().createNetworkView(network);
// Create root node.
final NullVisualProperty minimalRoot = new NullVisualProperty("MINIMAL_ROOT", "Minimal Root Visual Property");
final BasicVisualLexicon minimalLex = new BasicVisualLexicon(minimalRoot);
final Set<VisualLexicon> lexSet = new HashSet<VisualLexicon>();
lexSet.add(minimalLex);
final VisualMappingFunctionFactory ptFactory = mock(VisualMappingFunctionFactory.class);
eventHelper = mock(CyEventHelper.class);
final RenderingEngineFactory<CyNetwork> reFatory = mock(RenderingEngineFactory.class);
when(reFatory.getVisualLexicon()).thenReturn(minimalLex);
final NetworkViewRenderer nvRenderer = mock(NetworkViewRenderer.class);
when(nvRenderer.getRenderingEngineFactory(NetworkViewRenderer.DEFAULT_CONTEXT)).thenReturn(reFatory);
final CyApplicationManager appManager = mock(CyApplicationManager.class);
when(appManager.getCurrentNetworkViewRenderer()).thenReturn(nvRenderer);
final CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
when(serviceRegistrar.getService(CyApplicationManager.class)).thenReturn(appManager);
VisualProperty<NullDataType> rootVisualProperty = mock(VisualProperty.class);
BasicVisualLexicon lexicon = new BasicVisualLexicon(rootVisualProperty);
vpSet = new HashSet<VisualProperty<Paint>>();
vpSet.add(BasicVisualLexicon.NODE_BORDER_PAINT);
vpSet.add(BasicVisualLexicon.NODE_FILL_COLOR);
dependency = new VisualPropertyDependency<Paint>("dep1", "Dep 1", vpSet, lexicon);
final VisualStyleFactoryImpl visualStyleFactory = new VisualStyleFactoryImpl(serviceRegistrar, ptFactory);
originalTitle = "Style 1";
newTitle = "Style 2";
style = visualStyleFactory.createVisualStyle(originalTitle);
style.setDefaultValue(NODE_SIZE, DEF_NODE_SIZE);
style.setDefaultValue(NODE_FILL_COLOR, DEF_NODE_COLOR);
reset(eventHelper);
}
Aggregations