Skip to content

Commit 18ef351

Browse files
committed
Make check buttons not trigger on mouseover
1 parent 02a0138 commit 18ef351

3 files changed

Lines changed: 29 additions & 27 deletions

File tree

src/main/java/gui/StDataExplorerPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public void keyPressed( KeyEvent e ) {}
241241

242242
/*
243243
this.visualization = new JCheckBox( "Visualization Options" );
244-
this.visualization.addActionListener(
244+
this.visualization.addItemListener(
245245
e ->
246246
{
247247
if ( this.visualization.isSelected() )

src/main/java/gui/bdv/STIMCardAlignICP.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public STIMCardAlignICP(
222222
panel.add(panelbuttons, "span,growx,pushy");
223223

224224
// disable RANSAC slider if not used
225-
useRANSAC.addActionListener( e -> SwingUtilities.invokeLater( () -> maxErrorRANSACSlider.setEnabled( useRANSAC.isSelected() ) ) );
225+
useRANSAC.addItemListener(e -> SwingUtilities.invokeLater(() -> maxErrorRANSACSlider.setEnabled(useRANSAC.isSelected())));
226226

227227
// disable lambdas if no regularization is selected
228228
boxModelFinal2.addActionListener(e -> SwingUtilities.invokeLater(() -> {

src/main/java/gui/bdv/STIMCardAlignSIFT.java

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public class STIMCardAlignSIFT
9393
private Affine2D<?> previousModel = null;
9494
private final SIFTParam param;
9595
final static String[] optionsSIFT = { "Fast", "Normal", "Thorough", "Very thorough", "Custom ..." };
96-
private boolean customModeSIFT = false; // we always start with "normal" for
96+
private AtomicBoolean customModeSIFT = new AtomicBoolean(false); // we always start with "normal" for
9797

9898
private final ExecutorService service;
9999
private final HashSet<String> genesWithInliers = new HashSet<>();
@@ -353,50 +353,52 @@ public STIMCardAlignSIFT(
353353
// set sift preset box to custom once one of the values is manually changed
354354
//
355355
final AtomicBoolean triggedChange = new AtomicBoolean( false );
356+
final int customIndex = 4;
356357

357358
customComponents.forEach( c -> {
358-
if (c instanceof JFormattedTextField)
359+
if (c instanceof JFormattedTextField) {
359360
c.addPropertyChangeListener(e -> {
360-
if ( !triggedChange.get() && e.getOldValue() != null && e.getNewValue() != null && e.getOldValue() != e.getNewValue() && box.getSelectedIndex() != 4 )
361-
{
362-
box.setSelectedIndex( 4 );
361+
if (!triggedChange.get()
362+
&& box.getSelectedIndex() != customIndex
363+
&& e.getOldValue() != null
364+
&& e.getNewValue() != null
365+
&& e.getOldValue() != e.getNewValue()) {
366+
box.setSelectedIndex(customIndex);
363367
}
364-
} );
365-
else if (c instanceof JCheckBox)
366-
((JCheckBox)c).addChangeListener( e -> { if ( !triggedChange.get() && box.getSelectedIndex() != 4 ) box.setSelectedIndex( 4 ); } );
367-
else if (c instanceof BoundedValuePanel)
368-
((BoundedValuePanel)c).changeListeners().add( () -> { if ( !triggedChange.get() && box.getSelectedIndex() != 4 ) box.setSelectedIndex( 4 ); } );
368+
});
369+
} else if (c instanceof JCheckBox) {
370+
((JCheckBox) c).addItemListener(e -> {if (!triggedChange.get() && box.getSelectedIndex() != customIndex) box.setSelectedIndex(customIndex);});
371+
} else if (c instanceof BoundedValuePanel) {
372+
((BoundedValuePanel) c).changeListeners().add(() -> {if (!triggedChange.get() && box.getSelectedIndex() != customIndex) box.setSelectedIndex(customIndex);});
373+
}
369374
});
370375

371376
// transform listener for max octave size
372377
stimcard.bdvhandle().getViewerPanel().transformListeners().add(l -> SwingUtilities.invokeLater(this::updateMaxOctaveSize));
373378

374379
// advanced options listener (changes menu)
375-
advancedOptions.addChangeListener( e -> SwingUtilities.invokeLater( () -> {
376-
if ( !customModeSIFT )
377-
{
380+
advancedOptions.addItemListener(e -> SwingUtilities.invokeLater(() -> {
381+
if (!customModeSIFT.get()) {
378382
// change to advanced mode
379383
AtomicInteger cc = new AtomicInteger(componentCount);
380384
triggedChange.set(true);
381-
advancedSIFTComponents.forEach( c -> panel.add(c, "span,growx,pushy", cc.getAndIncrement() ));
385+
advancedSIFTComponents.forEach(c -> panel.add(c, "span,growx,pushy", cc.getAndIncrement()));
382386
panel.updateUI();
383387

384-
triggedChange.set( false );
385-
customModeSIFT = true;
386-
}
387-
else
388-
{
388+
triggedChange.set(false);
389+
customModeSIFT.set(true);
390+
} else {
389391
// change to simple mode
390392
advancedSIFTComponents.forEach(panel::remove);
391-
customModeSIFT = false;
393+
panel.updateUI();
394+
customModeSIFT.set(false);
392395
}
393396
}));
394397

395398
// advanced menu listener (changes menu)
396399
box.addActionListener( e -> {
397400

398-
if ( box.getSelectedIndex() < 4 )
399-
{
401+
if (box.getSelectedIndex() != customIndex) {
400402
SwingUtilities.invokeLater( () ->
401403
{
402404
// update all values to the specific preset
@@ -436,7 +438,7 @@ else if (c instanceof BoundedValuePanel)
436438
});
437439

438440
// overlay listener
439-
overlayInliers.addChangeListener( e ->
441+
overlayInliers.addItemListener(e ->
440442
{
441443
if ( !overlayInliers.isSelected() )
442444
{
@@ -700,7 +702,7 @@ else if (c instanceof BoundedValuePanel)
700702
});
701703

702704
//
703-
// Return command line paramters for the last SIFT align run ...
705+
// Return command line parameters for the last SIFT align run ...
704706
//
705707
cmdLine.addActionListener( l ->
706708
{
@@ -827,7 +829,7 @@ private double parseDoubleWithDefault(String text, double defaultValue) {
827829
try {
828830
return format.parse(text.trim()).doubleValue();
829831
} catch (ParseException e) {
830-
logger.warn("Cannot parse from GUI -> setting default to {}", e);
832+
logger.warn("Cannot parse from GUI -> setting default to {}", defaultValue, e);
831833
return defaultValue;
832834
}
833835
}

0 commit comments

Comments
 (0)