mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2025-02-16 17:22:46 +00:00
Updates to FX GUI
This commit is contained in:
parent
4de9613588
commit
78219981f8
@ -765,6 +765,7 @@ final public class PamModel implements PamModelInterface, PamSettings {
|
||||
mi.addDependency(new PamDependency(ClickDetection.class, "clickDetector.ClickControl"));
|
||||
mi.setToolTipText("Classifies clicks based on an ideal template to match and a template to reject. "
|
||||
+ "An example of this is to classify beaked whale clicks in an environment with dolphin clicks");
|
||||
mi.addGUICompatabilityFlag(PamGUIManager.FX);
|
||||
mi.setModulesMenuGroup(classifierGroup);
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@ import javafx.scene.layout.Priority;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Line;
|
||||
import javafx.util.StringConverter;
|
||||
import net.synedra.validatorfx.Validator;
|
||||
import PamController.PamController;
|
||||
import PamController.SettingsPane;
|
||||
import PamDetection.RawDataUnit;
|
||||
@ -175,12 +176,21 @@ public class ClickSettingsPane extends SettingsPane<ClickParameters>{
|
||||
* The default pane width
|
||||
*/
|
||||
public static double PREF_PANE_WIDTH=550;
|
||||
|
||||
|
||||
/**
|
||||
* Validator which checks for errors
|
||||
*/
|
||||
private Validator clickValidator;
|
||||
|
||||
|
||||
|
||||
public ClickSettingsPane(ClickControl clickControl){
|
||||
super(null);
|
||||
this.clickControl=clickControl;
|
||||
mainPane= new PamBorderPane();
|
||||
|
||||
clickValidator = new Validator();
|
||||
|
||||
pamTabbedPane=new PamTabPane();
|
||||
pamTabbedPane.setAddTabButton(false);
|
||||
@ -376,13 +386,24 @@ public class ClickSettingsPane extends SettingsPane<ClickParameters>{
|
||||
else selectNoChannels();
|
||||
});
|
||||
|
||||
//create a list of trigger boxes
|
||||
//create a list of trigger boxesc
|
||||
for (int i=0; i<triggerBoxes.length; i++){
|
||||
triggerBoxes[i]=new CheckBox(("Channel "+i));
|
||||
final int n=i;
|
||||
triggerBoxes[i].setOnAction((action)->{
|
||||
selectionChanged(n);
|
||||
clickValidator.validate(); //make sure all nodes are resrt when one channel is ticked.
|
||||
});
|
||||
clickValidator.createCheck()
|
||||
.dependsOn(("trigger " + n), triggerBoxes[i].selectedProperty())
|
||||
.withMethod(c -> {
|
||||
if (!isATriggerSelected() ) {
|
||||
c.error("At least one trigger channel needs to be selected for the module to work");
|
||||
}
|
||||
})
|
||||
.decorates(triggerBoxes[n])
|
||||
.immediate();
|
||||
|
||||
}
|
||||
|
||||
populateTriggerPane();
|
||||
@ -544,7 +565,7 @@ public class ClickSettingsPane extends SettingsPane<ClickParameters>{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current channle bitmap.
|
||||
* Get the current channels bitmap.
|
||||
* @return integer channel bitmap
|
||||
*/
|
||||
private int getChannels(){
|
||||
@ -557,6 +578,32 @@ public class ClickSettingsPane extends SettingsPane<ClickParameters>{
|
||||
}
|
||||
return channels;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of selected trigger channels.
|
||||
* @return the number of selected trigger channels.
|
||||
*/
|
||||
private int getNSelectedTrigger() {
|
||||
int channels=getChannels();
|
||||
int n=0;
|
||||
//now add correct trigger children again
|
||||
for (int i = 0; i < Math.min(PamConstants.MAX_CHANNELS, triggerBoxes.length); i++) {
|
||||
if ((channels & 1<<i) != 0 && triggerBoxes[i].isSelected()){
|
||||
n++;
|
||||
};
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether at least one trigger channel is selected.
|
||||
* @return true of a trigger channel is selected.
|
||||
*/
|
||||
private boolean isATriggerSelected() {
|
||||
return getNSelectedTrigger()>0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create trigger channels
|
||||
@ -574,6 +621,8 @@ public class ClickSettingsPane extends SettingsPane<ClickParameters>{
|
||||
triggerChannels.getChildren().add(selectAll);
|
||||
for (int i = 0; i < Math.min(PamConstants.MAX_CHANNELS, triggerBoxes.length); i++) {
|
||||
if ((channels & 1<<i) != 0){
|
||||
|
||||
//triggerBoxes[i] = new CheckBox("Channel " + i);
|
||||
triggerChannels.getChildren().add(triggerBoxes[i]);
|
||||
triggerBoxes[i].layoutYProperty().unbind();
|
||||
triggerBoxes[i].layoutYProperty().bind(sourcePane.getChannelBoxes()[i].layoutYProperty());
|
||||
|
@ -7,11 +7,14 @@ import java.util.ArrayList;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import PamController.PamControlledUnit;
|
||||
import PamController.PamControlledUnitGUI;
|
||||
import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamControllerInterface;
|
||||
import PamController.PamGUIManager;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import PamController.SettingsPane;
|
||||
import PamView.WrapperControlledGUISwing;
|
||||
import PamView.symbol.SymbolData;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import clickDetector.ClickClassifiers.ClickTypeProvider;
|
||||
@ -66,6 +69,17 @@ public class MTClassifierControl extends PamControlledUnit implements PamSetting
|
||||
* The offline process.
|
||||
*/
|
||||
private MTOfflineProcess mtOfflineProcess;
|
||||
|
||||
/**
|
||||
* The JavaFX graphics
|
||||
*/
|
||||
private MTControlGUI matchedClickGUIFX;
|
||||
|
||||
/**
|
||||
* The swing graphics - in this case the graphics are JavaFX so this calls a swing wrapper
|
||||
* to hold the JavaFX graphics.
|
||||
*/
|
||||
private PamControlledUnitGUI matchedClickGUIGUISwing;
|
||||
|
||||
|
||||
public MTClassifierControl(String unitName) {
|
||||
@ -379,6 +393,33 @@ public class MTClassifierControl extends PamControlledUnit implements PamSetting
|
||||
return mtOfflineProcess;
|
||||
}
|
||||
|
||||
public void setMTParams(MatchedTemplateParams newParams) {
|
||||
this.matchedTemplateParams = newParams;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the GUI for the PAMControlled unit. This has multiple GUI options which
|
||||
* are instantiated depending on the view type.
|
||||
*
|
||||
* @param flag. The GUI type flag defined in PAMGuiManager.
|
||||
* @return the GUI for the PamControlledUnit unit.
|
||||
*/
|
||||
public PamControlledUnitGUI getGUI(int flag) {
|
||||
if (flag == PamGUIManager.FX) {
|
||||
if (matchedClickGUIFX == null) {
|
||||
matchedClickGUIFX = new MTControlGUI(this);
|
||||
}
|
||||
return matchedClickGUIFX;
|
||||
}
|
||||
if (flag == PamGUIManager.SWING) {
|
||||
if (matchedClickGUIGUISwing == null) {
|
||||
matchedClickGUIGUISwing = new WrapperControlledGUISwing(this);
|
||||
}
|
||||
return matchedClickGUIGUISwing;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
74
src/matchedTemplateClassifer/MTControlGUI.java
Normal file
74
src/matchedTemplateClassifer/MTControlGUI.java
Normal file
@ -0,0 +1,74 @@
|
||||
package matchedTemplateClassifer;
|
||||
|
||||
import PamController.PamControlledUnitGUI;
|
||||
import PamController.PamController;
|
||||
import PamController.PamControllerInterface;
|
||||
import PamController.PamGUIManager;
|
||||
import PamController.SettingsPane;
|
||||
import PamView.WrapperControlledGUISwing;
|
||||
import pamViewFX.PamControlledGUIFX;
|
||||
import rawDeepLearningClassifier.DLControl;
|
||||
import rawDeepLearningClassifier.DLControlGUI;
|
||||
import rawDeepLearningClassifier.RawDLParams;
|
||||
|
||||
/**
|
||||
* The JavaFX GUI for the Matched click classifier control...
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class MTControlGUI extends PamControlledGUIFX {
|
||||
|
||||
/**
|
||||
* The dl control.
|
||||
*/
|
||||
private MTClassifierControl mtControl;
|
||||
|
||||
|
||||
public MTControlGUI(MTClassifierControl dlcontrol) {
|
||||
this.mtControl = dlcontrol;
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings pane contains ALL possible setting for the module in one placed.
|
||||
* Settings panes can be divided into tabs for more space etc.
|
||||
*
|
||||
* @param <T>
|
||||
* @return a Pane containing controls to change settings for module.
|
||||
*/
|
||||
public SettingsPane<?> getSettingsPane(){
|
||||
mtControl.getSettingsPane().setParams(mtControl.getMTParams());
|
||||
return mtControl.getSettingsPane();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateParams() {
|
||||
MatchedTemplateParams newParams=mtControl.getSettingsPane().getParams(mtControl.getMTParams());
|
||||
if (newParams!=null) {
|
||||
mtControl.setMTParams(newParams);
|
||||
}
|
||||
//setup the controlled unit.
|
||||
mtControl.setupControlledUnit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyGUIChange(int changeType) {
|
||||
switch (changeType) {
|
||||
case PamController.INITIALIZATION_COMPLETE:
|
||||
break;
|
||||
case PamControllerInterface.CHANGED_PROCESS_SETTINGS:
|
||||
//data source may have potentially changed. e.g. by a datamodelfx Need to set in params.
|
||||
//System.out.println("FFTControl: CHANGED_PROCESS_SETTINGS : " +fftProcess.getParentDataBlock());
|
||||
if (mtControl.getParentDataBlock()!=null){
|
||||
mtControl.getMTParams().dataSourceName = mtControl.getParentDataBlock().getDataName();
|
||||
}
|
||||
else mtControl.getMTParams().dataSourceName = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import PamController.PamController;
|
||||
import PamDetection.RawDataUnit;
|
||||
import PamUtils.complex.ComplexArray;
|
||||
import PamView.symbol.PamSymbolManager;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
@ -12,8 +13,10 @@ import PamguardMVC.PamInstantProcess;
|
||||
import PamguardMVC.PamObservable;
|
||||
import PamguardMVC.RawDataHolder;
|
||||
import Spectrogram.WindowFunction;
|
||||
import clickDetector.ClickDetection;
|
||||
import clickDetector.ClickLength;
|
||||
import clickDetector.ClickClassifiers.basicSweep.SweepClassifierSet;
|
||||
import clipgenerator.ClipDataUnit;
|
||||
import fftManager.FastFFT;
|
||||
import matchedTemplateClassifer.annotation.MatchedClickAnnotation;
|
||||
import matchedTemplateClassifer.annotation.MatchedClickAnnotationType;
|
||||
@ -485,6 +488,21 @@ public class MTProcess extends PamInstantProcess {
|
||||
public BeskopeClassifierManager getBespokeClassifierManager() {
|
||||
return bespokeClassifierManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of data block class types which are compatible as parent data blocks
|
||||
* for the PamProcess. This can return null, e.g. in the case of Acquisition
|
||||
* process.
|
||||
*
|
||||
* @return a list of PamDataBlock sub class types which can be used as parent
|
||||
* data blocks for the process.
|
||||
*/
|
||||
@Override
|
||||
public ArrayList getCompatibleDataUnits(){
|
||||
return new ArrayList<Class<? extends PamDataUnit>>(Arrays.asList(ClickDetection.class));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * Get the parent click data block.
|
||||
|
@ -61,7 +61,7 @@ public class GroupedSourcePaneFX extends SourcePaneFX {
|
||||
/**
|
||||
* Validator for channels
|
||||
*/
|
||||
private Validator validator;
|
||||
private Validator channelValidator;
|
||||
|
||||
|
||||
public GroupedSourcePaneFX(Class sourceType, boolean hasChannels, boolean includeSubClasses, boolean autoGrouping) {
|
||||
@ -76,7 +76,7 @@ public class GroupedSourcePaneFX extends SourcePaneFX {
|
||||
@Override
|
||||
protected void createPanel() {
|
||||
|
||||
validator = new Validator();
|
||||
channelValidator = new Validator();
|
||||
|
||||
sourcePane=new PamGridPane();
|
||||
sourcePane.setVgap(5);
|
||||
@ -138,11 +138,11 @@ public class GroupedSourcePaneFX extends SourcePaneFX {
|
||||
selectAll.setOnAction((action)->{
|
||||
if (selectAll.isSelected()) selectAllChannels();
|
||||
else selectNoChannels();
|
||||
validator.validate(); //makes sure any error signs are removed
|
||||
channelValidator.validate(); //makes sure any error signs are removed
|
||||
});
|
||||
|
||||
//create check to show at least some check boxes need to be selected.
|
||||
validator.createCheck()
|
||||
channelValidator.createCheck()
|
||||
.dependsOn(("select all"), selectAll.selectedProperty())
|
||||
.withMethod(c -> {
|
||||
if (!isAChannelSelected() ) {
|
||||
@ -156,7 +156,7 @@ public class GroupedSourcePaneFX extends SourcePaneFX {
|
||||
if (isHasChannels()){
|
||||
for (int i = 0; i < PamConstants.MAX_CHANNELS; i++){
|
||||
channelBoxes[i] = new CheckBox("Channel " + i);
|
||||
validator.createCheck()
|
||||
channelValidator.createCheck()
|
||||
.dependsOn(("channel " + i), channelBoxes[i].selectedProperty())
|
||||
.withMethod(c -> {
|
||||
if (!isAChannelSelected() ) {
|
||||
@ -170,7 +170,7 @@ public class GroupedSourcePaneFX extends SourcePaneFX {
|
||||
final int n=i;
|
||||
channelBoxes[i].setOnAction((action)->{
|
||||
selectionChanged(n);
|
||||
validator.validate(); //makes sure any error signs are removed.
|
||||
channelValidator.validate(); //makes sure any error signs are removed.
|
||||
});
|
||||
groupList[i]=new ComboBox<Integer>();
|
||||
//System.out.println("SourcePanel.java creatPanel"+i);
|
||||
@ -196,6 +196,15 @@ public class GroupedSourcePaneFX extends SourcePaneFX {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validator for the channel. This can identify errors
|
||||
* in
|
||||
* @return
|
||||
*/
|
||||
public Validator getChannelValidator() {
|
||||
return channelValidator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if
|
||||
* @return
|
||||
|
Loading…
Reference in New Issue
Block a user