Skip to content

Commit

Permalink
All three mann-whitney options should be disabled if there are no ranks.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekucera committed Nov 24, 2016
1 parent 3182b00 commit 34fdcf9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ private void filterSignatureGS(TaskMonitor taskMonitor) {
if(!selectedSignatureSetNames.contains(signatureGeneset)) {
boolean matchfound = false;

if(paParams.getFilterParameters().getType() != FilterType.NO_FILTER) {
FilterType type = paParams.getFilterParameters().getType();
if(type != FilterType.NO_FILTER) {
if(filterMetric == null) {
filterMetric = createFilterMetric(paParams);
filterMetric = createFilterMetric(type);
filterMetric.init();
}

Expand Down Expand Up @@ -109,8 +110,7 @@ private void filterSignatureGS(TaskMonitor taskMonitor) {



private FilterMetric createFilterMetric(PostAnalysisParameters paParams) {
FilterType type = paParams.getFilterParameters().getType();
private FilterMetric createFilterMetric(FilterType type) {
switch(type) {
case NUMBER:
return new NumberFilterMetric();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,24 @@
* Allows items in a JCombo box to look disabled.
*/
@SuppressWarnings("serial")
public class EnablementComboBoxRenderer extends BasicComboBoxRenderer {
public class EnablementComboBoxRenderer<T> extends BasicComboBoxRenderer {

private final Set<Integer> disabledIndicies = new HashSet<>();
private final Set<T> disabledItems = new HashSet<>();

public void disableIndex(int index) {
disabledIndicies.add(index);
@SafeVarargs
public final void disableItems(T ... items) {
for(T item : items)
disabledItems.add(item);
}

public void enableIndex(int index) {
disabledIndicies.remove(index);
@SafeVarargs
public final void enableItems(T ... items) {
for(T item : items)
disabledItems.remove(item);
}

public void enableAll() {
disabledItems.clear();
}

@Override
Expand All @@ -30,7 +38,7 @@ public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JLis

Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

if(disabledIndicies.contains(index)) {
if(disabledItems.contains(value)) {
component.setForeground(Color.LIGHT_GRAY);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class PostAnalysisWeightPanel extends JPanel {

private DefaultComboBoxModel<String> rankingModel;
private DefaultComboBoxModel<String> datasetModel;
private EnablementComboBoxRenderer rankingEnablementRenderer;
private EnablementComboBoxRenderer<FilterType> rankingEnablementRenderer;

private JPanel cardPanel;

Expand All @@ -88,13 +88,13 @@ private void init() {
JPanel warnCard = createWarningPanel();

cardPanel = new JPanel(new CardLayout());
cardPanel.add(mannWhittCard, FilterType.MANN_WHIT_TWO_SIDED.toString());
cardPanel.add(mannWhittCard, FilterType.MANN_WHIT_GREATER.toString());
cardPanel.add(mannWhittCard, FilterType.MANN_WHIT_LESS.toString());
cardPanel.add(hypergeomCard, FilterType.HYPERGEOM.toString());
cardPanel.add(createEmptyPanel(), FilterType.PERCENT.toString());
cardPanel.add(createEmptyPanel(), FilterType.NUMBER.toString());
cardPanel.add(createEmptyPanel(), FilterType.SPECIFIC.toString());
cardPanel.add(mannWhittCard, FilterType.MANN_WHIT_TWO_SIDED.name());
cardPanel.add(mannWhittCard, FilterType.MANN_WHIT_GREATER.name());
cardPanel.add(mannWhittCard, FilterType.MANN_WHIT_LESS.name());
cardPanel.add(hypergeomCard, FilterType.HYPERGEOM.name());
cardPanel.add(createEmptyPanel(), FilterType.PERCENT.name());
cardPanel.add(createEmptyPanel(), FilterType.NUMBER.name());
cardPanel.add(createEmptyPanel(), FilterType.SPECIFIC.name());
cardPanel.add(warnCard, "warn");

GroupLayout layout = new GroupLayout(this);
Expand All @@ -117,7 +117,7 @@ private void init() {
}
}

private JPanel createEmptyPanel() {
private static JPanel createEmptyPanel() {
JPanel panel = new JPanel();

if (LookAndFeelUtil.isAquaLAF())
Expand Down Expand Up @@ -173,7 +173,7 @@ private JPanel createRankTestSelectPanel() {
rankTestTextField.setHorizontalAlignment(JTextField.RIGHT);
rankTestTextField.addPropertyChangeListener("value", new FormattedTextFieldAction());

rankingEnablementRenderer = new EnablementComboBoxRenderer();
rankingEnablementRenderer = new EnablementComboBoxRenderer<>();
rankTestCombo = new JComboBox<>();
rankTestCombo.setRenderer(rankingEnablementRenderer);

Expand All @@ -197,7 +197,7 @@ public void actionPerformed(ActionEvent e) {
if (rankTest.isMannWhitney() && map.getAllRanks().isEmpty())
cardLayout.show(cardPanel, "warn");
else
cardLayout.show(cardPanel, rankTest.toString());
cardLayout.show(cardPanel, rankTest.name());
}
});

Expand Down Expand Up @@ -460,9 +460,12 @@ void initialize(EnrichmentMap currentMap, PostAnalysisParameters paParams) {
double value = filterParams.getValue(filterParams.getType());
rankTestTextField.setValue(value);

rankingEnablementRenderer.enableIndex(0);
rankingEnablementRenderer.enableAll();
if(rankingArray.length == 0) {
rankingEnablementRenderer.disableIndex(0);
rankingEnablementRenderer.disableItems(
FilterType.MANN_WHIT_TWO_SIDED,
FilterType.MANN_WHIT_LESS,
FilterType.MANN_WHIT_GREATER);
}
}

Expand Down

0 comments on commit 34fdcf9

Please sign in to comment.