use of org.baderlab.csplugins.enrichmentmap.style.ChartData 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.ChartData 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.ChartData 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();
}
}
});
}
Aggregations