17
17
import java .util .Arrays ;
18
18
import java .util .Map ;
19
19
20
+ import javax .swing .Box ;
20
21
import javax .swing .BoxLayout ;
21
22
import javax .swing .ButtonGroup ;
22
23
import javax .swing .DefaultComboBoxModel ;
39
40
@ SuppressWarnings ("serial" )
40
41
public class PostAnalysisWeightPanel extends CollapsiblePanel {
41
42
43
+ private static final String LABEL_TEST = "Test:" ;
44
+ private static final String LABEL_DATASET = "Data Set:" ;
45
+ private static final String LABEL_RANKS = "Ranks:" ;
46
+
42
47
private final CySwingApplication application ;
43
48
44
49
private PostAnalysisParameters paParams ;
@@ -67,7 +72,7 @@ public class PostAnalysisWeightPanel extends CollapsiblePanel {
67
72
private JPanel cardPanel ;
68
73
69
74
public PostAnalysisWeightPanel (CySwingApplication application ) {
70
- super ("Edge Weight Calculation Parameters" );
75
+ super ("Edge Weight Parameters" );
71
76
this .application = application ;
72
77
createPanel ();
73
78
}
@@ -124,6 +129,10 @@ private JPanel createRankTestSelectPanel() {
124
129
JPanel panel = new JPanel ();
125
130
panel .setLayout (new BoxLayout (panel , BoxLayout .Y_AXIS ));
126
131
132
+ JPanel cutoffLabel = new JPanel ();
133
+ cutoffLabel .add (new JLabel ("Select Cutoff:" ));
134
+ panel .add (cutoffLabel );
135
+
127
136
DecimalFormat decFormat = new DecimalFormat ();
128
137
decFormat .setParseIntegerOnly (false );
129
138
rankTestTextField = new JFormattedTextField (decFormat );
@@ -154,19 +163,24 @@ public void actionPerformed(ActionEvent e) {
154
163
}
155
164
});
156
165
157
- panel .add (rankTestCombo );
166
+
167
+ panel .add (create3CellGridPanel (LABEL_TEST , rankTestCombo , rankTestTextField ));
158
168
159
- JPanel cutoffLabel = new JPanel ();
160
- cutoffLabel .add (new JLabel ("Select Cutoff:" ));
161
- panel .add (cutoffLabel );
169
+ datasetCombo = new JComboBox <>();
170
+ // Dataset model is already initialized
171
+ datasetModel = new DefaultComboBoxModel <>();
172
+ datasetCombo .setModel (datasetModel );
173
+ datasetCombo .addActionListener (new ActionListener () {
174
+ public void actionPerformed (ActionEvent e ) {
175
+ String dataset = (String )datasetCombo .getSelectedItem ();
176
+ if (dataset == null )
177
+ return ;
178
+ paParams .setSignature_dataSet (dataset );
179
+ updateUniverseSize (dataset );
180
+ }
181
+ });
162
182
163
- JPanel cutoffPanel = new JPanel ();
164
- cutoffPanel .setLayout (new BoxLayout (cutoffPanel , BoxLayout .X_AXIS ));
165
-
166
- cutoffPanel .add (rankTestCombo );
167
- cutoffPanel .add (rankTestTextField );
168
-
169
- panel .add (cutoffPanel );
183
+ panel .add (create3CellGridPanel (LABEL_DATASET , datasetCombo , null ));
170
184
171
185
return panel ;
172
186
}
@@ -249,22 +263,6 @@ private JPanel createHypergeomPanel() {
249
263
250
264
251
265
private JPanel createMannWhittPanel () {
252
- JPanel panel = new JPanel (new GridBagLayout ());
253
-
254
- datasetCombo = new JComboBox <>();
255
- // Dataset model is already initialized
256
- datasetModel = new DefaultComboBoxModel <>();
257
- datasetCombo .setModel (datasetModel );
258
- datasetCombo .addActionListener (new ActionListener () {
259
- public void actionPerformed ( ActionEvent e ) {
260
- String dataset = (String )datasetCombo .getSelectedItem ();
261
- if (dataset == null )
262
- return ;
263
- paParams .setSignature_dataSet (dataset );
264
- updateUniverseSize ();
265
- }
266
- });
267
-
268
266
rankingModel = new DefaultComboBoxModel <>();
269
267
rankingCombo = new JComboBox <>();
270
268
rankingCombo .setModel (rankingModel );
@@ -274,23 +272,8 @@ public void actionPerformed( ActionEvent e ) {
274
272
}
275
273
});
276
274
277
-
278
- GridBagConstraints c = new GridBagConstraints ();
279
- c .insets = new Insets (0 ,0 ,0 ,0 );
280
- c .fill = GridBagConstraints .HORIZONTAL ;
281
- c .anchor = GridBagConstraints .WEST ;
282
- c .gridx = 0 ;
283
- c .gridy = 0 ;
284
- panel .add (datasetCombo , c );
285
-
286
- c .gridy = 1 ;
287
- panel .add (rankingCombo , c );
288
-
289
- c .gridy = 2 ;
290
- c .weighty = 1.0 ;
291
- c .weightx = 1.0 ;
292
- panel .add (new JLabel ("" ), c );
293
-
275
+ JPanel panel = new JPanel (new BorderLayout ());
276
+ panel .add (create3CellGridPanel (LABEL_RANKS , rankingCombo , null ), BorderLayout .NORTH );
294
277
return panel ;
295
278
}
296
279
@@ -342,6 +325,49 @@ else if (source == universeSelectionTextField) {
342
325
}
343
326
}
344
327
328
+ /*
329
+ * This is a hackey way of getting the three comboboxes to line up properly without putting them in the
330
+ * same grid panel. I didn't want to put them in the same panel because I would have had to rewrite
331
+ * a big chunk of this file.
332
+ */
333
+ private static JPanel create3CellGridPanel (String label , JComboBox <?> combo , JFormattedTextField textField ) {
334
+ int labelWidth = (int ) new JLabel (LABEL_DATASET ).getPreferredSize ().getWidth (); // use the widest one
335
+
336
+ JPanel panel = new JPanel (new GridBagLayout ());
337
+
338
+ GridBagConstraints c = new GridBagConstraints ();
339
+ c .insets = new Insets (0 ,0 ,0 ,0 );
340
+ c .fill = GridBagConstraints .HORIZONTAL ;
341
+ c .anchor = GridBagConstraints .WEST ;
342
+
343
+ c .gridy = 0 ;
344
+
345
+ c .gridx = 0 ;
346
+ panel .add (Box .createHorizontalStrut (labelWidth ), c );
347
+ c .gridx = 1 ;
348
+ panel .add (Box .createHorizontalStrut (1 ), c );
349
+ c .gridx = 2 ;
350
+ c .weightx = 1.0 ;
351
+ panel .add (Box .createHorizontalStrut (1 ), c );
352
+
353
+ c .weightx = 0.0 ;
354
+ c .gridy = 1 ;
355
+
356
+ c .gridx = 0 ;
357
+ panel .add (new JLabel (label ), c );
358
+ c .gridx = 1 ;
359
+ if (textField == null )
360
+ c .gridwidth = 2 ;
361
+ panel .add (combo , c );
362
+ if (textField == null )
363
+ return panel ;
364
+ c .gridx = 2 ;
365
+ panel .add (textField ,c );
366
+
367
+ return panel ;
368
+ }
369
+
370
+
345
371
346
372
void resetPanel () {
347
373
gmtRadioButton .setSelected (true );
@@ -361,6 +387,10 @@ void initialize(EnrichmentMap currentMap, PostAnalysisParameters paParams) {
361
387
for (String dataset : datasetArray ) {
362
388
datasetModel .addElement (dataset );
363
389
}
390
+ datasetCombo .setEnabled (datasetModel .getSize () > 1 );
391
+ if (datasetModel .getSize () > 0 ) {
392
+ datasetCombo .setSelectedIndex (0 );
393
+ }
364
394
365
395
Map <String ,Ranking > rankingMap = map .getAllRanks ();
366
396
String [] rankingArray = rankingMap .keySet ().toArray (new String [rankingMap .size ()]);
@@ -369,8 +399,10 @@ void initialize(EnrichmentMap currentMap, PostAnalysisParameters paParams) {
369
399
for (String ranking : rankingArray ) {
370
400
rankingModel .addElement (ranking );
371
401
}
372
-
373
- updateUniverseSize ();
402
+ rankingCombo .setEnabled (rankingModel .getSize () > 1 );
403
+ if (rankingModel .getSize () > 0 ) {
404
+ rankingCombo .setSelectedIndex (0 );
405
+ }
374
406
375
407
FilterParameters filterParams = paParams .getRankTestParameters ();
376
408
if (filterParams .getType () == FilterType .NO_FILTER ) {
@@ -385,13 +417,13 @@ void initialize(EnrichmentMap currentMap, PostAnalysisParameters paParams) {
385
417
rankTestTextField .setValue (value );
386
418
387
419
rankingEnablementRenderer .enableIndex (0 );
388
- if (rankingArray .length == 0 )
420
+ if (rankingArray .length == 0 ) {
389
421
rankingEnablementRenderer .disableIndex (0 );
422
+ }
390
423
}
391
424
392
425
393
- private void updateUniverseSize () {
394
- String signature_dataSet = paParams .getSignature_dataSet ();
426
+ private void updateUniverseSize (String signature_dataSet ) {
395
427
GeneExpressionMatrix expressionSets = map .getDataset (signature_dataSet ).getExpressionSets ();
396
428
397
429
universeGmt = map .getNumberOfGenes ();
0 commit comments