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);
}
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;
}
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();
}
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;
}
Aggregations