1
1
package org .baderlab .csplugins .enrichmentmap .commands ;
2
2
3
+ import static org .baderlab .csplugins .enrichmentmap .style .ChartData .DATA_SET ;
4
+ import static org .baderlab .csplugins .enrichmentmap .style .ChartData .EXPRESSION_DATA ;
5
+ import static org .baderlab .csplugins .enrichmentmap .style .ChartData .FDR_VALUE ;
6
+ import static org .baderlab .csplugins .enrichmentmap .style .ChartData .NES_VALUE ;
7
+ import static org .baderlab .csplugins .enrichmentmap .style .ChartData .NONE ;
8
+ import static org .baderlab .csplugins .enrichmentmap .style .ChartData .PHENOTYPES ;
9
+ import static org .baderlab .csplugins .enrichmentmap .style .ChartData .P_VALUE ;
10
+ import static org .baderlab .csplugins .enrichmentmap .style .ChartType .DATASET_PIE ;
11
+ import static org .baderlab .csplugins .enrichmentmap .style .ChartType .HEAT_MAP ;
12
+ import static org .baderlab .csplugins .enrichmentmap .style .ChartType .HEAT_STRIPS ;
13
+ import static org .baderlab .csplugins .enrichmentmap .style .ChartType .RADIAL_HEAT_MAP ;
14
+
3
15
import java .util .ArrayList ;
4
16
import java .util .List ;
5
17
import java .util .Map ;
6
- import java .util .function .Predicate ;
7
18
8
19
import org .baderlab .csplugins .enrichmentmap .commands .tunables .NetworkTunable ;
9
20
import org .baderlab .csplugins .enrichmentmap .model .EnrichmentMap ;
@@ -40,13 +51,13 @@ public class ChartCommandTask extends AbstractTask {
40
51
public ListSingleSelection <String > colors ;
41
52
42
53
@ Tunable
43
- public boolean showLabels ;
54
+ public boolean showChartLabels = true ;
44
55
45
56
46
57
public ChartCommandTask () {
47
- data = lssFromEnum (ChartData . values (), x -> true );
48
- type = lssFromEnum (ChartType . values (), ct -> ct != ChartType . DATASET_PIE );
49
- colors = lssFromEnum (ColorScheme .values (), x -> true );
58
+ data = lssFromEnum (NES_VALUE , P_VALUE , FDR_VALUE , PHENOTYPES , DATA_SET , EXPRESSION_DATA , NONE ); // want NES to be the default
59
+ type = lssFromEnum (RADIAL_HEAT_MAP , HEAT_STRIPS , HEAT_MAP ); // don't include DATASET_PIE
60
+ colors = lssFromEnum (ColorScheme .values ());
50
61
}
51
62
52
63
@ Override
@@ -57,13 +68,9 @@ public void run(TaskMonitor taskMonitor) {
57
68
if (networkView == null || map == null )
58
69
throw new IllegalArgumentException ("network is not an EnrichmentMap network" );
59
70
60
- Map <Long ,ViewParams > viewParamsMap = controlPanelMediator .getAllViewParams ();
61
- ViewParams params = viewParamsMap .get (networkView .getSUID ());
62
- ChartOptions chartOptions = params .getChartOptions ();
63
-
64
- ChartData chartData = "null" .equals (data .getSelectedValue ()) ? chartOptions .getData () : ChartData .valueOf (data .getSelectedValue ());
65
- ChartType chartType = "null" .equals (type .getSelectedValue ()) ? chartOptions .getType () : ChartType .valueOf (type .getSelectedValue ());
66
- ColorScheme colorScheme = "null" .equals (colors .getSelectedValue ()) ? chartOptions .getColorScheme () : ColorScheme .valueOf (colors .getSelectedValue ());
71
+ ChartData chartData = ChartData .valueOf (data .getSelectedValue ());
72
+ ChartType chartType = chartData == DATA_SET ? DATASET_PIE : ChartType .valueOf (type .getSelectedValue ());
73
+ ColorScheme colorScheme = ColorScheme .valueOf (colors .getSelectedValue ());
67
74
68
75
// validate
69
76
if (chartData == ChartData .EXPRESSION_DATA && !networkTunable .isAssociatedEnrichmenMap ())
@@ -75,22 +82,19 @@ public void run(TaskMonitor taskMonitor) {
75
82
if (chartData == ChartData .FDR_VALUE && !map .getParams ().isFDR ())
76
83
throw new IllegalArgumentException ("data=FDR_VALUE cannot be used on this network" );
77
84
78
- if (chartData == ChartData .DATA_SET )
79
- chartType = ChartType .DATASET_PIE ;
85
+ ChartOptions options = new ChartOptions (chartData , chartType , colorScheme , showChartLabels );
80
86
81
- ChartOptions options = new ChartOptions (chartData , chartType , colorScheme , showLabels );
87
+ Map <Long ,ViewParams > viewParamsMap = controlPanelMediator .getAllViewParams ();
88
+ ViewParams params = viewParamsMap .get (networkView .getSUID ());
82
89
params .setChartOptions (options );
83
90
controlPanelMediator .reset (params );
84
91
}
85
92
86
93
87
- private static ListSingleSelection <String > lssFromEnum (Enum <?>[] values , Predicate < Enum <?>> valueTester ) {
94
+ private static ListSingleSelection <String > lssFromEnum (Enum <?> ... values ) {
88
95
List <String > names = new ArrayList <>(values .length );
89
- names .add ("null" ); // important, need to know if the user did not set the value
90
96
for (Enum <?> value : values ) {
91
- if (valueTester .test (value )) {
92
- names .add (value .name ());
93
- }
97
+ names .add (value .name ());
94
98
}
95
99
return new ListSingleSelection <>(names );
96
100
}
0 commit comments