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) {
skipSecondsField.setText(String.format("%.1f", fileInputParameters.skipStartFileTime/1000.));
}
}
@Override

View File

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

View File

@ -1,5 +1,6 @@
package Acquisition.layoutFX;
import java.awt.GridBagConstraints;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@ -12,6 +13,8 @@ import Acquisition.FileInputParameters;
import Acquisition.FolderInputParameters;
import Acquisition.FolderInputSystem;
import Acquisition.pamAudio.PamAudioFileFilter;
import Acquisition.pamAudio.PamAudioFileLoader;
import Acquisition.pamAudio.PamAudioFileManager;
import PamController.PamController;
import PamController.PamFolders;
import PamUtils.PamCalendar;
@ -147,6 +150,8 @@ public class FolderInputPane extends DAQSettingsPane<FolderInputParameters>{
*/
private ToggleButton mergeContigious;
private PamBorderPane audioHolderloader;
// /**
// * The folder input system.
// * @param folderInputSystem - the folder system.
@ -245,8 +250,11 @@ public class FolderInputPane extends DAQSettingsPane<FolderInputParameters>{
Label utilsLabel=new Label("Sound file utilities");
PamGuiManagerFX.titleFont2style(utilsLabel);
//
audioHolderloader = new PamBorderPane();
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.
// if (PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW) {
@ -361,6 +369,7 @@ public class FolderInputPane extends DAQSettingsPane<FolderInputParameters>{
return new PamBorderPane(table);
}
/**
* 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.
@ -594,6 +603,9 @@ public class FolderInputPane extends DAQSettingsPane<FolderInputParameters>{
this.table.getItems().addAll(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.
if (fileList!=null && fileList.size()>0) {
@ -609,6 +621,34 @@ public class FolderInputPane extends DAQSettingsPane<FolderInputParameters>{
// 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.
@ -637,16 +677,30 @@ public class FolderInputPane extends DAQSettingsPane<FolderInputParameters>{
public void setParams() {
//set the parameters for the dialog.
this.setParams(folderInputSystem.getFolderInputParameters());
}
@Override
public boolean getParams() {
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;
else {
this.folderInputSystem.setFolderInputParameters(params);
return true;
}
}

View File

@ -3,6 +3,7 @@ package Acquisition.pamAudio;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.UnsupportedAudioFileException;
@ -177,7 +178,7 @@ public class PamAudioFileManager {
* @param files - the files to find audio loaders for.
* @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>();
PamAudioFileLoader loader;
for (int i=0; i<files.size(); i++) {

View File

@ -10,7 +10,10 @@ import javax.swing.JPanel;
import Acquisition.pamAudio.PamAudioSettingsPane;
import PamView.dialog.PamGridBagContraints;
import PamView.panel.PamPanel;
import javafx.scene.control.Tooltip;
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.
@ -20,6 +23,12 @@ public class SudAudioSettingsPane implements PamAudioSettingsPane {
private SudAudioFile sudAudioFile;
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) {
this.sudAudioFile=sudAudioFile;
@ -27,8 +36,10 @@ public class SudAudioSettingsPane implements PamAudioSettingsPane {
@Override
public Pane getAudioLoaderPane() {
// TODO Auto-generated method stub
return null;
if (sudAudioPaneFX==null) {
createSudAudioPaneFX();
}
return sudAudioPaneFX;
}
@Override
@ -42,17 +53,24 @@ public class SudAudioSettingsPane implements PamAudioSettingsPane {
private void createSudAudioPanel() {
sudAudioPanel = new SudSettingsPanel();
}
private void createSudAudioPaneFX() {
sudAudioPaneFX = new SudSettingsPane();
}
public void setParams(PamSudParams sudParams) {
//System.out.println("Set SUD PARAMS: " + sudParams + " " + sudParams.zeroPad);
if (sudAudioPanel!=null) sudAudioPanel.setParams(sudParams);;
if (sudAudioPaneFX!=null) sudAudioPaneFX.setParams(sudParams);;
}
public PamSudParams getParams(PamSudParams sudParams) {
//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;
}
@ -61,9 +79,8 @@ public class SudAudioSettingsPane implements PamAudioSettingsPane {
* The sud settings panel.
*/
public class SudSettingsPanel extends PamPanel {
private static final long serialVersionUID = 1L;
private JCheckBox zeroPadSud;
public SudSettingsPanel() {
@ -76,8 +93,7 @@ public class SudAudioSettingsPane implements PamAudioSettingsPane {
c.gridwidth = 1;
zeroPadSud = new JCheckBox("Zero pad sud files");
zeroPadSud.setToolTipText("Zero pad sud files. Zero padding replaces sections of sud files \n"
+ "with corrupt or no data with zeros. This can improve time drift. ");
zeroPadSud.setToolTipText(sudTooltip);
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

View File

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