Search in sources :

Example 26 with CyNetworkView

use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.

the class LegendPanel method update.

/**
	 * Update parameters panel based on given enrichment map parameters
	 * @param chartType 
	 */
void update(EMStyleOptions options, Collection<EMDataSet> filteredDataSets) {
    this.options = options;
    CyNetworkView networkView = options != null ? options.getNetworkView() : null;
    removeAll();
    EnrichmentMap map = networkView != null ? emManager.getEnrichmentMap(networkView.getModel().getSUID()) : null;
    EMCreationParameters params = map != null ? map.getParams() : null;
    if (params == null) {
        JLabel infoLabel = new JLabel("No EnrichmentMap View selected");
        infoLabel.setEnabled(false);
        infoLabel.setForeground(UIManager.getColor("Label.disabledForeground"));
        infoLabel.setHorizontalAlignment(JLabel.CENTER);
        infoLabel.setVerticalAlignment(JLabel.CENTER);
        infoLabel.setBorder(new EmptyBorder(120, 40, 120, 40));
        add(infoLabel, BorderLayout.CENTER);
    } else {
        nodeLegendPanel = null;
        nodeColorPanel = null;
        nodeShapePanel = null;
        nodeChartPanel = null;
        edgeLegendPanel = null;
        edgeColorPanel = null;
        updateNodeColorPanel(filteredDataSets, map);
        updateNodeShapePanel(map);
        updateNodeChartPanel(filteredDataSets, map);
        updateEdgeColorPanel(map);
        JPanel panel = new JPanel();
        final GroupLayout layout = new GroupLayout(panel);
        panel.setLayout(layout);
        layout.setAutoCreateContainerGaps(true);
        layout.setAutoCreateGaps(true);
        layout.setHorizontalGroup(layout.createParallelGroup(Alignment.CENTER, true).addComponent(getNodeLegendPanel(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(getEdgeLegendPanel(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createSequentialGroup().addComponent(getNodeLegendPanel(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(getEdgeLegendPanel(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE));
        JScrollPane scrollPane = new JScrollPane(panel);
        add(scrollPane, BorderLayout.CENTER);
    }
    revalidate();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) GroupLayout(javax.swing.GroupLayout) JLabel(javax.swing.JLabel) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) EmptyBorder(javax.swing.border.EmptyBorder) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 27 with CyNetworkView

use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.

the class LegendPanelMediator method showCreationParamsDialog.

@SuppressWarnings("serial")
private void showCreationParamsDialog() {
    JDialog d = new JDialog(dialog, "EnrichmentMap Creation Parameters", ModalityType.APPLICATION_MODAL);
    d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    d.setMinimumSize(new Dimension(420, 260));
    d.setPreferredSize(new Dimension(580, 460));
    JButton closeButton = new JButton(new AbstractAction("Close") {

        @Override
        public void actionPerformed(ActionEvent e) {
            d.dispose();
        }
    });
    JPanel bottomPanel = LookAndFeelUtil.createOkCancelPanel(null, closeButton);
    d.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
    CyNetworkView netView = legendPanelProvider.get().getOptions().getNetworkView();
    if (netView != null) {
        EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
        CreationParametersPanel paramsPanel = new CreationParametersPanel(map);
        d.getContentPane().add(paramsPanel, BorderLayout.CENTER);
    }
    LookAndFeelUtil.setDefaultOkCancelKeyStrokes(d.getRootPane(), null, closeButton.getAction());
    d.getRootPane().setDefaultButton(closeButton);
    d.setLocationRelativeTo(dialog);
    d.pack();
    d.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) AbstractAction(javax.swing.AbstractAction) CyNetworkView(org.cytoscape.view.model.CyNetworkView) JDialog(javax.swing.JDialog)

Example 28 with CyNetworkView

use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.

the class LegendPanel method updateEdgeColorPanel.

private void updateEdgeColorPanel(EnrichmentMap map) {
    JPanel p = getEdgeColorPanel();
    CyNetworkView netView = options.getNetworkView();
    VisualStyle style = netView != null ? visualMappingManager.getVisualStyle(netView) : null;
    JComponent[][] entries = null;
    if (map != null) {
        Dimension iconSize = new Dimension(LEGEND_ICON_SIZE, LEGEND_ICON_SIZE / 2);
        if (map.getParams().getCreateDistinctEdges()) {
            VisualMappingFunction<?, Paint> mf = style.getVisualMappingFunction(BasicVisualLexicon.EDGE_STROKE_UNSELECTED_PAINT);
            if (mf instanceof DiscreteMapping) {
                DiscreteMapping<?, Paint> dm = (DiscreteMapping<?, Paint>) mf;
                final Collator collator = Collator.getInstance();
                Map<Object, Paint> dmMap = new TreeMap<>((Object o1, Object o2) -> {
                    return collator.compare("" + o1, "" + o2);
                });
                dmMap.putAll(dm.getAll());
                dmMap.remove(Columns.EDGE_DATASET_VALUE_COMPOUND);
                if (!map.hasSignatureDataSets())
                    dmMap.remove(Columns.EDGE_DATASET_VALUE_SIG);
                if (dmMap.size() > 0) {
                    entries = new JComponent[dmMap.size()][2];
                    int i = 0;
                    for (Entry<?, Paint> e : dmMap.entrySet()) {
                        Color color = null;
                        if (e.getValue() instanceof Color)
                            color = (Color) e.getValue();
                        JLabel iconLabel = createColorLabel(color, iconSize);
                        JLabel descLabel = new JLabel("" + e.getKey());
                        if (Columns.EDGE_DATASET_VALUE_SIG.equals(e.getKey()))
                            descLabel.setFont(descLabel.getFont().deriveFont(Font.ITALIC));
                        entries[i++] = new JComponent[] { iconLabel, descLabel };
                    }
                }
            }
        }
        if (entries == null) {
            int rows = map.hasSignatureDataSets() ? 2 : 1;
            entries = new JComponent[rows][2];
            {
                JLabel iconLabel = createColorLabel(Colors.COMPOUND_EDGE_COLOR, iconSize);
                JLabel descLabel = new JLabel(Columns.EDGE_DATASET_VALUE_COMPOUND);
                descLabel.setFont(descLabel.getFont().deriveFont(Font.ITALIC));
                entries[0] = new JComponent[] { iconLabel, descLabel };
            }
            if (rows == 2) {
                JLabel iconLabel = createColorLabel(Colors.SIG_EDGE_COLOR, iconSize);
                JLabel descLabel = new JLabel(Columns.EDGE_DATASET_VALUE_SIG);
                descLabel.setFont(descLabel.getFont().deriveFont(Font.ITALIC));
                entries[1] = new JComponent[] { iconLabel, descLabel };
            }
        }
    }
    updateStyleLegendPanel(entries, p);
}
Also used : JPanel(javax.swing.JPanel) Color(java.awt.Color) DiscreteMapping(org.cytoscape.view.vizmap.mappings.DiscreteMapping) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Paint(java.awt.Paint) TreeMap(java.util.TreeMap) Paint(java.awt.Paint) Collator(java.text.Collator) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 29 with CyNetworkView

use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.

the class LegendPanel method updateNodeShapePanel.

private void updateNodeShapePanel(EnrichmentMap map) {
    JPanel p = getNodeShapePanel();
    p.removeAll();
    CyNetworkView netView = options.getNetworkView();
    VisualStyle style = netView != null ? visualMappingManager.getVisualStyle(netView) : null;
    nodeShapeIcon1.setVisible(style != null);
    nodeShapeDesc1.setVisible(style != null);
    nodeShapeIcon2.setVisible(style != null && map.hasSignatureDataSets());
    nodeShapeDesc2.setVisible(style != null && map.hasSignatureDataSets());
    if (style != null) {
        NodeShape shape = EMStyleBuilder.getGeneSetNodeShape(style);
        nodeShapeIcon1.setIcon(getIcon(BasicVisualLexicon.NODE_SHAPE, shape, netView));
        if (map.hasSignatureDataSets()) {
            shape = EMStyleBuilder.getSignatureNodeShape(style);
            nodeShapeIcon2.setIcon(getIcon(BasicVisualLexicon.NODE_SHAPE, shape, netView));
        }
    }
    p.revalidate();
}
Also used : JPanel(javax.swing.JPanel) NodeShape(org.cytoscape.view.presentation.property.values.NodeShape) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 30 with CyNetworkView

use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.

the class PAKnownSignatureCommandTask method run.

@Override
public void run(TaskMonitor taskMonitor) throws Exception {
    if (gmtFile == null || !gmtFile.canRead())
        throw new IllegalArgumentException("Signature GMT file name not valid");
    CyNetwork selectedNetwork;
    CyNetworkView selectedView;
    if (network == null) {
        selectedNetwork = applicationManager.getCurrentNetwork();
        selectedView = applicationManager.getCurrentNetworkView();
        if (selectedNetwork == null || selectedView == null) {
            throw new IllegalArgumentException("Current network not available.");
        }
    } else {
        selectedNetwork = network;
        Collection<CyNetworkView> networkViews = networkViewManager.getNetworkViews(network);
        if (networkViews == null || networkViews.isEmpty()) {
            throw new IllegalArgumentException("No network view for: " + network);
        }
        selectedView = networkViews.iterator().next();
    }
    EnrichmentMap map = emManager.getEnrichmentMap(selectedNetwork.getSUID());
    if (map == null)
        throw new IllegalArgumentException("Network is not an Enrichment Map.");
    loadGeneSets(map);
    PostAnalysisFilterType filter = PostAnalysisFilterType.valueOf(filterType.getSelectedValue());
    UniverseType universe = UniverseType.valueOf(hypergeomUniverseType.getSelectedValue());
    PostAnalysisParameters.Builder builder = new PostAnalysisParameters.Builder();
    builder.setAttributePrefix(map.getParams().getAttributePrefix());
    builder.setSignatureGMTFileName(gmtFile.getAbsolutePath());
    builder.setLoadedGMTGeneSets(signatureGenesets);
    builder.addSelectedGeneSetNames(selectedGenesetNames);
    builder.setUniverseType(universe);
    builder.setUserDefinedUniverseSize(userDefinedUniverseSize);
    builder.setRankTestParameters(new PostAnalysisFilterParameters(filter, cutoff));
    builder.setName(name);
    if (isBatch()) {
        // run in batch mode
        builder.setDataSetName(null);
    } else {
        if (map.getDataSet(dataSetName) == null) {
            throw new IllegalArgumentException("Data set name not valid: '" + dataSetName + "'");
        }
        builder.setDataSetName(dataSetName);
    }
    // Mann-Whitney requires ranks
    if (filter.isMannWhitney()) {
        processMannWhitneyArgs(map, builder);
    }
    TaskFactory taskFactory = taskFactoryFactory.create(selectedView, builder.build());
    TaskIterator taskIterator = new TaskIterator();
    taskIterator.append(taskFactory.createTaskIterator());
    Task updatePanelTask = new AbstractTask() {

        @Override
        public void run(TaskMonitor taskMonitor) {
            controlPanelMediatorProvider.get().updateDataSetList(selectedView);
            selectedView.updateView();
        }
    };
    taskIterator.append(updatePanelTask);
    insertTasksAfterCurrentTask(taskIterator);
}
Also used : Task(org.cytoscape.work.Task) AbstractTask(org.cytoscape.work.AbstractTask) UniverseType(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters.UniverseType) AbstractTask(org.cytoscape.work.AbstractTask) PostAnalysisFilterType(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterType) PostAnalysisFilterParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters) CyNetwork(org.cytoscape.model.CyNetwork) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) PostAnalysisParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) CreateDiseaseSignatureTaskFactory(org.baderlab.csplugins.enrichmentmap.task.postanalysis.CreateDiseaseSignatureTaskFactory) TaskFactory(org.cytoscape.work.TaskFactory) 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