use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.
the class ControlPanelMediator method setCurrentView.
private void setCurrentView(CyNetworkView netView) {
ForkJoinPool.commonPool().submit(() -> {
// Work around a bug in Cytoscape.
// When the current network view is changed it can lose its style, so set it back.
CyNetworkView prevNetView = applicationManager.getCurrentNetworkView();
VisualStyle visualStyle = visualMappingManager.getVisualStyle(prevNetView);
applicationManager.setCurrentNetworkView(netView);
visualMappingManager.setVisualStyle(visualStyle, prevNetView);
});
}
use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.
the class ControlPanelMediator method handleEvent.
@Override
public void handleEvent(NetworkViewAboutToBeDestroyedEvent e) {
final CyNetworkView netView = e.getNetworkView();
Timer timer = filterTimers.remove(netView);
if (timer != null)
timer.stop();
invokeOnEDT(() -> {
getControlPanel().removeEnrichmentMapView(netView);
});
}
use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.
the class ControlPanelMediator method init.
@AfterInjection
private void init() {
ControlPanel ctrlPanel = getControlPanel();
ctrlPanel.getCreateEmButton().addActionListener(evt -> {
masterMapDialogAction.actionPerformed(evt);
});
ctrlPanel.getCreateEmButton().setToolTipText("" + masterMapDialogAction.getValue(Action.NAME));
ctrlPanel.getOptionsButton().addActionListener(evt -> {
getOptionsMenu().show(ctrlPanel.getOptionsButton(), 0, ctrlPanel.getOptionsButton().getHeight());
});
ctrlPanel.getClosePanelButton().addActionListener(evt -> {
closeControlPanel();
});
ctrlPanel.update(applicationManager.getCurrentNetworkView());
// Wait until the UI is initialized to add this listener to the combo box
JComboBox<CyNetworkView> cmb = ctrlPanel.getEmViewCombo();
cmb.addActionListener(evt -> {
if (!updating)
setCurrentView((CyNetworkView) cmb.getSelectedItem());
});
}
use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.
the class ControlPanelMediator method reset.
public void reset() {
invokeOnEDT(() -> {
updating = true;
try {
for (CyNetworkView view : networkViewManager.getNetworkViewSet()) getControlPanel().removeEnrichmentMapView(view);
Map<Long, EnrichmentMap> maps = emManager.getAllEnrichmentMaps();
for (EnrichmentMap map : maps.values()) {
CyNetwork network = networkManager.getNetwork(map.getNetworkID());
Collection<CyNetworkView> networkViews = networkViewManager.getNetworkViews(network);
for (CyNetworkView netView : networkViews) addNetworkView(netView);
}
} finally {
updating = false;
}
setCurrentNetworkView(applicationManager.getCurrentNetworkView());
});
}
use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.
the class CreateEMViewTask method visualizeMap.
private void visualizeMap() {
CyNetwork network = networkManager.getNetwork(map.getNetworkID());
CyNetworkView view = networkViewFactory.createNetworkView(network);
networkViewManager.addNetworkView(view);
//apply force directed layout
CyLayoutAlgorithm layout = layoutManager.getLayout("force-directed");
if (layout == null)
layout = layoutManager.getDefaultLayout();
Task styleTask = applyStyleTaskFactory.create(new EMStyleOptions(view, map), null, false);
TaskIterator layoutTasks = layout.createTaskIterator(view, layout.createLayoutContext(), CyLayoutAlgorithm.ALL_NODE_VIEWS, null);
TaskIterator moreTasks = new TaskIterator();
moreTasks.append(styleTask);
moreTasks.append(layoutTasks);
insertTasksAfterCurrentTask(moreTasks);
}
Aggregations