Search in sources :

Example 1 with ChartType

use of org.baderlab.csplugins.enrichmentmap.style.ChartType in project EnrichmentMapApp by BaderLab.

the class ControlPanelMediator method createStyleOptions.

private EMStyleOptions createStyleOptions(EnrichmentMap map, EMViewControlPanel viewPanel) {
    if (map == null || viewPanel == null)
        return null;
    Set<AbstractDataSet> dataSets = viewPanel.getDataSetSelector().getCheckedItems();
    boolean publicationReady = viewPanel.getPublicationReadyCheck().isSelected();
    boolean postAnalysis = map.hasSignatureDataSets();
    ChartData data = (ChartData) viewPanel.getChartDataCombo().getSelectedItem();
    ChartType type = getChartType(viewPanel);
    ColorScheme colorScheme = (ColorScheme) viewPanel.getChartColorsCombo().getSelectedItem();
    boolean showLabels = viewPanel.getShowChartLabelsCheck().isSelected();
    ChartOptions chartOptions = new ChartOptions(data, type, colorScheme, showLabels);
    return new EMStyleOptions(viewPanel.getNetworkView(), map, dataSets::contains, chartOptions, postAnalysis, publicationReady);
}
Also used : EMStyleOptions(org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions) ChartData(org.baderlab.csplugins.enrichmentmap.style.ChartData) AbstractDataSet(org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet) ColorScheme(org.baderlab.csplugins.enrichmentmap.style.ColorScheme) ChartType(org.baderlab.csplugins.enrichmentmap.style.ChartType) ChartOptions(org.baderlab.csplugins.enrichmentmap.style.ChartOptions)

Example 2 with ChartType

use of org.baderlab.csplugins.enrichmentmap.style.ChartType in project EnrichmentMapApp by BaderLab.

the class ControlPanelMediator method createChart.

public CyCustomGraphics2<?> createChart(EMStyleOptions options) {
    CyCustomGraphics2<?> chart = null;
    ChartOptions chartOptions = options.getChartOptions();
    ChartData data = chartOptions != null ? chartOptions.getData() : null;
    if (data != null && data != ChartData.NONE) {
        // Ignore Signature Data Sets in charts
        Set<EMDataSet> dataSets = filterDataSets(options.getDataSets());
        if (dataSets.size() > 1) {
            ColumnDescriptor<Double> columnDescriptor = data.getColumnDescriptor();
            List<CyColumnIdentifier> columns = ChartUtil.getSortedColumnIdentifiers(options.getAttributePrefix(), dataSets, columnDescriptor, columnIdFactory);
            ChartType type = chartOptions.getType();
            Map<String, Object> props = new HashMap<>(type.getProperties());
            props.put("cy_dataColumns", columns);
            List<Double> range = ChartUtil.calculateGlobalRange(options.getNetworkView().getModel(), columns);
            props.put("cy_range", range);
            props.put("cy_autoRange", false);
            props.put("cy_globalRange", true);
            props.put("cy_showItemLabels", chartOptions.isShowLabels());
            props.put("cy_colors", chartOptions.getColorScheme().getColors());
            try {
                CyCustomGraphics2Factory<?> factory = chartFactoryManager.getChartFactory(type.getId());
                if (factory != null)
                    chart = factory.getInstance(props);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    return chart;
}
Also used : ChartData(org.baderlab.csplugins.enrichmentmap.style.ChartData) HashMap(java.util.HashMap) ChartType(org.baderlab.csplugins.enrichmentmap.style.ChartType) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) ChartOptions(org.baderlab.csplugins.enrichmentmap.style.ChartOptions)

Example 3 with ChartType

use of org.baderlab.csplugins.enrichmentmap.style.ChartType 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 4 with ChartType

use of org.baderlab.csplugins.enrichmentmap.style.ChartType in project EnrichmentMapApp by BaderLab.

the class LegendPanel method createChartPanel.

private ChartPanel createChartPanel(Collection<EMDataSet> dataSets) {
    JFreeChart chart = null;
    List<EMDataSet> sortedDataSets = ChartUtil.sortDataSets(dataSets);
    ChartType chartType = options.getChartOptions() != null ? options.getChartOptions().getType() : null;
    switch(chartType) {
        case RADIAL_HEAT_MAP:
            chart = ChartUtil.createRadialHeatMapLegend(sortedDataSets, options.getChartOptions());
            break;
        case HEAT_MAP:
            chart = ChartUtil.createHeatMapLegend(sortedDataSets, options.getChartOptions());
            break;
        case HEAT_STRIPS:
            chart = ChartUtil.createHeatStripsLegend(sortedDataSets, options.getChartOptions());
            break;
        default:
            break;
    }
    ChartPanel chartPanel = chart != null ? new ChartPanel(chart) : null;
    if (chartPanel != null) {
        chartPanel.setPopupMenu(null);
        chartPanel.setMouseZoomable(false);
    }
    return chartPanel;
}
Also used : ChartPanel(org.jfree.chart.ChartPanel) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) ChartType(org.baderlab.csplugins.enrichmentmap.style.ChartType) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

ChartType (org.baderlab.csplugins.enrichmentmap.style.ChartType)4 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)2 ChartData (org.baderlab.csplugins.enrichmentmap.style.ChartData)2 ChartOptions (org.baderlab.csplugins.enrichmentmap.style.ChartOptions)2 ChartPanel (org.jfree.chart.ChartPanel)2 HashMap (java.util.HashMap)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 AbstractDataSet (org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet)1 ColorScheme (org.baderlab.csplugins.enrichmentmap.style.ColorScheme)1 EMStyleOptions (org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions)1 NetworkViewRenderer (org.cytoscape.application.NetworkViewRenderer)1 CyNetworkView (org.cytoscape.view.model.CyNetworkView)1 VisualLexicon (org.cytoscape.view.model.VisualLexicon)1 CyCustomGraphics2 (org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2)1 BasicVisualLexicon (org.cytoscape.view.presentation.property.BasicVisualLexicon)1 CyColumnIdentifier (org.cytoscape.view.presentation.property.values.CyColumnIdentifier)1 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)1 JFreeChart (org.jfree.chart.JFreeChart)1