Search in sources :

Example 6 with CyNetworkView

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);
    });
}
Also used : VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 7 with CyNetworkView

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);
    });
}
Also used : Timer(javax.swing.Timer) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 8 with CyNetworkView

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());
    });
}
Also used : EMViewControlPanel(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel) CyNetworkView(org.cytoscape.view.model.CyNetworkView) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection)

Example 9 with CyNetworkView

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());
    });
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 10 with CyNetworkView

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);
}
Also used : EMStyleOptions(org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions) Task(org.cytoscape.work.Task) AbstractTask(org.cytoscape.work.AbstractTask) TaskIterator(org.cytoscape.work.TaskIterator) CyLayoutAlgorithm(org.cytoscape.view.layout.CyLayoutAlgorithm) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

CyNetworkView (org.cytoscape.view.model.CyNetworkView)41 Test (org.junit.Test)16 CyNetwork (org.cytoscape.model.CyNetwork)13 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)10 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)8 CyNode (org.cytoscape.model.CyNode)7 HashMap (java.util.HashMap)5 JPanel (javax.swing.JPanel)5 CyEdge (org.cytoscape.model.CyEdge)5 TaskIterator (org.cytoscape.work.TaskIterator)5 Timer (javax.swing.Timer)4 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)4 EMSignatureDataSet (org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet)4 CyTable (org.cytoscape.model.CyTable)4 CyCustomGraphics2 (org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2)4 Inject (com.google.inject.Inject)3 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 HashSet (java.util.HashSet)3 List (java.util.List)3