35
35
import javax .swing .JTextField ;
36
36
import javax .swing .LayoutStyle .ComponentPlacement ;
37
37
import javax .swing .SwingUtilities ;
38
+ import javax .swing .event .DocumentEvent ;
39
+ import javax .swing .event .DocumentListener ;
38
40
39
41
import org .baderlab .csplugins .enrichmentmap .AfterInjection ;
40
42
import org .baderlab .csplugins .enrichmentmap .model .EMDataSet ;
44
46
import org .baderlab .csplugins .enrichmentmap .model .UniverseType ;
45
47
import org .baderlab .csplugins .enrichmentmap .task .postanalysis .FilterMetric ;
46
48
import org .baderlab .csplugins .enrichmentmap .task .postanalysis .FilterMetricSet ;
49
+ import org .baderlab .csplugins .enrichmentmap .util .CoalesceTimer ;
47
50
import org .baderlab .csplugins .enrichmentmap .view .EnablementComboBoxRenderer ;
48
51
import org .baderlab .csplugins .enrichmentmap .view .util .GBCFactory ;
49
52
import org .baderlab .csplugins .enrichmentmap .view .util .SwingUtil ;
@@ -77,7 +80,7 @@ public class PAWeightPanel extends JPanel {
77
80
78
81
private JComboBox <String > datasetCombo ;
79
82
private JComboBox <PostAnalysisFilterType > rankTestCombo ;
80
- private JFormattedTextField rankTestTextField ;
83
+ private JTextField rankTestTextField ;
81
84
82
85
private JRadioButton gmtRadioButton ;
83
86
private JRadioButton intersectionRadioButton ;
@@ -100,6 +103,7 @@ public class PAWeightPanel extends JPanel {
100
103
101
104
private boolean rankTestUpdating = false ;
102
105
106
+ private CoalesceTimer debouncer = new CoalesceTimer (1000 , 1 );
103
107
104
108
public interface Factory {
105
109
PAWeightPanel create (EnrichmentMap map );
@@ -209,21 +213,12 @@ private void showWarning(String message) {
209
213
warnLabel .setVisible (message != null );
210
214
}
211
215
212
-
213
- @ SuppressWarnings ("unchecked" )
214
- private JPanel createRankTestSelectPanel () {
215
- JLabel testLabel = new JLabel (LABEL_TEST );
216
- JLabel cuttofLabel = new JLabel (LABEL_CUTOFF );
217
- JLabel dataSetLabel = new JLabel ("Data Set:" );
218
-
219
- DECIMAL_FORMAT .setParseIntegerOnly (false );
220
- rankTestTextField = new JFormattedTextField (DECIMAL_FORMAT );
221
- rankTestTextField .setColumns (6 );
222
- rankTestTextField .setHorizontalAlignment (JTextField .RIGHT );
223
- rankTestTextField .addPropertyChangeListener ("value" , e -> {
216
+ private void updateRankTestValue () {
217
+ debouncer .coalesce (() -> {
224
218
String text = rankTestTextField .getText ();
225
219
try {
226
220
double val = DECIMAL_FORMAT .parse (text ).doubleValue ();
221
+ System .out .println ("val: " + val );
227
222
PostAnalysisFilterType filterType = getFilterType ();
228
223
savedFilterValues .put (filterType , val );
229
224
showWarning (filterType .isValid (val ) ? null : filterType .getErrorMessage ());
@@ -234,6 +229,25 @@ private JPanel createRankTestSelectPanel() {
234
229
if (!rankTestUpdating )
235
230
firePropertyChange (PROPERTY_PARAMETERS , false , true );
236
231
});
232
+ }
233
+
234
+
235
+ private JPanel createRankTestSelectPanel () {
236
+ JLabel testLabel = new JLabel (LABEL_TEST );
237
+ JLabel cuttofLabel = new JLabel (LABEL_CUTOFF );
238
+ JLabel dataSetLabel = new JLabel ("Data Set:" );
239
+
240
+ DECIMAL_FORMAT .setParseIntegerOnly (false );
241
+ rankTestTextField = new JTextField ();
242
+ rankTestTextField .setColumns (15 );
243
+ rankTestTextField .setHorizontalAlignment (JTextField .RIGHT );
244
+
245
+ rankTestTextField .addActionListener (e -> { updateRankTestValue (); });
246
+ rankTestTextField .getDocument ().addDocumentListener (new DocumentListener () {
247
+ @ Override public void removeUpdate (DocumentEvent e ) { updateRankTestValue (); }
248
+ @ Override public void insertUpdate (DocumentEvent e ) { updateRankTestValue (); }
249
+ @ Override public void changedUpdate (DocumentEvent e ) { }
250
+ });
237
251
238
252
rankingEnablementRenderer = new EnablementComboBoxRenderer <>();
239
253
rankTestCombo = new JComboBox <>();
@@ -250,7 +264,7 @@ private JPanel createRankTestSelectPanel() {
250
264
rankTestCombo .addActionListener (e -> {
251
265
rankTestUpdating = true ;
252
266
PostAnalysisFilterType filterType = (PostAnalysisFilterType ) rankTestCombo .getSelectedItem ();
253
- rankTestTextField .setValue ( savedFilterValues .get (filterType ));
267
+ rankTestTextField .setText ( DECIMAL_FORMAT . format ( savedFilterValues .get (filterType ) ));
254
268
CardLayout cardLayout = (CardLayout ) cardPanel .getLayout ();
255
269
256
270
if (filterType .isMannWhitney () && map .getAllRanks ().isEmpty ())
@@ -422,7 +436,7 @@ private JPanel createHypergeomUniversePanel() {
422
436
universeSelectionTextField .addPropertyChangeListener ("value" , e -> {
423
437
Number val = (Number ) universeSelectionTextField .getValue ();
424
438
if (val == null || val .intValue () < 0 ) {
425
- universeSelectionTextField .setValue ( 1 );
439
+ universeSelectionTextField .setText ( "1" );
426
440
JOptionPane .showMessageDialog (SwingUtilities .getWindowAncestor (this ), "Universe value must be greater than zero" ,
427
441
"Parameter out of bounds" , JOptionPane .WARNING_MESSAGE );
428
442
}
@@ -547,7 +561,7 @@ private void initialize() {
547
561
548
562
PostAnalysisFilterType typeToUse = rankingArray .length == 0 ? PostAnalysisFilterType .HYPERGEOM : PostAnalysisFilterType .MANN_WHIT_TWO_SIDED ;
549
563
rankTestCombo .setSelectedItem (typeToUse );
550
- rankTestTextField .setValue ( typeToUse .defaultValue );
564
+ rankTestTextField .setText ( DECIMAL_FORMAT . format ( typeToUse .defaultValue ) );
551
565
552
566
rankingEnablementRenderer .enableAll ();
553
567
if (rankingArray .length == 0 ) {
0 commit comments