Skip to content

Commit

Permalink
Issue jawi#27: auto center on trigger after a capture is finished.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Willem Janssen committed Jan 26, 2013
1 parent 1726243 commit dc2ea96
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ protected String getDisplayValue( final SignalAlignment aValue )
private final JCheckBox showToolWindows;
private final JCheckBox showChannelIndexes;
private final JCheckBox retainAnnotations;
private final JCheckBox autoCenterCapture;
private final JComboBox annotationAlignment;
private final JComboBox signalAlignment;
private final JComboBox colorScheme;
Expand Down Expand Up @@ -193,6 +194,9 @@ public PreferencesDialog( final Window aParent, final UIColorSchemeManager aColo

this.showToolWindows = new JCheckBox();
this.showToolWindows.setToolTipText( "Whether or not the tool windows are shown by default. Will be applied after a restart." );

this.autoCenterCapture = new JCheckBox();
this.autoCenterCapture.setToolTipText( "Whether or not to auto-center the diagram to the trigger after a capture. Will be applied immediately." );

this.signalAlignment = new JComboBox( SignalAlignment.values() );
this.signalAlignment.setToolTipText( "The vertical alignment of the signals itself. Will be applied after an acquisition." );
Expand Down Expand Up @@ -277,6 +281,7 @@ protected void start() throws IOException
this.showChannelIndexes.setSelected( getBoolean( properties.get( CHANNELLABELS_SHOW_CHANNEL_INDEX ) ) );
this.retainAnnotations.setSelected( getBoolean( properties.get( RETAIN_ANNOTATIONS_WITH_RECAPTURE ) ) );
this.showToolWindows.setSelected( getBoolean( properties.get( SHOW_TOOL_WINDOWS_DEFAULT ) ) );
this.autoCenterCapture.setSelected( getBoolean( properties.get( AUTO_CENTER_TO_TRIGGER_AFTER_CAPTURE ) ) );

this.signalAlignment.setSelectedItem( getSignalAlignment( properties.get( SIGNALVIEW_SIGNAL_ALIGNMENT ) ) );
this.annotationAlignment.setSelectedItem( getSignalAlignment( properties.get( SIGNALVIEW_ANNOTATION_ALIGNMENT ) ) );
Expand Down Expand Up @@ -338,6 +343,7 @@ private void applyNewPreferences() throws IOException
properties.put( SHOW_TOOL_WINDOWS_DEFAULT, Boolean.toString( this.showToolWindows.isSelected() ) );
properties.put( CHANNELLABELS_SHOW_CHANNEL_INDEX, Boolean.toString( this.showChannelIndexes.isSelected() ) );
properties.put( RETAIN_ANNOTATIONS_WITH_RECAPTURE, Boolean.toString( this.retainAnnotations.isSelected() ) );
properties.put( AUTO_CENTER_TO_TRIGGER_AFTER_CAPTURE, Boolean.toString( this.autoCenterCapture.isSelected() ) );

properties.put( SIGNALVIEW_SIGNAL_ALIGNMENT, String.valueOf( this.signalAlignment.getSelectedItem() ) );
properties.put( SIGNALVIEW_ANNOTATION_ALIGNMENT, String.valueOf( this.annotationAlignment.getSelectedItem() ) );
Expand Down Expand Up @@ -407,6 +413,9 @@ private JComponent createGeneralSettingsTab()
pane.add( createRightAlignedLabel( "Show tool windows?" ) );
pane.add( this.showToolWindows );

pane.add( createRightAlignedLabel( "Auto-center on trigger?" ) );
pane.add( this.autoCenterCapture );

pane.add( createRightAlignedLabel( "Signal alignment" ) );
pane.add( this.signalAlignment );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import javax.swing.*;

import nl.lxtreme.ols.api.acquisition.AcquisitionResult;
import nl.lxtreme.ols.api.data.*;
import nl.lxtreme.ols.api.data.Cursor;
import nl.lxtreme.ols.api.data.project.*;
Expand Down Expand Up @@ -442,7 +443,23 @@ public void setDataModel( final DataSet aDataSet )
{
getSignalDiagramModel().setDataModel( aDataSet );

// will update the view and show the signals...
recalculateDimensions();

// optionally center the view on the trigger moment...
boolean autoCenterOnTrigger = UIManager.getBoolean( UIManagerKeys.AUTO_CENTER_TO_TRIGGER_AFTER_CAPTURE );
final AcquisitionResult capturedData = aDataSet.getCapturedData();

if ( autoCenterOnTrigger && capturedData.hasTriggerData() )
{
SwingComponentUtils.invokeOnEDT( new Runnable()
{
public void run()
{
scrollToTimestamp( capturedData.getTriggerPosition() );
}
} );
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public interface UIManagerKeys
String SNAP_CURSORS_DEFAULT = "ols.snap.cursors.default.boolean";
/** Whether or not the tool windows are shown by default. */
String SHOW_TOOL_WINDOWS_DEFAULT = "ols.show.tool.windows.default.boolean";
/** Whether or not the diagram should be centered to the trigger moment after a capture. */
String AUTO_CENTER_TO_TRIGGER_AFTER_CAPTURE = "ols.trigger.auto.center.boolean";
/** The current active color scheme. */
String COLOR_SCHEME = "ols.current.color.scheme.enum";
/**
Expand Down
1 change: 1 addition & 0 deletions ols.distribution/src/main/config/ols.ui.defaults.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ols.mousewheel.zoom.default.boolean = false
ols.snap.cursors.default.boolean = false
ols.show.tool.windows.default.boolean = false
ols.disble.sloppy.scope.painting.boolean = false
ols.trigger.auto.center.boolean = true
ols.background.color = 1E2126
ols.shadow.color = 151620
ols.channelgroup1.default.color = 92d4ca
Expand Down

0 comments on commit dc2ea96

Please sign in to comment.