use of org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet 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();
}
}
});
}
use of org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet in project EnrichmentMapApp by BaderLab.
the class EMStyleBuilder method setNodeColors.
private void setNodeColors(VisualStyle vs, EMStyleOptions options) {
String prefix = options.getAttributePrefix();
List<AbstractDataSet> dataSets = options.getDataSets().stream().filter(// Ignore Signature Data Sets in charts
ds -> ds instanceof EMDataSet).collect(Collectors.toList());
if (dataSets.size() == 1) {
// Only 1 Data Set? Use node colour instead of charts...
EMDataSet ds = (EMDataSet) dataSets.iterator().next();
// Create boundary conditions
BoundaryRangeValues<Paint> bv3a = new BoundaryRangeValues<>(Colors.MAX_PHENOTYPE_2, Colors.MAX_PHENOTYPE_2, Colors.MAX_PHENOTYPE_2);
BoundaryRangeValues<Paint> bv3b = new BoundaryRangeValues<>(Colors.LIGHTER_PHENOTYPE_2, Colors.LIGHTER_PHENOTYPE_2, Colors.MAX_PHENOTYPE_2);
BoundaryRangeValues<Paint> bv3c = new BoundaryRangeValues<>(Colors.LIGHTEST_PHENOTYPE_2, Colors.LIGHTEST_PHENOTYPE_2, Colors.LIGHTER_PHENOTYPE_2);
BoundaryRangeValues<Paint> bv3d = new BoundaryRangeValues<>(Colors.LIGHTEST_PHENOTYPE_2, Colors.OVER_COLOR, Colors.OVER_COLOR);
BoundaryRangeValues<Paint> bv3e = new BoundaryRangeValues<>(Colors.OVER_COLOR, Colors.OVER_COLOR, Colors.OVER_COLOR);
BoundaryRangeValues<Paint> bv3f = new BoundaryRangeValues<>(Colors.OVER_COLOR, Colors.OVER_COLOR, Colors.LIGHTEST_PHENOTYPE_1);
BoundaryRangeValues<Paint> bv3g = new BoundaryRangeValues<>(Colors.LIGHTEST_PHENOTYPE_1, Colors.LIGHTEST_PHENOTYPE_1, Colors.LIGHTER_PHENOTYPE_1);
BoundaryRangeValues<Paint> bv3h = new BoundaryRangeValues<>(Colors.LIGHTER_PHENOTYPE_1, Colors.LIGHTER_PHENOTYPE_1, Colors.MAX_PHENOTYPE_1);
BoundaryRangeValues<Paint> bv3i = new BoundaryRangeValues<>(Colors.MAX_PHENOTYPE_1, Colors.MAX_PHENOTYPE_1, Colors.MAX_PHENOTYPE_1);
// Continuous Mapping - set node colour based on the sign of the ES score of the dataset
ContinuousMapping<Double, Paint> cm = (ContinuousMapping<Double, Paint>) cmFactory.createVisualMappingFunction(Columns.NODE_COLOURING.with(prefix, ds.getName()), Double.class, BasicVisualLexicon.NODE_FILL_COLOR);
// Silence events fired by this mapping to prevent unnecessary style and view updates
eventHelper.silenceEventSource(cm);
try {
// Set the attribute point values associated with the boundary values
cm.addPoint(-1.0, bv3a);
cm.addPoint(-0.995, bv3b);
cm.addPoint(-0.95, bv3c);
cm.addPoint(-0.9, bv3d);
cm.addPoint(0.0, bv3e);
cm.addPoint(0.9, bv3f);
cm.addPoint(0.95, bv3g);
cm.addPoint(0.995, bv3h);
cm.addPoint(1.0, bv3i);
} finally {
eventHelper.unsilenceEventSource(cm);
}
vs.addVisualMappingFunction(cm);
// Then we need to use bypass to colour the hub nodes (signature genesets)
List<EMSignatureDataSet> signatureDataSets = options.getEnrichmentMap().getSignatureSetList();
CyNetworkView netView = options.getNetworkView();
CyNetwork net = netView.getModel();
for (EMSignatureDataSet sds : signatureDataSets) {
for (Long suid : sds.getNodeSuids()) {
CyNode node = net.getNode(suid);
if (node != null) {
View<CyNode> nv = netView.getNodeView(node);
if (nv != null)
nv.setLockedValue(NODE_FILL_COLOR, Colors.SIG_NODE_COLOR);
}
}
}
} else {
// 2 or more Data Sets? Use simple node colours and charts...
// Add mapping function for node fill color
DiscreteMapping<String, Paint> dm = (DiscreteMapping<String, Paint>) dmFactory.createVisualMappingFunction(Columns.NODE_GS_TYPE.with(prefix, null), String.class, NODE_FILL_COLOR);
// Silence events fired by this mapping to prevent unnecessary style and view updates
eventHelper.silenceEventSource(dm);
try {
dm.putMapValue(Columns.NODE_GS_TYPE_ENRICHMENT, Colors.DEF_NODE_COLOR);
dm.putMapValue(Columns.NODE_GS_TYPE_SIGNATURE, Colors.SIG_NODE_COLOR);
} finally {
eventHelper.unsilenceEventSource(dm);
}
vs.addVisualMappingFunction(dm);
}
}
Aggregations