>{
@Override
public void loadedDataComplete() {
- System.out.println("EXPORTER: loaded data complete");
+// System.out.println("EXPORTER: loaded data complete");
//force the exporter so save any renaming data units in the buffer
exporter.exportDataUnit(null, true);
exporter.close();
diff --git a/src/export/wavExport/WavFileExportManager.java b/src/export/wavExport/WavDetExport.java
similarity index 69%
rename from src/export/wavExport/WavFileExportManager.java
rename to src/export/wavExport/WavDetExport.java
index f245d68a..0724c725 100644
--- a/src/export/wavExport/WavFileExportManager.java
+++ b/src/export/wavExport/WavDetExport.java
@@ -1,6 +1,5 @@
package export.wavExport;
-import java.awt.Component;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
@@ -20,46 +19,36 @@ import PamguardMVC.PamObservable;
import PamguardMVC.PamObserver;
import PamguardMVC.PamObserverAdapter;
import PamguardMVC.PamRawDataBlock;
-import PamguardMVC.RawDataHolder;
import PamguardMVC.dataOffline.OfflineDataLoading;
import dataMap.OfflineDataMapPoint;
import detectiongrouplocaliser.DetectionGroupSummary;
-import export.PamDataUnitExporter;
-import javafx.scene.layout.Pane;
import wavFiles.Wav16AudioFormat;
import wavFiles.WavFileWriter;
-/**
- * Manages .wav file writing based on what type of data unit is selected and whether raw data is available.
- *
- * There are two primary use cases;
- *
- * 1) Order raw data from an overlay mark and save as a wav file
- *
- * 2) Save a list of data units to wav files - either a single file with zero pads, a concatonated file or seperate files.
- *
- * @author Jamie Macaulay
- *
- */
-public class WavFileExportManager implements PamDataUnitExporter {
-
+public class WavDetExport {
+
/**
* Successful writing of .wav file.
*/
- public static final int SUCCESS_WAV=0;
+// public static final int SUCCESS_WAV=0;
/**
* Successful writing of .wav file from data contained in detections.
*/
- public static final int SUCCESS_DET_WAV=1;
+// public static final int SUCCESS_DET_WAV=1;
/**
* General failure in wav file writing
*/
- public static final int FAILURE_WAV=2;
+// public static final int FAILURE_WAV=2;
- public static final int LOADING_WAV=2;
+// public static final int LOADING_WAV=2;
+
+ /**
+ * The maximum allowed size
+ */
+ private static final double MAX_ZEROPAD_SIZE_MEGABYTES = 1024; //MB
/**
* The default path to write files to
@@ -80,7 +69,7 @@ public class WavFileExportManager implements PamDataUnitExporter {
private WavOptionsPanel wavOptionsPanel;
- public WavFileExportManager() {
+ public WavDetExport() {
wavDataUnitExports.add(new RawHolderWavExport());
defaultPath=FileSystemView.getFileSystemView().getDefaultDirectory().getPath();
@@ -179,7 +168,7 @@ public class WavFileExportManager implements PamDataUnitExporter {
* @param selectedIndex - the currently selected data unit.
* @param mark - overlay mark.
*/
- public int dataUnits2Wav(DetectionGroupSummary foundDataUnits, int selectedIndex, OverlayMark mark) {
+ public int writeOverlayMarkWav(DetectionGroupSummary foundDataUnits, int selectedIndex, OverlayMark mark) {
System.out.println("Data units 2 wav");
//this order for .wav files.
//if there is a mark then save limits of mark. If there is one data unit then set limits of data units
@@ -224,15 +213,18 @@ public class WavFileExportManager implements PamDataUnitExporter {
int flag=-1;
+ String currentFileS = createFileName(foundDataUnits.getFirstTimeMillis());
+ File file = new File(currentFileS);
+
if (hasAllWavClips) {
- flag = saveDataUnitWav(foundDataUnits);
+ flag = writeDetGroupWav(foundDataUnits, file, false);
}
else if (!hasAllWavClips && haveRawData) {
//no raw data
flag = saveRawWav(start, end, rawDataBlock);
}
else {
- flag = saveDataUnitWav(foundDataUnits);
+ flag = writeDetGroupWav(foundDataUnits, file, false);
}
return flag;
@@ -263,47 +255,129 @@ public class WavFileExportManager implements PamDataUnitExporter {
/**
* Save wav data from a data unit instead of from the raw file store.
* @param foundDataUnits - the list of found data units.
+ * @param currentFile - path to current file to save to.
+ * @param zeroPad - if true will zeroPad detections.
* @return the number of data units that were saved.
*/
- private int saveDataUnitWav(DetectionGroupSummary foundDataUnits) {
- return saveDataUnitWav(foundDataUnits.getDataList());
+ public int writeDetGroupWav(DetectionGroupSummary foundDataUnits, File filename, boolean zeroPad) {
+ return writeDataUnitWav(foundDataUnits.getDataList(), filename, zeroPad);
}
+
/**
- * Save data units which contain raw data to a wav file. Note that this assumed
- * the data units all contain raw data and are in order.
- *
- * @param foundDataUnits - data units containing raw data.
- * @return the number of data units saved - this should be the same as the size
- * of the data unit list.
+ * Save data units which contain raw data to individual wav files within a folder.
+ * @param foundDataUnits - list of data units to save.
+ * @param currentFile - the current folder. If this is a file name the parent directory will be used.
+ * @return the number of data units saved
*/
- private int saveDataUnitWav(List foundDataUnits) {
+ public int writeDataUnitWavs(List foundDataUnits, File currentFile) {
int n=0;
WavFileWriter wavWrite = null;
for (PamDataUnit fnDataUnit: foundDataUnits){
-
- String currentFile = createFileName(fnDataUnit.getTimeMilliseconds());
-
+
AudioFormat audioFormat = new Wav16AudioFormat(fnDataUnit.getParentDataBlock().getSampleRate(), PamUtils.getNumChannels(fnDataUnit.getChannelBitmap()));
- System.out.println("Save detection wav." + foundDataUnits.size());
-
+ String currentFileS = createFileName(fnDataUnit.getTimeMilliseconds());
+
+ //System.out.println("Save detection wav." + foundDataUnits.size());
for (int i=0; i foundDataUnits, File currentFile, boolean zeroPad) {
+ int n=0;
+ WavFileWriter wavWrite = null;
+ PamDataUnit lastfnDataUnit = null;
+
+ if (foundDataUnits==null || foundDataUnits.size()<=0) {
+ return 0;
+ }
+
+ //System.out.println("Save detection wav." + foundDataUnits.size());
+ AudioFormat audioFormat = new Wav16AudioFormat(foundDataUnits.get(0).getParentDataBlock().getSampleRate(), PamUtils.getNumChannels(foundDataUnits.get(0).getChannelBitmap()));
+
+ wavWrite= new WavFileWriter(currentFile.getAbsolutePath(), audioFormat);
+
+ for (PamDataUnit fnDataUnit: foundDataUnits){
+
+ for (int i=0; iMAX_ZEROPAD_SIZE_MEGABYTES) {
+ wavWrite.close();
+ System.err.println(String.format("WavExportManager: A zero padding of %.2f MB was requested. The maximum allowed size is %.2f - "
+ + "the .wav file was closed and any additional data units have not been written %s", size, MAX_ZEROPAD_SIZE_MEGABYTES, currentFile));
+ return n;
+ }
+
+ System.out.println("Append wav. zero pad" + samplesPad);
+
+ wavWrite.append(new double[audioFormat.getChannels()][samplesPad]);
+ }
+
+ //save the wav file of detection
+ if (wavWrite.append(wavDataUnitExports.get(i).getWavClip(fnDataUnit))) {
+ n++;
+ }
+ lastfnDataUnit = fnDataUnit;
+ break;
+ }
+ }
+ }
+
+ wavWrite.close();
+
+
//send a message that the wav file has saved
if (wavWrite!=null && saveCallback!=null) saveCallback.wavSaved(wavWrite.getFileName(), 0);
@@ -340,85 +414,6 @@ public class WavFileExportManager implements PamDataUnitExporter {
}
-
- @Override
- public boolean hasCompatibleUnits(Class dataUnitType) {
-// boolean implementsInterface = Arrays.stream(dataUnitType.getInterfaces()).anyMatch(i -> i == RawDataHolder.class);
- if ( RawDataHolder.class.isAssignableFrom(dataUnitType)) return true;
- return false;
- }
-
-
-
- @Override
- public boolean exportData(File fileName,
- List dataUnits, boolean append) {
-
-
- //should we zeropad?
- saveDataUnitWav(dataUnits);
-
- return true;
-
-
- }
-
-
-
- @Override
- public String getFileExtension() {
- return "wav";
- }
-
-
-
- @Override
- public String getIconString() {
- return "mdi2f-file-music";
- }
-
-
-
- @Override
- public String getName() {
- return "raw sound";
- }
-
-
-
- @Override
- public void close() {
- // TODO Auto-generated method stub
- }
-
-
-
- @Override
- public boolean isNeedsNewFile() {
- return false;
- }
-
-
-
- @Override
- public Component getOptionsPanel() {
- if (this.wavOptionsPanel==null) {
- this.wavOptionsPanel = new WavOptionsPanel();
- }
- return wavOptionsPanel;
- }
-
-
-
- @Override
- public Pane getOptionsPane() {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-
-
/**
* Observes incoming raw data and saves to a wav file
*
@@ -528,70 +523,4 @@ public class WavFileExportManager implements PamDataUnitExporter {
}
- // hello(){
- //
- //
- // if (mark==null) {
- // start= foundDataUnits.getFirstTimeMillis();
- // end= foundDataUnits.getLastTimeMillis();
- // }
- //
- // File folder = new File(currentFolder);
- //
- // //save a .wav file clip.
- // if (!folder.exists()){
- // if (!folder.mkdir()){
- // //TODO- warning message.
- // return;
- // }
- // }
- //
- // String currentPath = PamCalendar.formatFileDateTime();
- // //add data types to the filen,ae
- // for (int i=0 ;i
+ * There are two primary use cases;
+ * 1) Order raw data from an overlay mark and save as a wav file
+ * 2) Save a list of data units to wav files - either a single file with zero
+ * pads, a concatenated file or separate files.
+ *
+ * @author Jamie Macaulay
+ *
+ */
+public class WavDetExportManager implements PamDataUnitExporter {
+
+ /**
+ * Options for exporting wav files.
+ */
+ private WavExportOptions wavFileoptions = new WavExportOptions();
+
+ /**
+ * Settings panel for wav file exporting
+ */
+ private WavOptionsPanel wavOptionsPanel;
+
+ /**
+ * Exporter of wav files.
+ */
+ private WavDetExport wavDetExport = new WavDetExport();
+
+ public WavDetExportManager() {
+
+ }
+
+ @Override
+ public boolean hasCompatibleUnits(Class dataUnitType) {
+ // boolean implementsInterface = Arrays.stream(dataUnitType.getInterfaces()).anyMatch(i -> i == RawDataHolder.class);
+ if ( RawDataHolder.class.isAssignableFrom(dataUnitType)) return true;
+ return false;
+ }
+
+
+
+ @Override
+ public boolean exportData(File fileName,
+ List dataUnits, boolean append) {
+
+ //make sure we have the latest options.
+ if (wavOptionsPanel!=null) {
+ //means the options panel has been opened.
+ wavFileoptions = wavOptionsPanel.getParams(wavFileoptions);
+ }
+
+ //should we zeropad?
+ //saveDataUnitWav(dataUnits);
+ switch (wavFileoptions.wavSaveChoice) {
+ case WavExportOptions.SAVEWAV_CONCAT:
+ wavDetExport.writeDataUnitWav(dataUnits, fileName, false);
+ break;
+ case WavExportOptions.SAVEWAV_INDIVIDUAL:
+ //here the filename will not be used but the parent folder will be used instead to write
+ //lots of wav files to.
+ wavDetExport.writeDataUnitWavs(dataUnits, fileName);
+ break;
+ case WavExportOptions.SAVEWAV_ZERO_PAD:
+ wavDetExport.writeDataUnitWav(dataUnits, fileName, true);
+ break;
+ }
+
+ return true;
+ }
+
+
+
+ @Override
+ public String getFileExtension() {
+ return "wav";
+ }
+
+
+
+ @Override
+ public String getIconString() {
+ return "mdi2f-file-music";
+ }
+
+
+
+ @Override
+ public String getName() {
+ return "raw sound";
+ }
+
+
+
+ @Override
+ public void close() {
+ // TODO Auto-generated method stub
+ }
+
+
+
+ @Override
+ public boolean isNeedsNewFile() {
+ return false;
+ }
+
+
+
+ @Override
+ public Component getOptionsPanel() {
+ if (this.wavOptionsPanel==null) {
+ this.wavOptionsPanel = new WavOptionsPanel();
+ }
+ wavOptionsPanel.setParams(this.wavFileoptions) ;
+ return wavOptionsPanel;
+ }
+
+
+
+ @Override
+ public Pane getOptionsPane() {
+ // TODO - make FX version of settings.
+ return null;
+ }
+
+
+
+
+
+ // hello(){
+ //
+ //
+ // if (mark==null) {
+ // start= foundDataUnits.getFirstTimeMillis();
+ // end= foundDataUnits.getLastTimeMillis();
+ // }
+ //
+ // File folder = new File(currentFolder);
+ //
+ // //save a .wav file clip.
+ // if (!folder.exists()){
+ // if (!folder.mkdir()){
+ // //TODO- warning message.
+ // return;
+ // }
+ // }
+ //
+ // String currentPath = PamCalendar.formatFileDateTime();
+ // //add data types to the filen,ae
+ // for (int i=0 ;i{
-// mainTabPane.layout(); //Don't need this
-// });
-
+ // showButton.prefWidthProperty().addListener((listener)->{
+ // mainTabPane.layout(); //Don't need this
+ // });
+
hidingSidePane.getTimeLineShow().setOnFinished((value)->{
showButtonRight.setPrefWidth(1);
showButtonRight.setVisible(false);
@@ -203,55 +203,55 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
PamButton closeButtonLeft=hidingSidePane.getHideButton();
closeButtonLeft.getStyleClass().add("close-button-right-trans");
-// closeButtonLeft.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.CHEVRON_RIGHT, Color.DARKGRAY.darker(), PamGuiManagerFX.iconSize));
+ // closeButtonLeft.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.CHEVRON_RIGHT, Color.DARKGRAY.darker(), PamGuiManagerFX.iconSize));
closeButtonLeft.prefHeightProperty().bind(mainTabPane.getHeaderHeightProperty());
-
+
//add hiding pane to main pane.
layout.setRight(hidingSidePane);
-
+
/**create settings pane. This allows access to primary PAMGUARD settings.**/
settingsPane=new PamSettingsMenuPane();
settingsPane.setPrefWidth(250);
hidingPaneLeft=new HidingPane(Side.LEFT, settingsPane, this, false);
hidingPaneLeft.showHidePane(false);
-
+
hidingPaneLeft.getStylesheets().addAll(pamGuiManagerFX.getPamSettingsCSS());
PamButton showButtonLeft=hidingPaneLeft.getShowButton();
-// showButtonLeft.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.BARS, Color.LIGHTGRAY, PamGuiManagerFX.iconSize));
+ // showButtonLeft.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.BARS, Color.LIGHTGRAY, PamGuiManagerFX.iconSize));
showButtonLeft.setGraphic(PamGlyphDude.createPamIcon("mdi2m-menu", Color.LIGHTGRAY, PamGuiManagerFX.iconSize));
showButtonLeft.getStyleClass().add("close-button-right-trans");
showButtonLeft.setStyle(" -fx-background-radius: 0 0 0 0;");
-
+
PamButton closeRightButton=hidingPaneLeft.getHideButton();
closeRightButton.setPrefWidth(40);
closeRightButton.getStyleClass().add("close-button-left-trans");
-// closeRightButton.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.CHEVRON_LEFT, Color.WHITE, PamGuiManagerFX.iconSize));
+ // closeRightButton.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.CHEVRON_LEFT, Color.WHITE, PamGuiManagerFX.iconSize));
closeRightButton.setGraphic(PamGlyphDude.createPamIcon("mdi2c-chevron-left", Color.WHITE, PamGuiManagerFX.iconSize));
closeRightButton.prefHeightProperty().bind(mainTabPane.getHeaderHeightProperty());
-
+
//add hiding pane to main pane.
layout.setLeft(hidingPaneLeft);
-
-// //Create a button which sits at end of tab pane
-// settingsButton = new PamButton();
-// settingsButton.setMinWidth(Control.USE_PREF_SIZE);
-// settingsButton.setGraphic(Glyph.create("FontAwesome|BARS").size(22).color(Color.DARKGREY.darker()));
-// settingsButton.getStyleClass().add("transparent-button");
-//// settingsButton.setPadding(new Insets(0,10,0,10));
-// settingsButton.setOnAction(e -> {
-// //TODO-open settings menu
-// });
+
+ // //Create a button which sits at end of tab pane
+ // settingsButton = new PamButton();
+ // settingsButton.setMinWidth(Control.USE_PREF_SIZE);
+ // settingsButton.setGraphic(Glyph.create("FontAwesome|BARS").size(22).color(Color.DARKGREY.darker()));
+ // settingsButton.getStyleClass().add("transparent-button");
+ //// settingsButton.setPadding(new Insets(0,10,0,10));
+ // settingsButton.setOnAction(e -> {
+ // //TODO-open settings menu
+ // });
mainTabPane.setTabEndRegion(showButtonRight);
mainTabPane.setTabStartRegion(showButtonLeft);
-// mainTabPane.getStyleClass().add(Styles.TABS_FLOATING);
+ // mainTabPane.getStyleClass().add(Styles.TABS_FLOATING);
mainTabPane.getAddTabButton().setOnAction((value)->{
- addPamTab(new TabInfo("Display " + (this.getNumTabs()+1)), null ,true);
- mainTabPane.layout();
+ addPamTab(new TabInfo("Display " + (this.getNumTabs()+1)), null ,true);
+ mainTabPane.layout();
});
-
+
//now have a holder - add the loading pane.
/**create left hiding pane**/
loadPane=new PamLoadingPane(this.pamGuiManagerFX);
@@ -259,14 +259,14 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
hidingLoadPane.setPrefHeight(110);
hidingLoadPane.removeHideButton();
hidingLoadPane.showHidePane(false);
-
+
PamBorderPane layoutHolder=new PamBorderPane(layout);
layoutHolder.setTop(hidingLoadPane);
- return layoutHolder;
-
+ return layoutHolder;
+
}
-
+
/**
* Get the load pane for the PamGuiFX- shows loading data and other status updates.
* @return the PamLoadingf Pane
@@ -281,79 +281,79 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
public void show(){
stage.show();
}
-
-
+
+
/**
* Convenience function to add a closable tab to the display with a new UserDisplayNodeFX.
* @param name- tab name.
* @param content- content to add to the tab. Can be null;
*/
public PamGuiTabFX addPamTab(TabInfo tabInfo, UserDisplayNodeFX content, boolean detachable ){
- //create holder pane and add to tab
+ //create holder pane and add to tab
PamGuiTabFX newTab = new PamGuiTabFX(tabInfo, this);
-
+
newTab.setToolbar(new ToolBarPane(newTab));
-
+
//static displays have non closable tabs and non resizable displays
- if (content!=null){
- newTab.setClosable(!content.isStaticDisplay());
- newTab.setResizableDisplays(!content.isStaticDisplay());
+ if (content!=null){
+ newTab.setClosable(!content.isStaticDisplay());
+ newTab.setResizableDisplays(!content.isStaticDisplay());
- if (content.isStaticDisplay()){
- //if static, then add to center.
- newTab.getContentHolder().setCenter(content.getNode());
- }
- else{
- //add content- will not add and return null if content is null
- newTab.addInternalPane(content);
- }
- }
-
- newTab.setOnClosed((action)->{
- //when a tab is closer.
- for (int i=0; i{
+ //when a tab is closer.
+ for (int i=0; i
mainTabPane.getTabs().addAll(pamGuiTabFXs);
}
-
+
/**
* Get the number of tabs currently open.
* @return the number of tabs.
@@ -391,7 +391,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
public int getNumTabs(){
return mainTabPane.getTabs().size();
}
-
+
/**
* Get a tab
* @param i - tab index
@@ -400,16 +400,16 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
public PamGuiTabFX getTab(int i){
return (PamGuiTabFX) mainTabPane.getTabs().get(i);
}
-
+
/**
* Select a tab
* @param j - index
*/
public void selectTab(int j) {
this.mainTabPane.getSelectionModel().select(j);
-
+
}
-
+
/**
* Create the tool bar pane. The top of each tab content node contains a tool
@@ -423,24 +423,24 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
*
*/
public class ToolBarPane extends PamBorderPane {
-
-
+
+
/**
* Record/batch process button. In real time starts/stops data acquisition. In viewer mode
* opens the batch run manager to allow batch processing of data e.g. reclassifying clicks.
*/
private PamButton recordButton;
-
+
/**
*Play/pause button. Plays back sound in real time/viewer mode.
*/
private PamButton playButton;
-
+
/**
* Holds all extra controls in the toolbar.
*/
private PamHBox centerHBox;
-
+
/**
* Height of the toolbar.
*/
@@ -466,59 +466,76 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
* Button to select what autosort option for windows.
*/
private MenuButton autoSortChoice;
-
+
public ToolBarPane(PamGuiTabFX pamGuiTab){
super();
-
- this.pamGuiTab=pamGuiTab;
-
- //create record and play buttons.
- PamHBox playControls=new PamHBox();
- recordButton=new PamButton();
-// recordButton.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.CIRCLE, Color.LIMEGREEN, PamGuiManagerFX.iconSize));
- recordButton.setGraphic(PamGlyphDude.createPamIcon("mdi2r-record-circle", Color.RED, PamGuiManagerFX.iconSize));
- recordButton.getStyleClass().add("transparent-button");
-
- //recordButton.setStyle(" -fx-background-radius: 50;");
-
- recordButton.setOnAction((action)->{
- if (PamController.getInstance().getPamStatus()==PamController.PAM_RUNNING){
- PamController.getInstance().pamStop();
- pamGuiManagerFX.setPamRunning(false);
- }
- else {
- PamController.getInstance().pamStart();
- pamGuiManagerFX.setPamRunning(true);
-
- }
- });
- playButton=new PamButton();
-// playButton.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.PLAY, Color.BLACK, PamGuiManagerFX.iconSize));
- playButton.setGraphic(PamGlyphDude.createPamIcon("mdi2p-play", Color.BLACK, PamGuiManagerFX.iconSize));
- playButton.getStyleClass().add("transparent-button");
- //playButton.setStyle(" -fx-background-radius: 50;");
- playButton.setOnAction((action)->{
- //TODO
- //start pamguard
- //PamController.getInstance().pamStart();
- });
-
-
- playControls.getChildren().addAll(recordButton,playButton);
- playControls.setSpacing(10);
- playControls.setPadding(new Insets(0,10,0,20));
-// playControls.getStyleClass().add("pane-opaque");
- playControls.setPrefHeight(prefHeight);
- playControls.setAlignment(Pos.CENTER);
-
+ this.pamGuiTab=pamGuiTab;
+
+ PamHBox analysisControls=new PamHBox();
+ analysisControls.setSpacing(10);
+ analysisControls.setPadding(new Insets(0,10,0,20));
+ // playControls.getStyleClass().add("pane-opaque");
+ analysisControls.setPrefHeight(prefHeight);
+ analysisControls.setAlignment(Pos.CENTER);
+
+ if (PamController.getInstance().getRunMode() == PamController.RUN_PAMVIEW) {
+
+ //in PMAGUard viewer mode we want a reporcess button
+
+ PamButton reProcessButton=new PamButton("Reprocess...");
+ reProcessButton.setGraphic(PamGlyphDude.createPamIcon("mdi2c-cog-transfer", PamGuiManagerFX.iconSize));
+ reProcessButton.setOnAction((action->{
+
+ }));
+
+
+ analysisControls.getChildren().addAll(reProcessButton);
+
+ }
+ else {
+ //real time mode
+ //create record and play buttons.
+ recordButton=new PamButton();
+ // recordButton.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.CIRCLE, Color.LIMEGREEN, PamGuiManagerFX.iconSize));
+ recordButton.setGraphic(PamGlyphDude.createPamIcon("mdi2r-record-circle", Color.RED, PamGuiManagerFX.iconSize));
+ recordButton.getStyleClass().add("transparent-button");
+ recordButton.setStyle("-fx-padding: 0 10 0 10;");
+ //recordButton.setStyle(" -fx-background-radius: 50;");
+
+ recordButton.setOnAction((action)->{
+ if (PamController.getInstance().getPamStatus()==PamController.PAM_RUNNING){
+ PamController.getInstance().pamStop();
+ pamGuiManagerFX.setPamRunning(false);
+ }
+ else {
+ PamController.getInstance().pamStart();
+ pamGuiManagerFX.setPamRunning(true);
+ }
+ });
+
+ // playButton=new PamButton();
+ //// playButton.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.PLAY, Color.BLACK, PamGuiManagerFX.iconSize));
+ // playButton.setGraphic(PamGlyphDude.createPamIcon("mdi2p-play", Color.BLACK, PamGuiManagerFX.iconSize));
+ // playButton.getStyleClass().add("transparent-button");
+ // //playButton.setStyle(" -fx-background-radius: 50;");
+ // playButton.setOnAction((action)->{
+ // //TODO
+ // //start pamguard
+ // //PamController.getInstance().pamStart();
+ // });
+
+ analysisControls.getChildren().addAll(recordButton);
+
+ }
+
//create window editing button. This holds a toggle to edit windows and options.
rightHBox=new PamHBox();
rightHBox.setAlignment(Pos.CENTER_LEFT);
rightHBox.setPadding(new Insets(0,10,0,20));
rightHBox.setSpacing(5);
-// rightHBox.getStyleClass().add("pane-opaque");
-
+ // rightHBox.getStyleClass().add("pane-opaque");
+
editWindows=new ToggleSwitch("Resize");
//HACK,
editWindows.setPadding(new Insets(8,0,0,0));
@@ -527,56 +544,56 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
boolean editable=!pamGuiTab.getEditable();
pamGuiTab.setPanesEditable(editable);
});
-
+
//add a choice box to allow users to automatically resize windows.
autoSortChoice=new MenuButton();
autoSortChoice.getStyleClass().add("transparent-button");
-// autoSortChoice.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.ELLIPSIS_V,
+ // autoSortChoice.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.ELLIPSIS_V,
autoSortChoice.setGraphic(PamGlyphDude.createPamIcon("mdi2d-dots-vertical",
Color.DARKGRAY, PamGuiManagerFX.iconSize));
-
+
MenuItem tile=new MenuItem("Tile");
tile.setOnAction((action)->{
pamGuiTab.autoSortPanes(PamGuiTabFX.SORT_TILE);
});
-
+
MenuItem vertical=new MenuItem("Horizontal");
vertical.setOnAction((action)->{
pamGuiTab.autoSortPanes(PamGuiTabFX.SORT_HORIZONTAL);
});
-
+
MenuItem horizontal=new MenuItem("Vertical");
horizontal.setOnAction((action)->{
pamGuiTab.autoSortPanes(PamGuiTabFX.SORT_VERTICAL);
});
-
+
autoSortChoice.getItems().addAll(tile, vertical, horizontal);
-
+
rightHBox.getChildren().addAll(editWindows, autoSortChoice);
-
+
//create content hboc for extra controls.
centerHBox=new PamHBox();
centerHBox.setSpacing(10);
//need to set this style to prevent the pane form being transparent.
//centerHBox.getStyleClass().add("pane-opaque");
centerHBox.setPrefHeight(prefHeight);
-
+
this.setCenter(centerHBox);
- this.setLeft(playControls);
+ this.setLeft(analysisControls);
this.setRight(rightHBox);
-
+
this.setPrefHeight(prefHeight);
this.getStyleClass().add("pane-opaque");
//this.setPadding(new Insets(0,0,0,0));
-
+
this.toFront();
}
-
-
+
+
/**
* Get the content HBox. This holds any extra controls in the top tool bar.
* @return HBox to add extra toolbar content to.
@@ -584,7 +601,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
public PamHBox getCenterHBox(){
return centerHBox;
}
-
+
/**
* Add a node to the content area of the toolbar.
* @param node - node to add.
@@ -592,7 +609,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
public void addToolbarNode(Node node){
centerHBox.getChildren().add(node);
}
-
+
/**
* Get the button which starts and stops PAMGUARD.
* @return the button.
@@ -600,7 +617,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
public Button getRecordButton(){
return recordButton;
}
-
+
/**
* Get the HBox on the right hand side of the toolbar.
* @return hbox on right hand side of display.
@@ -616,7 +633,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
/**
- * Show the controls which allows manula resizing of the pane.
+ * Show the controls which allows manual resizing of the pane.
* @param resize.
*/
public void showResizableControl(boolean resize) {
@@ -627,7 +644,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
}
}
-
+
/**
* Get all record buttons from the different toolbars in this stage.
* @return list of record buttons.
@@ -640,7 +657,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
}
return buttons;
}
-
+
/**
* Remove an internal pane if it is contained within any tabs within the PamGuiFX
* @param removeNode - remove the pane if it contains this node.
@@ -651,7 +668,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
tabs.get(i).removeInternalPane(removeNode);
}
}
-
+
/**
* Show the PamLoadPnae- this shows the pane that contains progress bars for loading data.
* @param show - true to show pane.
@@ -676,13 +693,13 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
* @param pamTaskUpdate - information on a thread which s currently doing some work.
*/
public void notifyLoadProgress(PamTaskUpdate pamTaskUpdate) {
- Platform.runLater (() -> this.loadPane.updateLoadPane(pamTaskUpdate));
+ Platform.runLater (() -> this.loadPane.updateLoadPane(pamTaskUpdate));
}
@Override
public void pamStarted() {
this.pamGuiManagerFX.pamStarted();
-
+
}
@Override
@@ -693,19 +710,19 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
@Override
public void modelChanged(int changeType) {
// TODO Auto-generated method stub
-
+
}
@Override
public void addControlledUnit(PamControlledUnit unit) {
this.pamGuiManagerFX.addControlledUnit(unit);
-
+
}
@Override
public void removeControlledUnit(PamControlledUnit unit) {
this.pamGuiManagerFX.removeControlledUnit(unit);
-
+
}
@Override
@@ -716,7 +733,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
@Override
public void setTitle(String title) {
// TODO Auto-generated method stub
-
+
}
@Override
@@ -733,7 +750,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
@Override
public void enableGUIControl(boolean enable) {
// TODO Auto-generated method stub
-
+
}
/**
@@ -769,7 +786,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
public PamVBox getSidePane() {
return sidePaneContent;
}
-
+
/**
* Show the side pane. The side pane holds extra quick access
* controls for modules.
@@ -778,7 +795,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
public void showSidePane(boolean show) {
this.hidingSidePane.showHidePane(show);
}
-
+
/**
* Rename a tab at a selected index.
* @param selectedItem - the new name
diff --git a/src/pamViewFX/PamLauncherPane.java b/src/pamViewFX/PamLauncherPane.java
index 60f3f4c4..622d0183 100644
--- a/src/pamViewFX/PamLauncherPane.java
+++ b/src/pamViewFX/PamLauncherPane.java
@@ -1,15 +1,9 @@
package pamViewFX;
import java.net.MalformedURLException;
-import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
-import atlantafx.base.controls.ToggleSwitch;
-import atlantafx.base.theme.PrimerDark;
-import atlantafx.base.theme.PrimerLight;
-import javafx.application.Application;
-import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.ContentDisplay;
@@ -96,7 +90,16 @@ public class PamLauncherPane extends PamBorderPane {
// this.getStylesheets().add(getClass().getResource(primerPAMGuard).toExternalForm());
// this.getStylesheets().add(getClass().getResource(new PrimerDark().getUserAgentStylesheet()).toExternalForm());
PamStylesManagerFX.getPamStylesManagerFX().setCurStyle(new PamDefaultStyle());
-
+ }
+
+ private void setStyle(boolean PAMGuardFX) {
+ this.getStylesheets().clear();
+
+ if (PAMGuardFX) {
+ PamStylesManagerFX.getPamStylesManagerFX().setCurStyle(new PamAtlantaStyle());
+ this.getStylesheets().addAll(PamStylesManagerFX.getPamStylesManagerFX().getCurStyle().getDialogCSS());
+ this.setStyle("-fx-background-color: -fx-darkbackground");
+ }
}
diff --git a/src/pamViewFX/PamSettingsMenuPane.java b/src/pamViewFX/PamSettingsMenuPane.java
index 21d6abb3..f7ed6271 100644
--- a/src/pamViewFX/PamSettingsMenuPane.java
+++ b/src/pamViewFX/PamSettingsMenuPane.java
@@ -42,7 +42,6 @@ import javafx.scene.control.ToggleButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.Priority;
-import javafx.scene.paint.Color;
/**
* Pane which holds settings menu. All primary settings are accessed from this pane which sits in a hiding pane to the right
diff --git a/src/pamViewFX/fxStyles/PamAtlantaStyle.java b/src/pamViewFX/fxStyles/PamAtlantaStyle.java
index 892558d9..a1aba825 100644
--- a/src/pamViewFX/fxStyles/PamAtlantaStyle.java
+++ b/src/pamViewFX/fxStyles/PamAtlantaStyle.java
@@ -4,6 +4,8 @@ import java.util.ArrayList;
import PamView.ColourScheme;
import PamView.PamColors;
+import atlantafx.base.theme.CupertinoDark;
+import atlantafx.base.theme.CupertinoLight;
import atlantafx.base.theme.PrimerDark;
import atlantafx.base.theme.PrimerLight;
@@ -53,6 +55,7 @@ public class PamAtlantaStyle extends PamDefaultStyle {
// private String guiCSS = new NordDark().getUserAgentStylesheet();
// protected String primerlight = "/Resources/css/primer-light.css";
protected String primerlight = new PrimerLight().getUserAgentStylesheet();
+// protected String primerlight = new CupertinoLight().getUserAgentStylesheet();
/**
* Relative location of the CSS style sheet to be used for the Pamguard standard
@@ -62,6 +65,7 @@ public class PamAtlantaStyle extends PamDefaultStyle {
// private String dialogCSS = new PrimerDark().getUserAgentStylesheet();
// protected String primerdark = "/Resources/css/primer-dark.css";
protected String primerdark = new PrimerDark().getUserAgentStylesheet();
+// protected String primerdark = new CupertinoDark().getUserAgentStylesheet();
/**
diff --git a/src/test/rawDeepLearningClassifier/ClickDLTest.java b/src/test/rawDeepLearningClassifier/ClickDLTest.java
index 0097cf1b..5d3d730b 100644
--- a/src/test/rawDeepLearningClassifier/ClickDLTest.java
+++ b/src/test/rawDeepLearningClassifier/ClickDLTest.java
@@ -7,6 +7,7 @@ import java.util.ArrayList;
import org.jamdev.jdl4pam.transforms.DLTransformsFactory;
import org.jamdev.jdl4pam.transforms.DLTransfromParams;
import org.jamdev.jdl4pam.transforms.SimpleTransformParams;
+import org.jamdev.jpamutils.wavFiles.AudioData;
import org.jamdev.jdl4pam.transforms.DLTransform.DLTransformType;
import org.junit.jupiter.api.Test;
@@ -31,7 +32,7 @@ public class ClickDLTest {
System.out.println("*****Click classification Deep Learning C*****");
//relative paths to the resource folders.
- String relModelPath = "./src/test/resources/rawDeepLearningClassifier/Generic/risso_click/updated_model/saved_model.pb";
+ String relModelPath = "./src/test/resources/rawDeepLearningClassifier/Generic/risso_click/uniform_model/saved_model.pb";
String clicksPath = "./src/test/resources/rawDeepLearningClassifier/Generic/risso_click/clicks.mat";
Path path = Paths.get(relModelPath);
@@ -45,14 +46,17 @@ public class ClickDLTest {
//create the transforms.
ArrayList dlTransformParamsArr = new ArrayList();
- dlTransformParamsArr.add(new SimpleTransformParams(DLTransformType.NORMALISE_WAV));
-
+ //waveform transforms.
+ dlTransformParamsArr.add(new SimpleTransformParams(DLTransformType.DECIMATE_SCIPY, 248000.));
+ dlTransformParamsArr.add(new SimpleTransformParams(DLTransformType.PEAK_TRIM, 128, 1));
+ dlTransformParamsArr.add(new SimpleTransformParams(DLTransformType.NORMALISE_WAV, 0., 1, AudioData.ZSCORE));
+
genericModelParams.dlTransfromParams = dlTransformParamsArr;
genericModelParams.dlTransfroms = DLTransformsFactory.makeDLTransforms((ArrayList)genericModelParams.dlTransfromParams);
//create the clicks.
path = Paths.get(clicksPath);
- ArrayList clicks = importClicks(path.toAbsolutePath().normalize().toString(), SAMPLE_RATE);
+ ArrayList clicks = importClicks(path.toAbsolutePath().normalize().toString(), SAMPLE_RATE);
//prep the model
genericModelWorker.prepModel(genericModelParams, null);
@@ -61,20 +65,22 @@ public class ClickDLTest {
ArrayList groupedData = new ArrayList();
- int i=0;
+ for (int i=0; i<1; i++) {
- float prediction = 0;
-
- groupedData.add(clicks.get(i)); //TODO for loop
-
- System.out.println("Waveform input: " + groupedData.get(i).getRawData().length + " " + groupedData.get(i).getRawData()[0].length);
+ float prediction = (float) clicks.get(i).getPrediction()[0];
+
+ groupedData.add(clicks.get(i)); //TODO for loop
+
+ //System.out.println("Waveform input: " + groupedData.get(i).getRawData().length + " " + groupedData.get(i).getRawData()[0].length);
+
+ ArrayList genericPrediction = genericModelWorker.runModel(groupedData,SAMPLE_RATE, 0);
+
+ float[] output = genericPrediction.get(i).getPrediction();
+
+ System.out.println(String.format("Click %d Predicted output: %.2f true output: %.2f passed: %b", clicks.get(i).getUID(),
+ output[0], prediction, output[0]>prediction*0.9 && output[0] genericPrediction = genericModelWorker.runModel(groupedData,SAMPLE_RATE, 0);
-
- float[] output = genericPrediction.get(0).getPrediction();
-
- System.out.println(String.format("Click %d Predicted output: %.2f true output: %.2f passed: %b", clicks.get(i).getUID(),
- output[0], prediction, output[0]>prediction*0.9 && output[0] importClicks(String filePath, float sR) {
+ public static ArrayList importClicks(String filePath, float sR) {
try {
Mat5File mfr = Mat5.readFromFile(filePath);
@@ -91,9 +97,9 @@ public class ClickDLTest {
Struct mlArrayRetrived = mfr.getStruct( "clickpreds" );
int numClicks= mlArrayRetrived.getNumCols();
- ArrayList clicks = new ArrayList(numClicks);
+ ArrayList clicks = new ArrayList(numClicks);
- GroupedRawData clickData;
+ PredGroupedRawData clickData;
for (int i=0; i