Updates to sud zero pad options on FX GUI

This commit is contained in:
Jamie Mac 2024-07-09 16:36:04 +01:00
parent 6ee03579d0
commit 38dc7e6076
6 changed files with 160 additions and 57 deletions

View File

@ -853,6 +853,7 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
if (skipSecondsField!=null) { if (skipSecondsField!=null) {
skipSecondsField.setText(String.format("%.1f", fileInputParameters.skipStartFileTime/1000.)); skipSecondsField.setText(String.format("%.1f", fileInputParameters.skipStartFileTime/1000.));
} }
} }
@Override @Override

View File

@ -6,23 +6,18 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Orientation; import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority; import javafx.scene.layout.Priority;
import javafx.scene.paint.Color;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.util.StringConverter; import javafx.util.StringConverter;
import pamViewFX.PamGuiManagerFX; import pamViewFX.PamGuiManagerFX;
import pamViewFX.fxGlyphs.PamGlyphDude;
import pamViewFX.fxNodes.PamBorderPane; import pamViewFX.fxNodes.PamBorderPane;
import pamViewFX.fxNodes.PamButton;
import pamViewFX.fxNodes.PamComboBox; import pamViewFX.fxNodes.PamComboBox;
import pamViewFX.fxNodes.PamGridPane; import pamViewFX.fxNodes.PamGridPane;
import pamViewFX.fxNodes.PamHBox;
import pamViewFX.fxNodes.PamTextField; import pamViewFX.fxNodes.PamTextField;
import pamViewFX.fxNodes.PamVBox; import pamViewFX.fxNodes.PamVBox;
import pamViewFX.fxNodes.flipPane.FlipPane; import pamViewFX.fxNodes.flipPane.FlipPane;
@ -43,7 +38,7 @@ import dataMap.filemaps.OfflineFileParameters;
*/ */
public class AcquisitionPaneFX extends SettingsPane<AcquisitionParameters>{ public class AcquisitionPaneFX extends SettingsPane<AcquisitionParameters>{
private final static int TEXT_FIELD_WIDTH = 60; private final static int TEXT_FIELD_WIDTH = 80;
/** /**
* Reference to acquisition control. * Reference to acquisition control.
@ -120,13 +115,13 @@ public class AcquisitionPaneFX extends SettingsPane<AcquisitionParameters>{
/** /**
* *
*/ */
private FlipPane flipPane; private PamFlipPane flipPane;
/** /**
* Pane which can be used for advanced settings. * Pane which can be used for advanced settings.
*/ */
private PamBorderPane advancedSettingPane; // private PamBorderPane advancedSettingPane;
/** /**
* Title label for the advanced pane. * Title label for the advanced pane.
@ -147,12 +142,13 @@ public class AcquisitionPaneFX extends SettingsPane<AcquisitionParameters>{
super(null); super(null);
mainPane = new PamBorderPane(); mainPane = new PamBorderPane();
mainPane.setPrefWidth(400); mainPane.setPrefWidth(400);
mainPane.setPadding(new Insets(5,5,5,5));
this.acquisitionControl=aquisitionControl; this.acquisitionControl=aquisitionControl;
this.acquisitionParameters=acquisitionControl.getAcquisitionParameters(); this.acquisitionParameters=acquisitionControl.getAcquisitionParameters();
//create the flip pane. //create the flip pane.
flipPane=new FlipPane(); flipPane=new PamFlipPane();
flipPane.setFlipDirection(Orientation.HORIZONTAL); flipPane.setFlipDirection(Orientation.HORIZONTAL);
flipPane.setFlipTime(PamFlipPane.FLIP_TIME); //default is 700ms- way too high flipPane.setFlipTime(PamFlipPane.FLIP_TIME); //default is 700ms- way too high
//flipPane.prefWidthProperty().bind(mainPane.widthProperty()); //flipPane.prefWidthProperty().bind(mainPane.widthProperty());
@ -166,45 +162,45 @@ public class AcquisitionPaneFX extends SettingsPane<AcquisitionParameters>{
flipPane.getFront().getChildren().add(mainPane); flipPane.getFront().getChildren().add(mainPane);
//create the advanced flip pane. //create the advanced flip pane.
advancedSettingPane = createAdvSettingsPane(); // advancedSettingPane = createAdvSettingsPane();
flipPane.getBack().getChildren().add(advancedSettingPane); // flipPane.getBack().getChildren().add(advancedSettingPane);
//System.out.println("MAKE PANE: " + acquisitionParameters.getDaqSystemType()); //System.out.println("MAKE PANE: " + acquisitionParameters.getDaqSystemType());
} }
/** // /**
* Create the advanced settings pane which can be accessed by DAQ panes if needed. // * Create the advanced settings pane which can be accessed by DAQ panes if needed.
*/ // */
private PamBorderPane createAdvSettingsPane() { // private PamBorderPane createAdvSettingsPane() {
//
PamButton back = new PamButton(); // PamButton back = new PamButton();
back.setGraphic(PamGlyphDude.createPamIcon("mdi2c-chevron-left", Color.WHITE, PamGuiManagerFX.iconSize)); // back.setGraphic(PamGlyphDude.createPamIcon("mdi2c-chevron-left", Color.WHITE, PamGuiManagerFX.iconSize));
//
back.setOnAction((action)->{ // back.setOnAction((action)->{
flipPane.flipToFront(); // flipPane.flipToFront();
}); // });
//
PamBorderPane advPane = new PamBorderPane(); // PamBorderPane advPane = new PamBorderPane();
advPane.setPadding(new Insets(5,5,5,5)); // advPane.setPadding(new Insets(5,5,5,5));
//
PamHBox buttonHolder = new PamHBox(); // PamHBox buttonHolder = new PamHBox();
//
buttonHolder.setBackground(null); // buttonHolder.setBackground(null);
//buttonHolder.setStyle("-fx-background-color: red;"); // //buttonHolder.setStyle("-fx-background-color: red;");
buttonHolder.setAlignment(Pos.CENTER_LEFT); // buttonHolder.setAlignment(Pos.CENTER_LEFT);
buttonHolder.getChildren().addAll(back, advLabel = new Label("Adv. Settings")); // buttonHolder.getChildren().addAll(back, advLabel = new Label("Adv. Settings"));
advLabel.setAlignment(Pos.CENTER); // advLabel.setAlignment(Pos.CENTER);
advLabel.setMaxWidth(Double.MAX_VALUE); //need to make sure label is in center. // advLabel.setMaxWidth(Double.MAX_VALUE); //need to make sure label is in center.
PamGuiManagerFX.titleFont2style(advLabel); // PamGuiManagerFX.titleFont2style(advLabel);
//
advLabel.setAlignment(Pos.CENTER); // advLabel.setAlignment(Pos.CENTER);
HBox.setHgrow(advLabel, Priority.ALWAYS); // HBox.setHgrow(advLabel, Priority.ALWAYS);
//
advPane.setTop(buttonHolder); // advPane.setTop(buttonHolder);
//
return advPane; // return advPane;
//
} // }
/** /**
* Create the Sound Aquisition pane for real time monitoring. * Create the Sound Aquisition pane for real time monitoring.
@ -606,11 +602,12 @@ public class AcquisitionPaneFX extends SettingsPane<AcquisitionParameters>{
} }
public PamBorderPane getAdvancedPane() { public PamBorderPane getAdvancedPane() {
return this.advancedSettingPane; return this.flipPane.getAdvContentPane()
;
} }
public Label getAdvancedLabel() { public TextField getAdvancedLabel() {
return this.advLabel; return this.flipPane.getAdvLabel();
} }
} }

View File

@ -1,5 +1,6 @@
package Acquisition.layoutFX; package Acquisition.layoutFX;
import java.awt.GridBagConstraints;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -12,6 +13,8 @@ import Acquisition.FileInputParameters;
import Acquisition.FolderInputParameters; import Acquisition.FolderInputParameters;
import Acquisition.FolderInputSystem; import Acquisition.FolderInputSystem;
import Acquisition.pamAudio.PamAudioFileFilter; import Acquisition.pamAudio.PamAudioFileFilter;
import Acquisition.pamAudio.PamAudioFileLoader;
import Acquisition.pamAudio.PamAudioFileManager;
import PamController.PamController; import PamController.PamController;
import PamController.PamFolders; import PamController.PamFolders;
import PamUtils.PamCalendar; import PamUtils.PamCalendar;
@ -147,6 +150,8 @@ public class FolderInputPane extends DAQSettingsPane<FolderInputParameters>{
*/ */
private ToggleButton mergeContigious; private ToggleButton mergeContigious;
private PamBorderPane audioHolderloader;
// /** // /**
// * The folder input system. // * The folder input system.
// * @param folderInputSystem - the folder system. // * @param folderInputSystem - the folder system.
@ -245,8 +250,11 @@ public class FolderInputPane extends DAQSettingsPane<FolderInputParameters>{
Label utilsLabel=new Label("Sound file utilities"); Label utilsLabel=new Label("Sound file utilities");
PamGuiManagerFX.titleFont2style(utilsLabel); PamGuiManagerFX.titleFont2style(utilsLabel);
//
audioHolderloader = new PamBorderPane();
pamVBox.getChildren().addAll(fileSelectBox, subFolderPane, progressBar, createTablePane(), pamVBox.getChildren().addAll(fileSelectBox, subFolderPane, progressBar, createTablePane(),
fileDateText=new Label(), utilsLabel, createUtilsPane()); fileDateText=new Label(), audioHolderloader, utilsLabel, createUtilsPane());
//allow users to check file headers in viewer mode. //allow users to check file headers in viewer mode.
// if (PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW) { // if (PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW) {
@ -361,6 +369,7 @@ public class FolderInputPane extends DAQSettingsPane<FolderInputParameters>{
return new PamBorderPane(table); return new PamBorderPane(table);
} }
/** /**
* Open a dialog to select either a folder or a list of files. * Open a dialog to select either a folder or a list of files.
* @param folderDir - true to use directory chooser, false to use multiple file chooser. * @param folderDir - true to use directory chooser, false to use multiple file chooser.
@ -594,6 +603,9 @@ public class FolderInputPane extends DAQSettingsPane<FolderInputParameters>{
this.table.getItems().addAll(fileList); this.table.getItems().addAll(fileList);
fileDateStrip.setFileList(fileList); fileDateStrip.setFileList(fileList);
//set any bespoke options for the files to be laoded.
setFileOptionPane(fileList);
//need to set the sample rate and channels in the main pane. //need to set the sample rate and channels in the main pane.
if (fileList!=null && fileList.size()>0) { if (fileList!=null && fileList.size()>0) {
@ -609,6 +621,34 @@ public class FolderInputPane extends DAQSettingsPane<FolderInputParameters>{
// fileDateStrip.setDate(folderInputSystem.getFileStartTime(selFiles[0])); // fileDateStrip.setDate(folderInputSystem.getFileStartTime(selFiles[0]));
// } // }
} }
/**
* Set bespoke options for certain file types.
*/
public void setFileOptionPane(ObservableList<WavFileType> fileList) {
audioHolderloader.setCenter(null);
if (fileList.size() > 0) {
//Get all the audio file laoders that will be used for this list of files. Usually
//just one but possible that there can be mixed files.
ArrayList<PamAudioFileLoader> loaders = PamAudioFileManager.getInstance().getAudioFileLoaders(fileList);
PamVBox vBox = new PamVBox();
vBox.setSpacing(5);
for (PamAudioFileLoader loader : loaders) {
if (loader.getSettingsPane()!=null) {
//add the settings pane to the vbox
vBox.getChildren().add(loader.getSettingsPane().getAudioLoaderPane());
loader.getSettingsPane().setParams();
}
}
audioHolderloader.setCenter(vBox);
}
}
/** /**
* Called whenever a new file worker is initialised to search a folder for wav files. * Called whenever a new file worker is initialised to search a folder for wav files.
@ -637,16 +677,30 @@ public class FolderInputPane extends DAQSettingsPane<FolderInputParameters>{
public void setParams() { public void setParams() {
//set the parameters for the dialog. //set the parameters for the dialog.
this.setParams(folderInputSystem.getFolderInputParameters()); this.setParams(folderInputSystem.getFolderInputParameters());
} }
@Override @Override
public boolean getParams() { public boolean getParams() {
FolderInputParameters params = this.getParams(folderInputSystem.getFolderInputParameters()); FolderInputParameters params = this.getParams(folderInputSystem.getFolderInputParameters());
//get bespoke paramters from selected audio loaders. Note these are global and so are not part
//of the folder input system
ArrayList<PamAudioFileLoader> loaders = PamAudioFileManager.getInstance().getAudioFileLoaders();
for (PamAudioFileLoader loader : loaders) {
if (loader.getSettingsPane()!=null) {
loader.getSettingsPane().getParams();
}
}
if (params == null) return false; if (params == null) return false;
else { else {
this.folderInputSystem.setFolderInputParameters(params); this.folderInputSystem.setFolderInputParameters(params);
return true; return true;
} }
} }

View File

@ -3,6 +3,7 @@ package Acquisition.pamAudio;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.UnsupportedAudioFileException; import javax.sound.sampled.UnsupportedAudioFileException;
@ -177,7 +178,7 @@ public class PamAudioFileManager {
* @param files - the files to find audio loaders for. * @param files - the files to find audio loaders for.
* @return a list of the audio loaders required for the file list * @return a list of the audio loaders required for the file list
*/ */
public ArrayList<PamAudioFileLoader> getAudioFileLoaders(ArrayList<? extends File> files) { public ArrayList<PamAudioFileLoader> getAudioFileLoaders(List<? extends File> files) {
ArrayList<PamAudioFileLoader> audioLoaders = new ArrayList<PamAudioFileLoader>(); ArrayList<PamAudioFileLoader> audioLoaders = new ArrayList<PamAudioFileLoader>();
PamAudioFileLoader loader; PamAudioFileLoader loader;
for (int i=0; i<files.size(); i++) { for (int i=0; i<files.size(); i++) {

View File

@ -10,7 +10,10 @@ import javax.swing.JPanel;
import Acquisition.pamAudio.PamAudioSettingsPane; import Acquisition.pamAudio.PamAudioSettingsPane;
import PamView.dialog.PamGridBagContraints; import PamView.dialog.PamGridBagContraints;
import PamView.panel.PamPanel; import PamView.panel.PamPanel;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import pamViewFX.fxNodes.PamHBox;
import pamViewFX.fxNodes.utilityPanes.PamToggleSwitch;
/** /**
* Some Swing and FX controls to allow a user to chnage sud parameters. * Some Swing and FX controls to allow a user to chnage sud parameters.
@ -20,6 +23,12 @@ public class SudAudioSettingsPane implements PamAudioSettingsPane {
private SudAudioFile sudAudioFile; private SudAudioFile sudAudioFile;
private SudSettingsPanel sudAudioPanel; private SudSettingsPanel sudAudioPanel;
private SudSettingsPane sudAudioPaneFX;
private String sudTooltip = "Zero pad sud files. Zero padding replaces sections of sud files \n"
+ "with corrupt or no data with zeros. This can improve time drift. ";
public SudAudioSettingsPane(SudAudioFile sudAudioFile) { public SudAudioSettingsPane(SudAudioFile sudAudioFile) {
this.sudAudioFile=sudAudioFile; this.sudAudioFile=sudAudioFile;
@ -27,8 +36,10 @@ public class SudAudioSettingsPane implements PamAudioSettingsPane {
@Override @Override
public Pane getAudioLoaderPane() { public Pane getAudioLoaderPane() {
// TODO Auto-generated method stub if (sudAudioPaneFX==null) {
return null; createSudAudioPaneFX();
}
return sudAudioPaneFX;
} }
@Override @Override
@ -42,17 +53,24 @@ public class SudAudioSettingsPane implements PamAudioSettingsPane {
private void createSudAudioPanel() { private void createSudAudioPanel() {
sudAudioPanel = new SudSettingsPanel(); sudAudioPanel = new SudSettingsPanel();
} }
private void createSudAudioPaneFX() {
sudAudioPaneFX = new SudSettingsPane();
}
public void setParams(PamSudParams sudParams) { public void setParams(PamSudParams sudParams) {
//System.out.println("Set SUD PARAMS: " + sudParams + " " + sudParams.zeroPad); //System.out.println("Set SUD PARAMS: " + sudParams + " " + sudParams.zeroPad);
if (sudAudioPanel!=null) sudAudioPanel.setParams(sudParams);; if (sudAudioPanel!=null) sudAudioPanel.setParams(sudParams);;
if (sudAudioPaneFX!=null) sudAudioPaneFX.setParams(sudParams);;
} }
public PamSudParams getParams(PamSudParams sudParams) { public PamSudParams getParams(PamSudParams sudParams) {
//System.out.println("Get SUD PARAMS: " + sudParams + " " + sudParams.zeroPad); //System.out.println("Get SUD PARAMS: " + sudParams + " " + sudParams.zeroPad);
if (sudAudioPanel!=null) return sudAudioPanel.getParams(sudParams);; if (sudAudioPanel!=null) return sudAudioPanel.getParams(sudParams);
if (sudAudioPaneFX!=null) return sudAudioPaneFX.getParams(sudParams);;
return null; return null;
} }
@ -61,9 +79,8 @@ public class SudAudioSettingsPane implements PamAudioSettingsPane {
* The sud settings panel. * The sud settings panel.
*/ */
public class SudSettingsPanel extends PamPanel { public class SudSettingsPanel extends PamPanel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private JCheckBox zeroPadSud; private JCheckBox zeroPadSud;
public SudSettingsPanel() { public SudSettingsPanel() {
@ -76,8 +93,7 @@ public class SudAudioSettingsPane implements PamAudioSettingsPane {
c.gridwidth = 1; c.gridwidth = 1;
zeroPadSud = new JCheckBox("Zero pad sud files"); zeroPadSud = new JCheckBox("Zero pad sud files");
zeroPadSud.setToolTipText("Zero pad sud files. Zero padding replaces sections of sud files \n" zeroPadSud.setToolTipText(sudTooltip);
+ "with corrupt or no data with zeros. This can improve time drift. ");
this.add(zeroPadSud,c); this.add(zeroPadSud,c);
} }
@ -93,6 +109,40 @@ public class SudAudioSettingsPane implements PamAudioSettingsPane {
} }
} }
/**
* The sud settings panel for JavaFX
*/
public class SudSettingsPane extends PamHBox {
private PamToggleSwitch zeroPadSud;
public SudSettingsPane() {
// soundTrapDate.setPreferredSize(tzPanel.getPreferredSize());
GridBagConstraints c = new PamGridBagContraints();
c.gridy = 0;
c.gridx = 0;
c.gridwidth = 1;
zeroPadSud = new PamToggleSwitch("Zero pad sud files");
zeroPadSud.setTooltip(new Tooltip(sudTooltip));
this.getChildren().add(zeroPadSud);
}
public void setParams(PamSudParams sudParams) {
this.zeroPadSud.setSelected(sudParams.zeroPad);
}
public PamSudParams getParams(PamSudParams sudParams) {
sudParams.zeroPad = zeroPadSud.isSelected();
return sudParams;
}
}
@Override @Override

View File

@ -128,7 +128,7 @@ public class PamFlipPane extends FlipPane {
* Convenience duplicate of getBackPane(). * Convenience duplicate of getBackPane().
* @return the back pane. * @return the back pane.
*/ */
public PamBorderPane getAdvPane() { public PamBorderPane getAdvContentPane() {
return advPane; return advPane;
} }