Skip to content

Commit bd1953b

Browse files
committed
Correct order for 'Color by Data Set' chart.
Refs #441.
1 parent 35d1894 commit bd1953b

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/style/EMStyleOptions.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.baderlab.csplugins.enrichmentmap.style;
22

3-
import java.util.Collection;
3+
import java.util.List;
44
import java.util.Objects;
55

66
import org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet;
@@ -14,12 +14,12 @@ public class EMStyleOptions {
1414
private final ChartOptions chartOptions;
1515
private boolean postAnalysis;
1616
private final boolean publicationReady;
17-
private final Collection<? extends AbstractDataSet> dataSets;
17+
private final List<? extends AbstractDataSet> dataSets;
1818

1919
/**
2020
* It is assumed that all the given DataSets come from the same EnrichmentMap.
2121
*/
22-
public EMStyleOptions(CyNetworkView networkView, EnrichmentMap map, Collection<? extends AbstractDataSet> dataSets,
22+
public EMStyleOptions(CyNetworkView networkView, EnrichmentMap map, List<? extends AbstractDataSet> dataSets,
2323
ChartOptions chartOptions, boolean postAnalysis, boolean publicationReady) {
2424
this.networkView = Objects.requireNonNull(networkView);
2525
this.map = Objects.requireNonNull(map);
@@ -37,7 +37,7 @@ public CyNetworkView getNetworkView() {
3737
return networkView;
3838
}
3939

40-
public Collection<? extends AbstractDataSet> getDataSets() {
40+
public List<? extends AbstractDataSet> getDataSets() {
4141
return dataSets;
4242
}
4343

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/control/ControlPanelMediator.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.awt.event.ItemEvent;
1616
import java.awt.event.MouseAdapter;
1717
import java.awt.event.MouseEvent;
18+
import java.util.ArrayList;
1819
import java.util.Collection;
1920
import java.util.Collections;
2021
import java.util.HashMap;
@@ -795,7 +796,16 @@ private EMStyleOptions createStyleOptions(EnrichmentMap map, EMViewControlPanel
795796
if (map == null || viewPanel == null)
796797
return null;
797798

798-
Set<AbstractDataSet> dataSets = viewPanel.getDataSetSelector().getCheckedItems();
799+
Set<AbstractDataSet> checkedDataSets = viewPanel.getDataSetSelector().getCheckedItems();
800+
801+
// Need to maintain the correct order
802+
List<AbstractDataSet> dataSetList = new ArrayList<>();
803+
for(AbstractDataSet ds : map.getDataSetList()) { // Need to maintain the same order that's in the EnrichmentMap object
804+
if(checkedDataSets.contains(ds)) {
805+
dataSetList.add(ds);
806+
}
807+
}
808+
799809
boolean publicationReady = viewPanel.getPublicationReadyCheck().isSelected();
800810
boolean postAnalysis = map.hasSignatureDataSets();
801811

@@ -814,7 +824,7 @@ private EMStyleOptions createStyleOptions(EnrichmentMap map, EMViewControlPanel
814824
boolean showLabels = viewPanel.getShowChartLabelsCheck().isSelected();
815825
ChartOptions chartOptions = new ChartOptions(data, type, colorScheme, showLabels);
816826

817-
return new EMStyleOptions(viewPanel.getNetworkView(), map, dataSets, chartOptions, postAnalysis, publicationReady);
827+
return new EMStyleOptions(viewPanel.getNetworkView(), map, dataSetList, chartOptions, postAnalysis, publicationReady);
818828
}
819829

820830
private AssociatedStyleOptions createAssociatedStyleOptions(EnrichmentMap map, AssociatedViewControlPanel viewPanel) {

0 commit comments

Comments
 (0)