mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
Updates to the decimator FX
This commit is contained in:
parent
f9f29bae75
commit
08005c06e1
@ -30,8 +30,7 @@ public class OfflineDAQPane extends SettingsPane<OfflineFileParameters>{
|
||||
private PamBorderPane mainPane;
|
||||
|
||||
|
||||
public OfflineDAQPane(OfflineFileDataStore acquisitionControl,
|
||||
AcquisitionPaneFX acquisitionPaneFX){
|
||||
public OfflineDAQPane(OfflineFileDataStore acquisitionControl){
|
||||
super(null);
|
||||
this.mainPane= new PamBorderPane();
|
||||
mainPane.setCenter(createOfflinePane());
|
||||
|
@ -1,19 +1,35 @@
|
||||
package decimator.layoutFX;
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
|
||||
import org.controlsfx.control.PopOver;
|
||||
|
||||
import Acquisition.layoutFX.OfflineDAQPane;
|
||||
import Filters.FilterBand;
|
||||
import Filters.FilterDialog;
|
||||
import Filters.FilterParams;
|
||||
import Filters.FilterType;
|
||||
import PamController.PamController;
|
||||
import PamController.SettingsPane;
|
||||
import PamDetection.RawDataUnit;
|
||||
import PamView.dialog.PamGridBagContraints;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import apple.laf.JRSUIUtils.TabbedPane;
|
||||
import dataMap.filemaps.OfflineFileDialogPanel;
|
||||
import decimator.DecimatorControl;
|
||||
import decimator.DecimatorParams;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.Pane;
|
||||
import pamViewFX.PamGuiManagerFX;
|
||||
import pamViewFX.fxNodes.PamBorderPane;
|
||||
import pamViewFX.fxNodes.PamButton;
|
||||
import pamViewFX.fxNodes.PamGridPane;
|
||||
import pamViewFX.fxNodes.PamVBox;
|
||||
import pamViewFX.fxNodes.pamDialogFX.PamDialogFX;
|
||||
import pamViewFX.fxNodes.utilityPanes.FilterPaneFX;
|
||||
import pamViewFX.fxNodes.utilityPanes.SourcePaneFX;
|
||||
|
||||
/**
|
||||
@ -24,6 +40,8 @@ import pamViewFX.fxNodes.utilityPanes.SourcePaneFX;
|
||||
*/
|
||||
public class DecimatorSettingsPane extends SettingsPane<DecimatorParams> {
|
||||
|
||||
private static DecimatorParams decimatorParams;
|
||||
|
||||
private PamBorderPane mainPane;
|
||||
|
||||
private DecimatorControl decimatorControl;
|
||||
@ -36,13 +54,25 @@ public class DecimatorSettingsPane extends SettingsPane<DecimatorParams> {
|
||||
|
||||
private TextField newSampleRate;
|
||||
|
||||
private PamButton filterButton;
|
||||
|
||||
private PamButton defaultFilterButton;
|
||||
|
||||
private Label filterInfo;
|
||||
|
||||
private FilterPaneFX filterPaneFX;
|
||||
|
||||
private ComboBox<String> interpolator;
|
||||
|
||||
private boolean isViewer;
|
||||
|
||||
public DecimatorSettingsPane(DecimatorControl aquisitionControl) {
|
||||
super(null);
|
||||
|
||||
mainPane= new PamBorderPane();
|
||||
this.decimatorControl = aquisitionControl;
|
||||
|
||||
mainPane.setCenter(new Label("Hello Decimator Pane"));
|
||||
mainPane.setCenter(createPane() );
|
||||
|
||||
}
|
||||
|
||||
@ -50,8 +80,11 @@ public class DecimatorSettingsPane extends SettingsPane<DecimatorParams> {
|
||||
|
||||
PamVBox mainPanel = new PamVBox();
|
||||
|
||||
GridBagConstraints constraints = new PamGridBagContraints();
|
||||
// insets = new Insets(2,2,2,2);
|
||||
// insets = new Insets(2,2,2,2);
|
||||
|
||||
Label srcLabel = new Label("Decimator settings");
|
||||
PamGuiManagerFX.titleFont2style(srcLabel);
|
||||
mainPanel.getChildren().add(srcLabel);
|
||||
|
||||
sourcePanel = new SourcePaneFX( RawDataUnit.class, true, true);
|
||||
sourcePanel.addSelectionListener((obsval, oldVal, newVal)->{
|
||||
@ -59,12 +92,14 @@ public class DecimatorSettingsPane extends SettingsPane<DecimatorParams> {
|
||||
});
|
||||
|
||||
// sourcePanel.addSourcePanelMonitor(new SPMonitor());
|
||||
mainPanel.getChildren().add(sourcePanel.getPane());
|
||||
mainPanel.getChildren().addAll(srcLabel, sourcePanel.getPane());
|
||||
|
||||
PamGridPane decimatorPanel = new PamGridPane();
|
||||
|
||||
|
||||
//Decimator Settings
|
||||
Label label = new Label("Decimator settings");
|
||||
PamGuiManagerFX.titleFont2style(label);
|
||||
mainPanel.getChildren().add(label);
|
||||
|
||||
int gridx = 0;
|
||||
int gridy = 0;
|
||||
@ -73,46 +108,67 @@ public class DecimatorSettingsPane extends SettingsPane<DecimatorParams> {
|
||||
decimatorPanel.add(sourceSampleRate = new Label(" - Hz"), gridx, gridy);
|
||||
gridx = 0;
|
||||
gridy ++;
|
||||
// decimatorPanel.add(new JLabel("Output sample rate "), gridx, gridy);
|
||||
// gridx ++;
|
||||
// decimatorPanel.add(newSampleRate = new TextField(), gridx, gridy);
|
||||
// gridx ++;
|
||||
// decimatorPanel.add(new JLabel(" Hz"), gridx, gridy);
|
||||
// gridy ++;
|
||||
// gridx = 0;
|
||||
|
||||
decimatorPanel.add(new Label("Output sample rate "), gridx, gridy);
|
||||
gridx ++;
|
||||
decimatorPanel.add(newSampleRate = new TextField(), gridx, gridy);
|
||||
gridx ++;
|
||||
decimatorPanel.add(new Label(" Hz"), gridx, gridy);
|
||||
gridy ++;
|
||||
gridx = 0;
|
||||
// gridwidth = 1;
|
||||
// decimatorPanel.add(filterButton = new PamButton("Filter settings"), gridx, gridy);
|
||||
|
||||
filterPaneFX = new FilterPaneFX();
|
||||
decimatorPanel.add(filterButton = new PamButton("Filter settings"), gridx, gridy);
|
||||
filterButton.setOnAction((action)->{
|
||||
selectFilters(filterButton);
|
||||
});
|
||||
|
||||
|
||||
// filterButton.addActionListener(new FilterButton());
|
||||
// gridx = 1;
|
||||
gridx = 1;
|
||||
// gridwidth = 2;
|
||||
// addComponent(decimatorPanel, defaultFilterButton = new PamButton("Default Filter"), gridx, gridy);
|
||||
// defaultFilterButton.addActionListener(new DefaultFilterButton());
|
||||
// gridx = 0;
|
||||
// gridwidth = 3;
|
||||
// gridy++;
|
||||
// addComponent(decimatorPanel, filterInfo = new JLabel("Filter: "), gridx, gridy);
|
||||
// gridx = 0;
|
||||
|
||||
|
||||
decimatorPanel.add(defaultFilterButton = new PamButton("Default Filter"), gridx, gridy);
|
||||
defaultFilterButton.setOnAction((action)->{
|
||||
restoreDefaultSettings();
|
||||
});
|
||||
|
||||
gridx = 0;
|
||||
gridy++;
|
||||
decimatorPanel.add(filterInfo = new Label("Filter: "), gridx, gridy);
|
||||
PamGridPane.setColumnSpan(filterInfo, 3);
|
||||
|
||||
gridx = 0;
|
||||
// gridwidth = 1;
|
||||
// gridy++;
|
||||
// addComponent(decimatorPanel, new JLabel("Interpolation: ", JLabel.RIGHT), gridx, gridy);
|
||||
gridy++;
|
||||
|
||||
Label interpLabel = new Label("Interpolation: ");
|
||||
|
||||
decimatorPanel.add(interpLabel, gridx, gridy);
|
||||
gridx++;
|
||||
// gridx += gridwidth;
|
||||
// gridwidth = 2;
|
||||
// addComponent(decimatorPanel, interpolator = new JComboBox<String>(), gridx, gridy);
|
||||
// interpolator.addItem("None");
|
||||
// interpolator.addItem("Linear");
|
||||
// interpolator.addItem("Quadratic");
|
||||
decimatorPanel.add(interpolator = new ComboBox<String>(), gridx, gridy);
|
||||
interpolator.getItems().add("None");
|
||||
interpolator.getItems().add("Linear");
|
||||
interpolator.getItems().add("Quadratic");
|
||||
//
|
||||
// isViewer = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW;
|
||||
// if (isViewer) {
|
||||
// JTabbedPane tabbedPane = new JTabbedPane();
|
||||
// offlineDAQDialogPanel = new OfflineFileDialogPanel(decimatorControl, this);
|
||||
// tabbedPane.add("Offline Files", offlineDAQDialogPanel.getComponent());
|
||||
// tabbedPane.add("Runtime Settings", mainPanel);
|
||||
// setDialogComponent(tabbedPane);
|
||||
// }
|
||||
// else {
|
||||
// setDialogComponent(mainPanel);
|
||||
// }
|
||||
isViewer = PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW;
|
||||
if (isViewer) {
|
||||
TabPane tabbedPane = new TabPane();
|
||||
|
||||
offlineDAQPaneFX= new OfflineDAQPane(acquisitionControl, this);
|
||||
|
||||
offlineDAQDialogPanel = new OfflineFileDialogPanel(decimatorControl, this);
|
||||
tabbedPane.add("Offline Files", offlineDAQDialogPanel.getComponent());
|
||||
tabbedPane.add("Runtime Settings", mainPanel);
|
||||
setDialogComponent(tabbedPane);
|
||||
}
|
||||
else {
|
||||
setDialogComponent(mainPanel);
|
||||
}
|
||||
//
|
||||
// setHelpPoint("sound_processing.decimatorHelp.docs.decimator_decimator");
|
||||
// filterButton.setToolTipText("Manual adjustment of filter settings");
|
||||
@ -122,6 +178,80 @@ public class DecimatorSettingsPane extends SettingsPane<DecimatorParams> {
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
private void selectFilters(PamButton button) {
|
||||
float filtSampleRate = Math.max(inputSampleRate, getOutputSampleRate());
|
||||
|
||||
PopOver popOver = new PopOver();
|
||||
|
||||
popOver.setContentNode(filterPaneFX.getContentNode());
|
||||
|
||||
popOver.setOnHidden((e)->{
|
||||
filterPaneFX.setSampleRate(filtSampleRate);
|
||||
FilterParams newFP = filterPaneFX.getParams(decimatorParams.filterParams);
|
||||
|
||||
if (newFP != null) {
|
||||
decimatorParams.filterParams = newFP.clone();
|
||||
}
|
||||
|
||||
sayFilter();
|
||||
|
||||
});
|
||||
|
||||
popOver.show(button);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* display filter information
|
||||
*/
|
||||
private void sayFilter() {
|
||||
if (decimatorParams == null || decimatorParams.filterParams == null) {
|
||||
filterInfo.setText("No filter");
|
||||
}
|
||||
else {
|
||||
filterInfo.setText("Filter: " + decimatorParams.filterParams.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private float getOutputSampleRate() {
|
||||
try {
|
||||
float fs = Float.valueOf(newSampleRate.getText());
|
||||
return fs;
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return inputSampleRate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void restoreDefaultSettings() {
|
||||
/*
|
||||
* does not set the output sample rate, but does set sensible values for the
|
||||
* filter.
|
||||
*/
|
||||
float newFS = 0;
|
||||
try {
|
||||
newFS = java.lang.Float.valueOf(newSampleRate.getText());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
}
|
||||
PamDataBlock sourceblock = sourcePanel.getSource();
|
||||
if (sourceblock.getSampleRate() > 0) {
|
||||
newFS = Math.min(newFS, sourceblock.getSampleRate());
|
||||
}
|
||||
if (newFS <= 0) {
|
||||
PamDialogFX.showWarning("Invalid output samplerate : " + newSampleRate.getText());
|
||||
return;
|
||||
}
|
||||
decimatorParams.filterParams.lowPassFreq = newFS/2;
|
||||
decimatorParams.filterParams.filterType = FilterType.BUTTERWORTH;
|
||||
decimatorParams.filterParams.filterOrder = 6;
|
||||
decimatorParams.filterParams.filterBand = FilterBand.LOWPASS;
|
||||
|
||||
sayFilter();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DecimatorParams getParams(DecimatorParams currParams) {
|
||||
|
Loading…
Reference in New Issue
Block a user