Search in sources :

Example 6 with EMViewControlPanel

use of org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel in project EnrichmentMapApp by BaderLab.

the class ControlPanelMediator method getOptionsMenu.

private JPopupMenu getOptionsMenu() {
    final JPopupMenu menu = new JPopupMenu();
    {
        final JMenuItem mi = new JCheckBoxMenuItem("Show Legend");
        mi.addActionListener(evt -> {
            if (legendPanelMediatorProvider.get().getDialog().isVisible()) {
                legendPanelMediatorProvider.get().hideDialog();
            } else {
                CyNetworkView netView = getCurrentEMView();
                EMViewControlPanel viewPanel = getControlPanel().getViewControlPanel(netView);
                legendPanelMediatorProvider.get().showDialog(createStyleOptions(netView), getFilteredDataSets(viewPanel));
            }
        });
        mi.setSelected(legendPanelMediatorProvider.get().getDialog().isVisible());
        menu.add(mi);
    }
    menu.addSeparator();
    for (FilterMode mode : FilterMode.values()) {
        final JMenuItem mi = new JCheckBoxMenuItem(mode.toString());
        mi.addActionListener(evt -> setFilterMode(mode));
        mi.setSelected(filterMode == mode);
        menu.add(mi);
    }
    return menu;
}
Also used : ViewParams(org.baderlab.csplugins.enrichmentmap.view.control.io.ViewParams) ChartType(org.baderlab.csplugins.enrichmentmap.style.ChartType) EMViewControlPanel(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel) Inject(com.google.inject.Inject) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection) SliderBarPanel(org.baderlab.csplugins.enrichmentmap.view.util.SliderBarPanel) CyCustomGraphics2(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) CyNetwork(org.cytoscape.model.CyNetwork) Map(java.util.Map) SetCurrentNetworkViewEvent(org.cytoscape.application.events.SetCurrentNetworkViewEvent) LegendPanelMediator(org.baderlab.csplugins.enrichmentmap.view.legend.LegendPanelMediator) FinishStatus(org.cytoscape.work.FinishStatus) JComboBox(javax.swing.JComboBox) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) EDGE_DATASET_VALUE_COMPOUND(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_DATASET_VALUE_COMPOUND) Timer(javax.swing.Timer) EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) ChartData(org.baderlab.csplugins.enrichmentmap.style.ChartData) Columns(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns) ItemEvent(java.awt.event.ItemEvent) EMStyleOptions(org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions) NetworkViewAboutToBeDestroyedListener(org.cytoscape.view.model.events.NetworkViewAboutToBeDestroyedListener) Collection(java.util.Collection) SetCurrentNetworkViewListener(org.cytoscape.application.events.SetCurrentNetworkViewListener) Set(java.util.Set) CyNetworkManager(org.cytoscape.model.CyNetworkManager) FilterMode(org.baderlab.csplugins.enrichmentmap.task.FilterNodesEdgesTask.FilterMode) Collectors(java.util.stream.Collectors) NODE_GS_TYPE(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.NODE_GS_TYPE) ColorScheme(org.baderlab.csplugins.enrichmentmap.style.ColorScheme) AbstractDataSet(org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet) ColumnDescriptor(org.baderlab.csplugins.enrichmentmap.style.ColumnDescriptor) List(java.util.List) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CySwingApplication(org.cytoscape.application.swing.CySwingApplication) RemoveSignatureDataSetsTask(org.baderlab.csplugins.enrichmentmap.task.postanalysis.RemoveSignatureDataSetsTask) TaskObserver(org.cytoscape.work.TaskObserver) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) ApplyEMStyleTask(org.baderlab.csplugins.enrichmentmap.task.ApplyEMStyleTask) ObservableTask(org.cytoscape.work.ObservableTask) Singleton(com.google.inject.Singleton) ActionListener(java.awt.event.ActionListener) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) EDGE_INTERACTION_VALUE_SIG(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_INTERACTION_VALUE_SIG) CyNode(org.cytoscape.model.CyNode) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) NetworkViewAboutToBeDestroyedEvent(org.cytoscape.view.model.events.NetworkViewAboutToBeDestroyedEvent) HashMap(java.util.HashMap) Action(javax.swing.Action) TaskIterator(org.cytoscape.work.TaskIterator) HashSet(java.util.HashSet) FilterNodesEdgesTask(org.baderlab.csplugins.enrichmentmap.task.FilterNodesEdgesTask) CyRow(org.cytoscape.model.CyRow) JMenuItem(javax.swing.JMenuItem) PostAnalysisPanelMediator(org.baderlab.csplugins.enrichmentmap.view.postanalysis.PostAnalysisPanelMediator) ShowEnrichmentMapDialogAction(org.baderlab.csplugins.enrichmentmap.actions.ShowEnrichmentMapDialogAction) ChartOptions(org.baderlab.csplugins.enrichmentmap.style.ChartOptions) NetworkViewAddedListener(org.cytoscape.view.model.events.NetworkViewAddedListener) CyTable(org.cytoscape.model.CyTable) NetworkViewAddedEvent(org.cytoscape.view.model.events.NetworkViewAddedEvent) Properties(java.util.Properties) CyCustomGraphics2Factory(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2Factory) JPopupMenu(javax.swing.JPopupMenu) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier) EnrichmentMapManager(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapManager) JOptionPane(javax.swing.JOptionPane) CutoffParam(org.baderlab.csplugins.enrichmentmap.view.control.io.ViewParams.CutoffParam) ActionEvent(java.awt.event.ActionEvent) CytoPanel(org.cytoscape.application.swing.CytoPanel) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) CytoPanelComponent(org.cytoscape.application.swing.CytoPanelComponent) Provider(com.google.inject.Provider) EdgeWidthDialog(org.baderlab.csplugins.enrichmentmap.view.postanalysis.EdgeWidthDialog) NODE_GS_TYPE_ENRICHMENT(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.NODE_GS_TYPE_ENRICHMENT) ForkJoinPool(java.util.concurrent.ForkJoinPool) ChartUtil(org.baderlab.csplugins.enrichmentmap.view.util.ChartUtil) ChartFactoryManager(org.baderlab.csplugins.enrichmentmap.style.ChartFactoryManager) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyColumnIdentifierFactory(org.cytoscape.view.presentation.property.values.CyColumnIdentifierFactory) EMSignatureDataSet(org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet) CyEdge(org.cytoscape.model.CyEdge) WidthFunction(org.baderlab.csplugins.enrichmentmap.style.WidthFunction) Collections(java.util.Collections) SwingUtil.invokeOnEDT(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil.invokeOnEDT) EMViewControlPanel(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel) FilterMode(org.baderlab.csplugins.enrichmentmap.task.FilterNodesEdgesTask.FilterMode) JMenuItem(javax.swing.JMenuItem) CyNetworkView(org.cytoscape.view.model.CyNetworkView) JPopupMenu(javax.swing.JPopupMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 7 with EMViewControlPanel

use of org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel in project EnrichmentMapApp by BaderLab.

the class ControlPanelMediator method addNetworkView.

@SuppressWarnings("unchecked")
private void addNetworkView(CyNetworkView netView) {
    invokeOnEDT(() -> {
        EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
        // Is the new view an EnrichmentMap one?
        if (map != null) {
            EMViewControlPanel viewPanel = getControlPanel().addEnrichmentMapView(netView);
            if (viewPanel != null) {
                // Add listeners to the new panel's fields
                viewPanel.getQValueRadio().addActionListener(evt -> {
                    viewPanel.updateFilterPanel();
                    if (!updating)
                        filterNodesAndEdges(viewPanel, map);
                });
                viewPanel.getPValueRadio().addActionListener(evt -> {
                    viewPanel.updateFilterPanel();
                    if (!updating)
                        filterNodesAndEdges(viewPanel, map);
                });
                SliderBarPanel pvSliderPanel = viewPanel.getPValueSliderPanel();
                SliderBarPanel qvSliderPanel = viewPanel.getQValueSliderPanel();
                SliderBarPanel sSliderPanel = viewPanel.getSimilaritySliderPanel();
                if (pvSliderPanel != null)
                    pvSliderPanel.addChangeListener(evt -> {
                        if (!updating)
                            filterNodesAndEdges(viewPanel, map);
                    });
                if (qvSliderPanel != null)
                    qvSliderPanel.addChangeListener(evt -> {
                        if (!updating)
                            filterNodesAndEdges(viewPanel, map);
                    });
                if (sSliderPanel != null)
                    sSliderPanel.addChangeListener(evt -> {
                        if (!updating)
                            filterNodesAndEdges(viewPanel, map);
                    });
                viewPanel.getDataSetSelector().addPropertyChangeListener("checkedData", evt -> {
                    if (!updating) {
                        viewPanel.updateChartDataCombo();
                        filterNodesAndEdges(viewPanel, map);
                        ChartData data = (ChartData) viewPanel.getChartDataCombo().getSelectedItem();
                        Set<EMDataSet> oldDataSets = filterDataSets((Collection<AbstractDataSet>) evt.getOldValue());
                        Set<EMDataSet> newDataSets = filterDataSets((Collection<AbstractDataSet>) evt.getNewValue());
                        int oldSize = oldDataSets.size();
                        int newSize = newDataSets.size();
                        boolean updateStyle = data != null && data != ChartData.NONE && oldSize != newSize;
                        updateStyle = updateStyle || oldSize == 0 && newSize > 0;
                        updateStyle = updateStyle || oldSize > 0 && newSize == 0;
                        updateStyle = updateStyle || oldSize == 1 && newSize > 1;
                        updateStyle = updateStyle || oldSize > 1 && newSize == 1;
                        if (updateStyle)
                            updateVisualStyle(map, viewPanel);
                        else
                            netView.updateView();
                    }
                });
                viewPanel.getDataSetSelector().getAddButton().addActionListener(evt -> {
                    postAnalysisPanelMediatorProvider.get().showDialog(viewPanel, netView);
                });
                viewPanel.getDataSetSelector().getRemoveButton().addActionListener(evt -> {
                    removeSignatureDataSets(map, viewPanel);
                });
                viewPanel.getChartDataCombo().addItemListener(evt -> {
                    if (!updating && evt.getStateChange() == ItemEvent.SELECTED) {
                        updating = true;
                        try {
                            viewPanel.updateChartCombos();
                        } finally {
                            updating = false;
                        }
                        updateVisualStyle(map, viewPanel, true);
                    }
                });
                viewPanel.getChartTypeCombo().addItemListener(evt -> {
                    if (!updating && evt.getStateChange() == ItemEvent.SELECTED) {
                        updating = true;
                        try {
                            viewPanel.updateChartColorsCombo();
                            viewPanel.updateChartLabelsCheck();
                        } finally {
                            updating = false;
                        }
                        updateVisualStyle(map, viewPanel, true);
                    }
                });
                viewPanel.getChartColorsCombo().addItemListener(evt -> {
                    if (!updating && evt.getStateChange() == ItemEvent.SELECTED)
                        updateVisualStyle(map, viewPanel, true);
                });
                viewPanel.getShowChartLabelsCheck().addActionListener(evt -> {
                    if (!updating)
                        updateVisualStyle(map, viewPanel, true);
                });
                viewPanel.getPublicationReadyCheck().addActionListener(evt -> {
                    if (!updating)
                        updateVisualStyle(map, viewPanel);
                });
                viewPanel.getResetStyleButton().addActionListener(evt -> {
                    updateVisualStyle(map, viewPanel);
                });
                viewPanel.getSetEdgeWidthButton().addActionListener(evt -> {
                    showEdgeWidthDialog();
                });
                viewPanel.updateChartDataCombo();
            }
        }
    });
}
Also used : EMViewControlPanel(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel) ViewParams(org.baderlab.csplugins.enrichmentmap.view.control.io.ViewParams) ChartType(org.baderlab.csplugins.enrichmentmap.style.ChartType) EMViewControlPanel(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel) Inject(com.google.inject.Inject) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection) SliderBarPanel(org.baderlab.csplugins.enrichmentmap.view.util.SliderBarPanel) CyCustomGraphics2(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) CyNetwork(org.cytoscape.model.CyNetwork) Map(java.util.Map) SetCurrentNetworkViewEvent(org.cytoscape.application.events.SetCurrentNetworkViewEvent) LegendPanelMediator(org.baderlab.csplugins.enrichmentmap.view.legend.LegendPanelMediator) FinishStatus(org.cytoscape.work.FinishStatus) JComboBox(javax.swing.JComboBox) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) EDGE_DATASET_VALUE_COMPOUND(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_DATASET_VALUE_COMPOUND) Timer(javax.swing.Timer) EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) ChartData(org.baderlab.csplugins.enrichmentmap.style.ChartData) Columns(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns) ItemEvent(java.awt.event.ItemEvent) EMStyleOptions(org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions) NetworkViewAboutToBeDestroyedListener(org.cytoscape.view.model.events.NetworkViewAboutToBeDestroyedListener) Collection(java.util.Collection) SetCurrentNetworkViewListener(org.cytoscape.application.events.SetCurrentNetworkViewListener) Set(java.util.Set) CyNetworkManager(org.cytoscape.model.CyNetworkManager) FilterMode(org.baderlab.csplugins.enrichmentmap.task.FilterNodesEdgesTask.FilterMode) Collectors(java.util.stream.Collectors) NODE_GS_TYPE(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.NODE_GS_TYPE) ColorScheme(org.baderlab.csplugins.enrichmentmap.style.ColorScheme) AbstractDataSet(org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet) ColumnDescriptor(org.baderlab.csplugins.enrichmentmap.style.ColumnDescriptor) List(java.util.List) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CySwingApplication(org.cytoscape.application.swing.CySwingApplication) RemoveSignatureDataSetsTask(org.baderlab.csplugins.enrichmentmap.task.postanalysis.RemoveSignatureDataSetsTask) TaskObserver(org.cytoscape.work.TaskObserver) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) ApplyEMStyleTask(org.baderlab.csplugins.enrichmentmap.task.ApplyEMStyleTask) ObservableTask(org.cytoscape.work.ObservableTask) Singleton(com.google.inject.Singleton) ActionListener(java.awt.event.ActionListener) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) EDGE_INTERACTION_VALUE_SIG(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_INTERACTION_VALUE_SIG) CyNode(org.cytoscape.model.CyNode) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) NetworkViewAboutToBeDestroyedEvent(org.cytoscape.view.model.events.NetworkViewAboutToBeDestroyedEvent) HashMap(java.util.HashMap) Action(javax.swing.Action) TaskIterator(org.cytoscape.work.TaskIterator) HashSet(java.util.HashSet) FilterNodesEdgesTask(org.baderlab.csplugins.enrichmentmap.task.FilterNodesEdgesTask) CyRow(org.cytoscape.model.CyRow) JMenuItem(javax.swing.JMenuItem) PostAnalysisPanelMediator(org.baderlab.csplugins.enrichmentmap.view.postanalysis.PostAnalysisPanelMediator) ShowEnrichmentMapDialogAction(org.baderlab.csplugins.enrichmentmap.actions.ShowEnrichmentMapDialogAction) ChartOptions(org.baderlab.csplugins.enrichmentmap.style.ChartOptions) NetworkViewAddedListener(org.cytoscape.view.model.events.NetworkViewAddedListener) CyTable(org.cytoscape.model.CyTable) NetworkViewAddedEvent(org.cytoscape.view.model.events.NetworkViewAddedEvent) Properties(java.util.Properties) CyCustomGraphics2Factory(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2Factory) JPopupMenu(javax.swing.JPopupMenu) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier) EnrichmentMapManager(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapManager) JOptionPane(javax.swing.JOptionPane) CutoffParam(org.baderlab.csplugins.enrichmentmap.view.control.io.ViewParams.CutoffParam) ActionEvent(java.awt.event.ActionEvent) CytoPanel(org.cytoscape.application.swing.CytoPanel) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) CytoPanelComponent(org.cytoscape.application.swing.CytoPanelComponent) Provider(com.google.inject.Provider) EdgeWidthDialog(org.baderlab.csplugins.enrichmentmap.view.postanalysis.EdgeWidthDialog) NODE_GS_TYPE_ENRICHMENT(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.NODE_GS_TYPE_ENRICHMENT) ForkJoinPool(java.util.concurrent.ForkJoinPool) ChartUtil(org.baderlab.csplugins.enrichmentmap.view.util.ChartUtil) ChartFactoryManager(org.baderlab.csplugins.enrichmentmap.style.ChartFactoryManager) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyColumnIdentifierFactory(org.cytoscape.view.presentation.property.values.CyColumnIdentifierFactory) EMSignatureDataSet(org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet) CyEdge(org.cytoscape.model.CyEdge) WidthFunction(org.baderlab.csplugins.enrichmentmap.style.WidthFunction) Collections(java.util.Collections) SwingUtil.invokeOnEDT(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil.invokeOnEDT) ChartData(org.baderlab.csplugins.enrichmentmap.style.ChartData) AbstractDataSet(org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) SliderBarPanel(org.baderlab.csplugins.enrichmentmap.view.util.SliderBarPanel)

Aggregations

EMViewControlPanel (org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel)7 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)4 Inject (com.google.inject.Inject)3 Provider (com.google.inject.Provider)3 Singleton (com.google.inject.Singleton)3 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 ItemEvent (java.awt.event.ItemEvent)3 Collection (java.util.Collection)3 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Map (java.util.Map)3 Properties (java.util.Properties)3 Set (java.util.Set)3 ForkJoinPool (java.util.concurrent.ForkJoinPool)3 Collectors (java.util.stream.Collectors)3 Action (javax.swing.Action)3 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)3