@@ -233,6 +233,13 @@ private JPanel createFilterEdgesPanel() {
233
233
cardPanel .add (advancedPanel , "advanced" );
234
234
cardPanel .setOpaque (false );
235
235
236
+ // Link the two panels together
237
+ similaritySlider .getSlider ().addChangeListener (e -> {
238
+ SimilarityMetric metric = similaritySlider .getSimilarityMetric ();
239
+ double cutoff = similaritySlider .getCutoff ();
240
+ cutoffMetricCombo .setSelectedItem (ComboItem .of (metric ));
241
+ similarityCutoffText .setText (String .valueOf (cutoff ));
242
+ });
236
243
237
244
final GroupLayout layout = new GroupLayout (panel );
238
245
panel .setLayout (layout );
@@ -342,9 +349,10 @@ private JPanel createFilterEdgesPanel_Advanced() {
342
349
SwingUtil .makeSmall (similarityCutoffText , cutoffMetricCombo );
343
350
344
351
ActionListener sliderUpdate = e -> {
345
- SimilarityMetric type = getSimilarityMetric ();
352
+ SimilarityMetric type = getCutoffMetricComboValue ();
346
353
similarityCutoffText .setValue (cutoffValues .get (type ));
347
- combinedConstantSlider .setVisible (type == SimilarityMetric .COMBINED );
354
+ // Don't make the slider visible unless the advanced panel is also visible or else it throws off the layout.
355
+ combinedConstantSlider .setVisible (advancedCheckBox .isSelected () && type == SimilarityMetric .COMBINED );
348
356
};
349
357
350
358
double combinedConstant = propertyManager .getCombinedConstant ();
@@ -360,7 +368,7 @@ private JPanel createFilterEdgesPanel_Advanced() {
360
368
361
369
similarityCutoffText .addPropertyChangeListener ("value" , e -> {
362
370
double value = ((Number )e .getNewValue ()).doubleValue ();
363
- cutoffValues .put (getSimilarityMetric (), value );
371
+ cutoffValues .put (getCutoffMetricComboValue (), value );
364
372
});
365
373
366
374
final GroupLayout layout = new GroupLayout (panel );
@@ -426,18 +434,22 @@ public void reset() {
426
434
}
427
435
428
436
429
- private void showAdvancedOptions (boolean show ) {
430
- pvalueLabel .setVisible (show );
431
- pvalueText .setVisible (show );
432
- nesFilterLabel .setVisible (show );
433
- nesFilterCombo .setVisible (show );
434
- minExperimentsLabel .setVisible (show );
435
- minExperimentsText .setVisible (show );
436
- shouldFilterMinLabel .setVisible (show );
437
- shouldFilterMinCheckbox .setVisible (show );
437
+ private void showAdvancedOptions (boolean showAdvanced ) {
438
+ pvalueLabel .setVisible (showAdvanced );
439
+ pvalueText .setVisible (showAdvanced );
440
+ nesFilterLabel .setVisible (showAdvanced );
441
+ nesFilterCombo .setVisible (showAdvanced );
442
+ minExperimentsLabel .setVisible (showAdvanced );
443
+ minExperimentsText .setVisible (showAdvanced );
444
+ shouldFilterMinLabel .setVisible (showAdvanced );
445
+ shouldFilterMinCheckbox .setVisible (showAdvanced );
438
446
439
447
CardLayout cardLayout = (CardLayout )cardPanel .getLayout ();
440
- cardLayout .show (cardPanel , show ? "advanced" : "simple" );
448
+ cardLayout .show (cardPanel , showAdvanced ? "advanced" : "simple" );
449
+
450
+ // If we are switching to the advanced panel make sure the combined slider is visible if it needs to be.
451
+ boolean showCombinedSlider = showAdvanced && getCutoffMetricComboValue () == SimilarityMetric .COMBINED ;
452
+ combinedConstantSlider .setVisible (showCombinedSlider );
441
453
}
442
454
443
455
@@ -458,7 +470,7 @@ public AbstractFormatter getFormatter(JFormattedTextField tf) {
458
470
459
471
public double getPValue () {
460
472
return pvalueText .isVisible ()
461
- ? getValue (pvalueText )
473
+ ? getTextFieldDoubleValue (pvalueText )
462
474
: propertyManager .getPvalue ();
463
475
}
464
476
@@ -479,7 +491,7 @@ public Optional<Integer> getMinimumExperiments() {
479
491
}
480
492
481
493
public double getQValue () {
482
- return getValue (qvalueText );
494
+ return getTextFieldDoubleValue (qvalueText );
483
495
}
484
496
485
497
public double getCombinedConstant () {
@@ -491,14 +503,18 @@ public double getCombinedConstant() {
491
503
492
504
public double getCutoff () {
493
505
if (advancedCheckBox .isSelected ())
494
- return getValue (similarityCutoffText );
506
+ return getTextFieldDoubleValue (similarityCutoffText );
495
507
else
496
508
return similaritySlider .getCutoff ();
497
509
}
498
510
511
+ private SimilarityMetric getCutoffMetricComboValue () {
512
+ return cutoffMetricCombo .getItemAt (cutoffMetricCombo .getSelectedIndex ()).getValue ();
513
+ }
514
+
499
515
public SimilarityMetric getSimilarityMetric () {
500
516
if (advancedCheckBox .isSelected ())
501
- return cutoffMetricCombo . getItemAt ( cutoffMetricCombo . getSelectedIndex ()). getValue ();
517
+ return getCutoffMetricComboValue ();
502
518
else
503
519
return similaritySlider .getSimilarityMetric ();
504
520
}
@@ -507,7 +523,7 @@ public EdgeStrategy getEdgeStrategy() {
507
523
return edgeStrategyCombo .getItemAt (edgeStrategyCombo .getSelectedIndex ()).getValue ();
508
524
}
509
525
510
- private static double getValue (JFormattedTextField textField ) {
526
+ private static double getTextFieldDoubleValue (JFormattedTextField textField ) {
511
527
return ((Number )textField .getValue ()).doubleValue ();
512
528
}
513
529
0 commit comments