Updates to deep learning and PAMGuardFX GUI

This commit is contained in:
Jamie Mac 2024-08-08 14:07:16 +01:00
parent fc4c9495cf
commit f5f448cb88
17 changed files with 202 additions and 92 deletions

View File

@ -309,7 +309,7 @@
<dependency>
<groupId>io.github.macster110</groupId>
<artifactId>jdl4pam</artifactId>
<version>0.0.99b</version>
<version>0.0.99d</version>
</dependency>
<!-- https://mvnrepository.com/artifact/gov.nist.math/jama -->

View File

@ -55,16 +55,6 @@ import pamguard.GlobalArguments;
//import org.w3c.dom.Node;
//import com.thoughtworks.xstream.XStream;
import java.io.StringWriter;
//import javax.xml.transform.OutputKeys;
//import javax.xml.transform.Transformer;
//import javax.xml.transform.TransformerException;
@ -73,13 +63,6 @@ import java.io.StringWriter;
//import javax.xml.transform.stream.StreamResult;
//import sun.jdbc.odbc.OdbcDef;
import tipOfTheDay.TipOfTheDayManager;
//import javax.swing.filechooser.FileFilter;
@ -90,11 +73,7 @@ import PamController.settings.SettingsNameChanger;
import PamUtils.PamCalendar;
import PamUtils.PamFileChooser;
import PamUtils.PamFileFilter;
import PamUtils.Splash;
import PamView.PamGui;
import PamView.dialog.warn.WarnOnce;
import amplifier.AmpDialog;
import amplifier.AmpParameters;
//import PamUtils.PamFileFilter;
@ -172,6 +151,7 @@ public class PamSettingManager {
static public final String fileEnd = "psf";
static public final String fileEndx = "psfx";
static public final String fileEndXML = "psfxml";
private static boolean saveAsPSFX = true;
static public String getCurrentSettingsFileEnd() {
@ -220,11 +200,12 @@ public class PamSettingManager {
/**
* Save settings to a psf file
*/
static private final int SAVE_PSF = 0x1;
static public final int SAVE_PSF = 0x1;
/**
* Save settings to database tables (if available).
*/
static private final int SAVE_DATABASE = 0x2;
static public final int SAVE_DATABASE = 0x2;
/**
* running in remote mode, default normal
@ -800,7 +781,6 @@ public class PamSettingManager {
/*
* then save it to a single XML file
*/
//XML file test
objectToXMLFile(pamSettingsList,file);

View File

View File

@ -178,12 +178,13 @@ public class DataMapPaneFX extends PamBorderPane implements UserDisplayNodeFX {
* Called from ScalePanel when anything
* to do with scaling changes.
*/
@Deprecated
public void scaleChanged() {
if (scalePane == null || scrollingDataPanel == null) {
return;
}
scalePane.getParams(dataMapControl.dataMapParameters);
scrollingDataPanel.scaleChange();
//scrollingDataPanel.scaleChange();
}
@Override

View File

@ -1,6 +1,5 @@
package dataMap.layoutFX;
import java.awt.Insets;
import java.util.Arrays;
import java.util.Iterator;
@ -159,11 +158,12 @@ public class DataStreamPaneFX extends PamBorderPane {
showButton = new PamButton();
showButton.setStyle("-fx-padding: 0 10 0 10; -fx-border-radius: 0 0 0 0; -fx-background-radius: 0 0 0 0;");
showButton.setGraphic(PamGlyphDude.createPamIcon("mdi2c-chevron-down", 18));
showButton.setOnAction((action)->{
this.setCollapsed(!this.isCollapsed());
setButtonGraphic();
});
setButtonGraphic();
pane.setLeft(showButton);
pane.setPrefHeight(PREF_HEADER_HEIGHT);
@ -172,6 +172,18 @@ public class DataStreamPaneFX extends PamBorderPane {
}
private void setButtonGraphic() {
if (this.isCollapsed()) {
showButton.setGraphic(PamGlyphDude.createPamIcon("mdi2c-chevron-down", (int) PREF_HEADER_HEIGHT-2));
}
else {
showButton.setGraphic(PamGlyphDude.createPamIcon("mdi2c-chevron-up", (int) PREF_HEADER_HEIGHT-2));
}
}
/**
* @return the dataGraph
*/

View File

@ -223,6 +223,9 @@ public class ScrollingDataPaneFX extends PamBorderPane {
timeScrollBar.getTextBox().setPrefWidth(100);
timeScrollBar.setPrefHeight(50);
//set this to zero just so that we know if it has been set or not
timeScrollBar.setVisibleAmount(0.);
holder.setCenter(timeScrollBar);
holder.setBottom(timeLabelPane);
@ -388,7 +391,12 @@ public class ScrollingDataPaneFX extends PamBorderPane {
timeScrollBar.setMaxVal(Math.max(dataSeconds, screenSeconds)*1000L);
timeScrollBar.setBlockIncrement(Math.max(1, screenSeconds * 4/5));
// timeScrollBar.setUnitIncrement(Math.max(1, screenSeconds / 20));
timeScrollBar.setVisibleAmount(screenSeconds*1000L);
//there might already have a visible amount in which case we do not wish to change. This is a bit of a hack
//to figure out whether the visible amount has already been set.
if (timeScrollBar.getVisibleAmount()==0) {
timeScrollBar.setVisibleAmount(screenSeconds*1000L);
}
timeScrollBar.setCurrentValue(currentPos);
//now paint the canvas to show the data.
@ -479,13 +487,13 @@ public class ScrollingDataPaneFX extends PamBorderPane {
return dataMapPaneFX;
}
int lastHScaleChoice=-1;
public void scaleChange() {
if (lastHScaleChoice != dataMapControl.dataMapParameters.hScaleChoice) {
lastHScaleChoice = dataMapControl.dataMapParameters.hScaleChoice;
setupScrollBar();
}
this.notifyScrollChange();
}
// int lastHScaleChoice=-1;
// public void scaleChange() {
// if (lastHScaleChoice != dataMapControl.dataMapParameters.hScaleChoice) {
// lastHScaleChoice = dataMapControl.dataMapParameters.hScaleChoice;
// setupScrollBar();
// }
// this.notifyScrollChange();
// }
}

View File

@ -476,9 +476,11 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
PamHBox playControls=new PamHBox();
recordButton=new PamButton();
// recordButton.setGraphic(PamGlyphDude.createPamGlyph(FontAwesomeIcon.CIRCLE, Color.LIMEGREEN, PamGuiManagerFX.iconSize));
recordButton.setGraphic(PamGlyphDude.createPamIcon("mdi2c-checkbox-blank-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.setStyle(" -fx-background-radius: 50;");
recordButton.setOnAction((action)->{
if (PamController.getInstance().getPamStatus()==PamController.PAM_RUNNING){
PamController.getInstance().pamStop();
@ -487,6 +489,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
else {
PamController.getInstance().pamStart();
pamGuiManagerFX.setPamRunning(true);
}
});
@ -494,7 +497,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
// 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.setStyle(" -fx-background-radius: 50;");
playButton.setOnAction((action)->{
//TODO
//start pamguard
@ -505,7 +508,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
playControls.getChildren().addAll(recordButton,playButton);
playControls.setSpacing(10);
playControls.setPadding(new Insets(0,10,0,20));
playControls.getStyleClass().add("pane-opaque");
// playControls.getStyleClass().add("pane-opaque");
playControls.setPrefHeight(prefHeight);
playControls.setAlignment(Pos.CENTER);
@ -514,7 +517,7 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
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,

View File

@ -0,0 +1,24 @@
package pamViewFX;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class PamLauncherFXApp extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("PAMGuard Launcher");
StackPane root = new StackPane();
root.getChildren().add(new PamLauncherPane());
primaryStage.setScene(new Scene(root, 500, 250));
primaryStage.show();
}
}

View File

@ -0,0 +1,9 @@
package pamViewFX;
public class PamLauncherFXAppLauncher {
public static void main(String[] args) {
PamLauncherFXApp.main(args);
}
}

View File

@ -0,0 +1,27 @@
package pamViewFX;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import pamViewFX.fxNodes.PamBorderPane;
import pamViewFX.fxNodes.PamButton;
/**
* Shows a launcher pane which allows a user to open a real time or viewer configuration.
*/
public class PamLauncherPane extends PamBorderPane {
public PamLauncherPane() {
PamButton buttonNormal = new PamButton("Real time");
buttonNormal.setGraphic(buttonNormal);
Image img = new Image("./src/Resources/pamguardIcon.png");
ImageView view = new ImageView(img);
buttonNormal.setGraphic(view);
this.setLeft(buttonNormal);
}
}

View File

@ -2,6 +2,7 @@ package pamViewFX;
import generalDatabase.DBControlUnit;
import java.io.File;
import java.util.Optional;
import binaryFileStorage.BinaryStore;
@ -16,7 +17,8 @@ import PamController.StorageParameters;
import PamController.soundMedium.GlobalMedium;
import PamController.soundMedium.GlobalMedium.SoundMedium;
import PamModel.PamModuleInfo;
import PamView.dialog.warn.WarnOnce;
import PamUtils.PamFileFilter;
import pamViewFX.fxGlyphs.PamGlyphDude;
import pamViewFX.fxNodes.PamButton;
import pamViewFX.fxNodes.PamVBox;
import pamViewFX.fxNodes.PamHBox;
@ -34,10 +36,13 @@ import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.control.Separator;
import javafx.scene.text.TextAlignment;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
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
@ -81,13 +86,16 @@ public class PamSettingsMenuPane extends PamVBox {
PamSettingManager.getInstance().saveSettings(null);
});
styleButton(saveConfig);
saveConfig.setGraphic(PamGlyphDude.createPamIcon("mdi2c-content-save-outline",
PamGuiManagerFX.iconSize));
PamButton saveConfigAs=new PamButton("Save as...");
saveConfigAs.setOnAction((action)->{
PamSettingManager.getInstance().saveSettingsAs(null);
saveSettingsAs();
});
styleButton(saveConfigAs);
saveConfigAs.setGraphic(PamGlyphDude.createPamIcon("mdi2c-content-save-move-outline",
PamGuiManagerFX.iconSize));
//Air or water mode
ToggleButton toggleButton1 = new ToggleButton("Water");
@ -97,6 +105,7 @@ public class PamSettingsMenuPane extends PamVBox {
if (PamController.getInstance().getGlobalMediumManager().getGlobalMediumParameters().currentMedium==SoundMedium.Water) return; //do nothing.
PamController.getInstance().getGlobalMediumManager().setCurrentMedium(SoundMedium.Water);
});
ToggleButton toggleButton2 = new ToggleButton("Air");
toggleButton2.setPrefWidth(60);
@ -114,6 +123,8 @@ public class PamSettingsMenuPane extends PamVBox {
Label mediumLabel = new Label("Sound Medium");
mediumLabel.setAlignment(Pos.CENTER_LEFT);
mediumLabel.setPadding(new Insets(0,0,0,15));
mediumLabel.setGraphic(PamGlyphDude.createPamIcon("mdi2w-waves",
PamGuiManagerFX.iconSize));
//styleButton(mediumLabel);
@ -132,9 +143,13 @@ public class PamSettingsMenuPane extends PamVBox {
PamButton generalSettings=new PamButton("General Settings...");
styleButton(generalSettings);
generalSettings.setGraphic(PamGlyphDude.createPamIcon("mdi2c-cog",
PamGuiManagerFX.iconSize));
MenuButton settings=new MenuButton("Module Settings");
settings.setPopupSide(Side.RIGHT);
settings.setGraphic(PamGlyphDude.createPamIcon("mdi2c-cogs",
PamGuiManagerFX.iconSize));
// settings.setStyle("-fx-background-radius: 0;"
// + " -fx-border-color: transparent; -fx-padding: 0 0 0 0;");
@ -173,6 +188,8 @@ public class PamSettingsMenuPane extends PamVBox {
}
});
styleButton(database);
database.setGraphic(PamGlyphDude.createPamIcon("mdi2d-database",
PamGuiManagerFX.iconSize));
PamButton binaryStorage=new PamButton("Binary Storage...");
binaryStorage.setOnAction((action)->{
@ -193,6 +210,8 @@ public class PamSettingsMenuPane extends PamVBox {
}
});
styleButton(binaryStorage);
binaryStorage.setGraphic(PamGlyphDude.createPamIcon("mdi2f-file-table",
PamGuiManagerFX.iconSize));
PamButton storageManager=new PamButton("Storage Manager...");
storageManager.setOnAction((action)->{
@ -204,24 +223,35 @@ public class PamSettingsMenuPane extends PamVBox {
}
});
styleButton(storageManager);
storageManager.setGraphic(PamGlyphDude.createPamIcon("mdi2d-database-cog",
PamGuiManagerFX.iconSize));
PamButton help=new PamButton("Help...");
styleButton(help);
help.setGraphic(PamGlyphDude.createPamIcon("mdi2h-help-circle-outline",
PamGuiManagerFX.iconSize));
PamButton about=new PamButton("About...");
styleButton(about);
about.setGraphic(PamGlyphDude.createPamIcon("mdi2i-information-outline",
PamGuiManagerFX.iconSize));
// PamButton tip=new PamButton("Tip of the day...");
// styleButton(tip);
PamButton website=new PamButton("Website");
styleButton(website);
website.setGraphic(PamGlyphDude.createPamIcon("mdi2e-earth",
PamGuiManagerFX.iconSize));
PamButton contact=new PamButton("Found a bug?");
styleButton(contact);
contact.setGraphic(PamGlyphDude.createPamIcon("mdi2b-bug",
PamGuiManagerFX.iconSize));
PamButton checkForUpdates=new PamButton("Check for updates");
styleButton(checkForUpdates);
checkForUpdates.setGraphic(PamGlyphDude.createPamIcon("mdi2r-refresh",
PamGuiManagerFX.iconSize));
this.getChildren().addAll(settingsLabel,saveConfig,saveConfigAs, new Separator(), mediumToggleBox, generalSettings, settings, new Separator(),
storageManager, database, binaryStorage, new Separator(), help, checkForUpdates, website, contact, about);
@ -268,4 +298,55 @@ public class PamSettingsMenuPane extends PamVBox {
}
}
/**
* Save settings to a new psf file.
* @param frame parent frame for dialog.
*/
public void saveSettingsAs() {
/*
* get a new file name, set that as the current file
* then write all settings to it.
*/
File file = null;
String currentfileName = PamSettingManager.getInstance().getSettingsFileName();
if (currentfileName != null) {
file =new File(currentfileName);
}
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open Resource File");
fileChooser.getExtensionFilters().addAll(
new ExtensionFilter("PAMGuard settings files", "*.xml", "*.psfx"));
if (currentfileName!=null) {
fileChooser.setInitialDirectory(file);
}
File selectedFile = fileChooser.showOpenDialog(this.getScene().getWindow());
if (selectedFile == null) {
return;
}
selectedFile = PamFileFilter.checkFileEnd(selectedFile, PamSettingManager.getCurrentSettingsFileEnd(), true);
System.out.println("Saving settings to file " + selectedFile.getAbsolutePath());
// Insert the new file into the top of the recent psf file list. Also check
// if we are running remotely, which probably means the user double-clicked on
// a psf to start Pamguard. In that case, change the remotePSF pointer to
// the new file as well
PamSettingManager.getInstance().setDefaultFile(selectedFile.getAbsolutePath());
if (PamSettingManager.remote_psf != null) {
PamSettingManager.remote_psf = selectedFile.getAbsolutePath();
}
PamSettingManager.getInstance().saveSettings(PamSettingManager.SAVE_PSF);
PamController.getInstance().getGuiFrameManager().sortFrameTitles();
}
}

View File

@ -1,39 +0,0 @@
package pamguard;
import java.sql.Connection;
import java.sql.SQLException;
import org.sqlite.SQLiteConfig;
import generalDatabase.sqlite.SqliteSQLTypes;
public class PAMGuard_sqlite {
public static void main(String[] args) {
String dbName = "/Users/jdjm/Desktop/section2_cpod/hyskeir_pamguard.sqlite3";
/*
* Don't use the driver manager, but open from the built in command in
* SQLiteConfig. This will then correctly set the dateformat of the database.
*/
SQLiteConfig config = new SQLiteConfig();
config.setSharedCache(true);
config.enableRecursiveTriggers(true);
config.enableLoadExtension(true);
config.setDateClass(SqliteSQLTypes.dateClass.getValue());
config.setDateStringFormat(SQLiteConfig.DEFAULT_DATE_STRING_FORMAT);
Connection con = null;
try {
con = config.createConnection("jdbc:sqlite:" + dbName);
con.setAutoCommit(false);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Connection: " + con);
}
}

View File

@ -10,10 +10,7 @@ import org.jamdev.jdl4pam.transforms.SimpleTransformParams;
import org.jamdev.jdl4pam.transforms.DLTransform.DLTransformType;
import org.junit.jupiter.api.Test;
import PamDetection.RawDataUnit;
import PamUtils.PamArrayUtils;
import PamguardMVC.RawDataHolder;
import matchedTemplateClassifer.MatchTemplate;
import rawDeepLearningClassifier.dlClassification.genericModel.GenericModelParams;
import rawDeepLearningClassifier.dlClassification.genericModel.GenericModelWorker;
import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction;
@ -25,7 +22,7 @@ import us.hebi.matlab.mat.types.Struct;
public class ClickDLTest {
@Test
public void clickDLTest() {
@ -39,7 +36,6 @@ public class ClickDLTest {
Path path = Paths.get(relModelPath);
GenericModelWorker genericModelWorker = new GenericModelWorker();
GenericModelParams genericModelParams = new GenericModelParams();
@ -54,7 +50,6 @@ public class ClickDLTest {
genericModelParams.dlTransfromParams = dlTransformParamsArr;
genericModelParams.dlTransfroms = DLTransformsFactory.makeDLTransforms((ArrayList<DLTransfromParams>)genericModelParams.dlTransfromParams);
//create the clicks.
path = Paths.get(clicksPath);
ArrayList<GroupedRawData> clicks = importClicks(path.toAbsolutePath().normalize().toString(), SAMPLE_RATE);

View File

@ -0,0 +1,9 @@
{\rtf1\ansi\ansicpg1252\cocoartf2761
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;}
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red255\green255\blue255;}
{\*\expandedcolortbl;;\cssrgb\c0\c0\c0;\cssrgb\c100000\c100000\c99985\c0;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11220\viewh8100\viewkind0
\deftab720
\pard\pardeftab720\partightenfactor0
\f0\fs24 \cf2 \cb3 clickwave.wav is a Rissos dolphin click with a prediction of 0.8221 for channel 0 and 0.9631 for channel 1. }