Search in sources :

Example 1 with CyCustomGraphics2

use of org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2 in project EnrichmentMapApp by BaderLab.

the class LegendPanel method updateNodeChartPanel.

private void updateNodeChartPanel(Collection<EMDataSet> dataSets, EnrichmentMap map) {
    JPanel p = getNodeChartPanel();
    chartLegendPanel.removeAll();
    CyNetworkView netView = options.getNetworkView();
    VisualStyle style = netView != null ? visualMappingManager.getVisualStyle(netView) : null;
    NetworkViewRenderer renderer = applicationManager.getCurrentNetworkViewRenderer();
    if (renderer == null)
        renderer = applicationManager.getDefaultNetworkViewRenderer();
    VisualLexicon lexicon = renderer.getRenderingEngineFactory(NetworkViewRenderer.DEFAULT_CONTEXT).getVisualLexicon();
    VisualProperty<?> vp = lexicon.lookup(CyNode.class, "NODE_CUSTOMGRAPHICS_1");
    Object cg = vp != null ? style.getDefaultValue(vp) : null;
    ChartType chartType = options.getChartOptions() != null ? options.getChartOptions().getType() : null;
    if (chartType != null && cg instanceof CyCustomGraphics2 && dataSets != null && dataSets.size() > 1) {
        ChartPanel chart = createChartPanel(dataSets);
        if (chart != null) {
            JLabel titleLabel = new JLabel("" + options.getChartOptions().getData());
            titleLabel.setHorizontalAlignment(JLabel.CENTER);
            makeSmall(titleLabel);
            chartLegendPanel.add(chart, BorderLayout.CENTER);
            chartLegendPanel.add(titleLabel, BorderLayout.SOUTH);
        }
        p.setVisible(true);
    } else {
        p.setVisible(false);
    }
    p.revalidate();
}
Also used : JPanel(javax.swing.JPanel) CyCustomGraphics2(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2) BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) VisualLexicon(org.cytoscape.view.model.VisualLexicon) ChartPanel(org.jfree.chart.ChartPanel) JLabel(javax.swing.JLabel) ChartType(org.baderlab.csplugins.enrichmentmap.style.ChartType) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView) NetworkViewRenderer(org.cytoscape.application.NetworkViewRenderer)

Example 2 with CyCustomGraphics2

use of org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2 in project cytoscape-impl by cytoscape.

the class CyCustomGraphicsValueEditor method refreshUI.

private void refreshUI() {
    getGraphicsPnl().updateList();
    Component newSelected = getGraphicsPnl();
    final Iterator<Entry<String, CustomGraphics2Panel>> iter = cg2PnlMap.entrySet().iterator();
    while (iter.hasNext()) {
        final CustomGraphics2Panel cg2Pnl = iter.next().getValue();
        cg2Pnl.update(oldCustomGraphics instanceof CyCustomGraphics2 ? (CyCustomGraphics2) oldCustomGraphics : null);
        if (cg2Pnl.getEditorCount() == 0) {
            iter.remove();
            if (getGroupTpn().indexOfComponent(cg2Pnl) >= 0)
                getGroupTpn().remove(cg2Pnl);
            continue;
        }
        if (oldCustomGraphics instanceof CyCustomGraphics2 && cg2Pnl.canEdit((CyCustomGraphics2) oldCustomGraphics))
            newSelected = cg2Pnl;
    }
    getGroupTpn().setSelectedComponent(newSelected);
}
Also used : CyCustomGraphics2(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2) Entry(java.util.Map.Entry) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Aggregations

CyCustomGraphics2 (org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2)2 Component (java.awt.Component)1 Entry (java.util.Map.Entry)1 JComponent (javax.swing.JComponent)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 ChartType (org.baderlab.csplugins.enrichmentmap.style.ChartType)1 NetworkViewRenderer (org.cytoscape.application.NetworkViewRenderer)1 CyNetworkView (org.cytoscape.view.model.CyNetworkView)1 VisualLexicon (org.cytoscape.view.model.VisualLexicon)1 BasicVisualLexicon (org.cytoscape.view.presentation.property.BasicVisualLexicon)1 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)1 ChartPanel (org.jfree.chart.ChartPanel)1