From f9e87e92ab87086598967f8fec8862a60dcc986d Mon Sep 17 00:00:00 2001 From: Jamie Mac Date: Fri, 12 Jul 2024 08:33:03 +0100 Subject: [PATCH] Updated POm to ignore test resources and updates to DL data selector --- .classpath | 2 +- .settings/org.eclipse.core.resources.prefs | 1 + .settings/org.eclipse.jdt.core.prefs | 6 +- dependency-reduced-pom.xml | 1 + pom.xml | 3 +- .../dataSelector/CompoundDataSelector.java | 8 +- .../dataSelector/CompoundDialogPaneFX.java | 81 ++++++++++++++++++ .../dataSelector/CompoundDialogPanel.java | 2 - .../DataSelectorDialogPaneFX.java | 42 +++++++++ .../clickPlotFX/ClickControlPane2.java | 1 + .../dataSelector/DLDataSelectCreator.java | 22 +++-- .../dataSelector/DLDataSelector.java | 34 ++++++-- .../dataSelector/DLSelectPanel.java | 5 +- .../dlClassification/DLDataUnit.java | 2 +- .../DLDetectionDataBlock.java | 22 ++--- .../layoutFX/.DS_Store | Bin 6148 -> 6148 bytes .../logging/DLAnnotationType.java | 14 ++- 17 files changed, 208 insertions(+), 38 deletions(-) create mode 100644 src/PamguardMVC/dataSelector/CompoundDialogPaneFX.java create mode 100644 src/PamguardMVC/dataSelector/DataSelectorDialogPaneFX.java diff --git a/.classpath b/.classpath index 49faf461..924124d8 100644 --- a/.classpath +++ b/.classpath @@ -6,7 +6,7 @@ - + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 51bb81c3..a474f512 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,5 +1,6 @@ eclipse.preferences.version=1 encoding//src/rawDeepLearningClassifer/segmenter/SegmenterProcess.java=UTF-8 +encoding//src/test=UTF-8 encoding//src/test/resources=UTF-8 encoding/=UTF-8 encoding/src=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index ecb498c8..43939db6 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.compliance=21 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -13,4 +13,4 @@ org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=17 +org.eclipse.jdt.core.compiler.source=21 diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index e135ce29..1775ad8d 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -107,6 +107,7 @@ META-INF/*.SF META-INF/*.DSA META-INF/*.RSA + test/resources/** diff --git a/pom.xml b/pom.xml index dd3572a4..0295d525 100644 --- a/pom.xml +++ b/pom.xml @@ -101,6 +101,7 @@ META-INF/*.SF META-INF/*.DSA META-INF/*.RSA + test/resources/** @@ -179,7 +180,7 @@ --> - + diff --git a/src/PamguardMVC/dataSelector/CompoundDataSelector.java b/src/PamguardMVC/dataSelector/CompoundDataSelector.java index 923baf6c..78effad5 100644 --- a/src/PamguardMVC/dataSelector/CompoundDataSelector.java +++ b/src/PamguardMVC/dataSelector/CompoundDataSelector.java @@ -13,6 +13,8 @@ public class CompoundDataSelector extends DataSelector { private CompoundParams compoundParams = new CompoundParams(); + private CompoundDialogPaneFX compoundPaneFX; + public CompoundDataSelector(PamDataBlock pamDataBlock, ArrayList allSelectors, String selectorName, boolean allowScores, String selectorType) { super(pamDataBlock, selectorName, allowScores); @@ -57,8 +59,10 @@ public class CompoundDataSelector extends DataSelector { @Override public DynamicSettingsPane getDialogPaneFX() { - // TODO Auto-generated method stub - return null; + if (compoundPaneFX==null) { + compoundPaneFX = new CompoundDialogPaneFX(this); + } + return compoundPaneFX; } @Override diff --git a/src/PamguardMVC/dataSelector/CompoundDialogPaneFX.java b/src/PamguardMVC/dataSelector/CompoundDialogPaneFX.java new file mode 100644 index 00000000..23ca4b9d --- /dev/null +++ b/src/PamguardMVC/dataSelector/CompoundDialogPaneFX.java @@ -0,0 +1,81 @@ +package PamguardMVC.dataSelector; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.util.ArrayList; + +import javax.swing.JComponent; +import javax.swing.JPanel; + +import PamView.dialog.PamDialogPanel; +import PamView.dialog.PamGridBagContraints; +import javafx.scene.Node; +import pamViewFX.fxNodes.PamBorderPane; +import pamViewFX.fxNodes.PamVBox; +import pamViewFX.fxSettingsPanes.DynamicSettingsPane; + +public class CompoundDialogPaneFX extends DynamicSettingsPane { + + + private CompoundDataSelector compoundDataSelector; + + private ArrayList selectorList; + private ArrayList selectorPanels; + + private PamVBox mainPanel; + + public CompoundDialogPaneFX(CompoundDataSelector compoundDataSelector) { + this.compoundDataSelector = compoundDataSelector; + this.selectorList = compoundDataSelector.getSelectorList(); + + mainPanel = new PamVBox(); + mainPanel.setSpacing(5); + selectorPanels = new ArrayList(selectorList.size()); + int ind = 0; + for (DataSelector ds : selectorList) { + DynamicSettingsPane panel = ds.getDialogPaneFX(); + // turn all these panels into the compound ones with the extra enable options. + +// DataSelectorDialogPanel dsp = new DataSelectorDialogPanel(ds, panel, ind++); +// selectorPanels.add(dsp); + + mainPanel.getChildren().add(panel.getContentNode()); + } + } + + + @Override + public Boolean getParams(Boolean currParams) { + boolean ok = true; + for (int i = 0; i < selectorPanels.size(); i++) { + PamDialogPanel panel = selectorPanels.get(i); + ok |= panel.getParams(); + } + return ok; + } + + @Override + public void setParams(Boolean input) { + for (int i = 0; i < selectorPanels.size(); i++) { + PamDialogPanel panel = selectorPanels.get(i); + panel.setParams(); + } + } + + @Override + public String getName() { + return "Compound data selector pane"; + } + + @Override + public Node getContentNode() { + return mainPanel; + } + + @Override + public void paneInitialized() { + // TODO Auto-generated method stub + + } + +} diff --git a/src/PamguardMVC/dataSelector/CompoundDialogPanel.java b/src/PamguardMVC/dataSelector/CompoundDialogPanel.java index 6ce8cc0f..8f648caa 100644 --- a/src/PamguardMVC/dataSelector/CompoundDialogPanel.java +++ b/src/PamguardMVC/dataSelector/CompoundDialogPanel.java @@ -1,11 +1,9 @@ package PamguardMVC.dataSelector; -import java.awt.Color; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.util.ArrayList; -import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JPanel; diff --git a/src/PamguardMVC/dataSelector/DataSelectorDialogPaneFX.java b/src/PamguardMVC/dataSelector/DataSelectorDialogPaneFX.java new file mode 100644 index 00000000..97894ae9 --- /dev/null +++ b/src/PamguardMVC/dataSelector/DataSelectorDialogPaneFX.java @@ -0,0 +1,42 @@ +package PamguardMVC.dataSelector; + +import javafx.scene.Node; +import pamViewFX.fxSettingsPanes.DynamicSettingsPane; + +public class DataSelectorDialogPaneFX extends DynamicSettingsPane { + + public DataSelectorDialogPaneFX(Object ownerWindow) { + super(ownerWindow); + // TODO Auto-generated constructor stub + } + + @Override + public Boolean getParams(Boolean currParams) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setParams(Boolean input) { + // TODO Auto-generated method stub + + } + + @Override + public String getName() { + return "Data selector wrapper pane"; + } + + @Override + public Node getContentNode() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void paneInitialized() { + // TODO Auto-generated method stub + + } + +} diff --git a/src/dataPlotsFX/clickPlotFX/ClickControlPane2.java b/src/dataPlotsFX/clickPlotFX/ClickControlPane2.java index ad31f10c..655ee46a 100644 --- a/src/dataPlotsFX/clickPlotFX/ClickControlPane2.java +++ b/src/dataPlotsFX/clickPlotFX/ClickControlPane2.java @@ -242,6 +242,7 @@ public class ClickControlPane2 extends PamBorderPane implements TDSettingsPane { * @return the data select pane. */ private DynamicSettingsPane createDataSelectPane(){ + System.out.println("Data selector: " + clickPlotInfo.getClickDataSelector()); return clickPlotInfo.getClickDataSelector().getDialogPaneFX(); } diff --git a/src/rawDeepLearningClassifier/dataSelector/DLDataSelectCreator.java b/src/rawDeepLearningClassifier/dataSelector/DLDataSelectCreator.java index a4cf341c..e484aa86 100644 --- a/src/rawDeepLearningClassifier/dataSelector/DLDataSelectCreator.java +++ b/src/rawDeepLearningClassifier/dataSelector/DLDataSelectCreator.java @@ -1,23 +1,24 @@ package rawDeepLearningClassifier.dataSelector; -import PamguardMVC.PamDataBlock; import PamguardMVC.dataSelector.DataSelectParams; import PamguardMVC.dataSelector.DataSelector; -import PamguardMVC.dataSelector.DataSelectorCreator; -import clickDetector.dataSelector.ClickDataSelector; +import annotation.DataAnnotationType; +import annotation.dataselect.AnnotationDataSelCreator; import rawDeepLearningClassifier.DLControl; +import rawDeepLearningClassifier.logging.DLAnnotation; +import rawDeepLearningClassifier.logging.DLAnnotationType; /** * Creates a data selector for the deep learning module. * * @author Jamie Macaulay */ -public class DLDataSelectCreator extends DataSelectorCreator { +public class DLDataSelectCreator extends AnnotationDataSelCreator { private DLControl dlcontrol; - public DLDataSelectCreator(DLControl dlcontrol, PamDataBlock pamDataBlock) { - super(pamDataBlock); + public DLDataSelectCreator(DLControl dlcontrol, DLAnnotationType type) { + super(type); this.dlcontrol = dlcontrol; } @@ -27,8 +28,13 @@ public class DLDataSelectCreator extends DataSelectorCreator { } @Override - public DataSelector createDataSelector(String selectorName, boolean allowScores, String selectorType) { - return new DLDataSelector(dlcontrol, this.getPamDataBlock(), selectorName, allowScores, selectorType); + public DataSelector createDataSelector(DataAnnotationType dataAnnotationType, String selectorName, + boolean allowScores, String selectorType) { + // TODO Auto-generated method stub + return new DLDataSelector(dlcontrol, dataAnnotationType, null, + selectorName, allowScores); } + + } diff --git a/src/rawDeepLearningClassifier/dataSelector/DLDataSelector.java b/src/rawDeepLearningClassifier/dataSelector/DLDataSelector.java index 4ca9913f..9fe55e04 100644 --- a/src/rawDeepLearningClassifier/dataSelector/DLDataSelector.java +++ b/src/rawDeepLearningClassifier/dataSelector/DLDataSelector.java @@ -8,21 +8,24 @@ import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataUnit; import PamguardMVC.dataSelector.DataSelectParams; import PamguardMVC.dataSelector.DataSelector; +import annotation.DataAnnotationType; +import annotation.dataselect.AnnotationDataSelector; import pamViewFX.fxSettingsPanes.DynamicSettingsPane; import rawDeepLearningClassifier.DLControl; +import rawDeepLearningClassifier.logging.DLAnnotation; /** - * Data selector of DL data units. Note that data selectors are really data - * unit specific and not annotation specific. + * Data selector of DL data units. Note that data selectors are for deep leanring annotations + * rather than deep learning data units. *

* The data selector can have different types of data selectors which can - * depend on the classifer used and user choice. + * depend on the classifier used and user choice. *

* Note that this is slightly different from DLPredicitoDecision * as it deals with data units that may have a more than one prediction. * i.e. */ -public class DLDataSelector extends DataSelector { +public class DLDataSelector extends AnnotationDataSelector { /** @@ -52,10 +55,19 @@ public class DLDataSelector extends DataSelector { * @param allowScores - allow all the scores. * @param selectorType - the selector type. */ - public DLDataSelector(DLControl dlcontrol, PamDataBlock pamDataBlock, String selectorName, boolean allowScores, String selectorType) { - super(pamDataBlock, selectorName, allowScores); + public DLDataSelector(DLControl dlcontrol, DataAnnotationType annotationType, PamDataBlock pamDataBlock, + String selectorName, boolean allowScores) { + super(annotationType, pamDataBlock, selectorName, allowScores); /****New data filters go here****/ dataFilters.add(new DLPredictionFilter(dlcontrol)); + + //create default params + dlDataSelectParams = new DLDataSelectorParams(); + dlDataSelectParams.dataSelectorParams = new DataSelectParams[dataFilters.size()]; + for (int i=0; i=0 ? 1 : 0; } + @Override + protected double scoreData(PamDataUnit pamDataUnit, DLAnnotation annotation) { + int score = dataFilters.get(dlDataSelectParams.dataSelectorIndex).scoreDLData(pamDataUnit); + + //the score is the index of the class that scores highest or -1 if it does not pass threshold prediciton. + //Need to make more simple here as scores in PG are 0 for not passed rather than negative. + + return score>=0 ? 1 : 0; + } + } diff --git a/src/rawDeepLearningClassifier/dataSelector/DLSelectPanel.java b/src/rawDeepLearningClassifier/dataSelector/DLSelectPanel.java index bf7f054c..c56e4d7e 100644 --- a/src/rawDeepLearningClassifier/dataSelector/DLSelectPanel.java +++ b/src/rawDeepLearningClassifier/dataSelector/DLSelectPanel.java @@ -1,6 +1,7 @@ package rawDeepLearningClassifier.dataSelector; import javax.swing.JComponent; +import javax.swing.JLabel; import PamView.dialog.PamDialogPanel; @@ -16,7 +17,7 @@ public class DLSelectPanel implements PamDialogPanel { @Override public JComponent getDialogComponent() { // TODO Auto-generated method stub - return null; + return new JLabel("Hello Annotation DL"); } @Override @@ -28,7 +29,7 @@ public class DLSelectPanel implements PamDialogPanel { @Override public boolean getParams() { // TODO Auto-generated method stub - return false; + return true; } } diff --git a/src/rawDeepLearningClassifier/dlClassification/DLDataUnit.java b/src/rawDeepLearningClassifier/dlClassification/DLDataUnit.java index 4fa03e38..ffd4e002 100644 --- a/src/rawDeepLearningClassifier/dlClassification/DLDataUnit.java +++ b/src/rawDeepLearningClassifier/dlClassification/DLDataUnit.java @@ -5,7 +5,7 @@ import PamguardMVC.PamDataUnit; import rawDeepLearningClassifier.dlClassification.genericModel.StandardPrediction; /** - * A data unit created from classification results of DL model. this data unit holds one model results, i.e. + * A data unit created from classification results of DL model. This data unit holds one model results, i.e. * corresponds to one segment of raw data. * * @author Jamie Macaulay diff --git a/src/rawDeepLearningClassifier/dlClassification/DLDetectionDataBlock.java b/src/rawDeepLearningClassifier/dlClassification/DLDetectionDataBlock.java index 97bfe6d5..f0f4c43e 100644 --- a/src/rawDeepLearningClassifier/dlClassification/DLDetectionDataBlock.java +++ b/src/rawDeepLearningClassifier/dlClassification/DLDetectionDataBlock.java @@ -74,17 +74,17 @@ public class DLDetectionDataBlock extends AcousticDataBlock impleme } - /* (non-Javadoc) - * @see PamguardMVC.PamDataBlock#getDataSelectCreator() - */ - @Override - public synchronized DataSelectorCreator getDataSelectCreator() { - if (dlDataSelectCreator == null) { - dlDataSelectCreator = new DLDataSelectCreator(dlControl, this); - } - return dlDataSelectCreator; - - } +// /* (non-Javadoc) +// * @see PamguardMVC.PamDataBlock#getDataSelectCreator() +// */ +// @Override +// public synchronized DataSelectorCreator getDataSelectCreator() { +// if (dlDataSelectCreator == null) { +// dlDataSelectCreator = new DLDataSelectCreator(dlControl, this); +// } +// return dlDataSelectCreator; +// +// } } diff --git a/src/rawDeepLearningClassifier/layoutFX/.DS_Store b/src/rawDeepLearningClassifier/layoutFX/.DS_Store index d9c2dd0a3d5a22ccdf3788f0a560bfde534aec5f..854e4d03182745e66c5d4bd06b5b0533eb97ae01 100644 GIT binary patch literal 6148 zcmeHKy-ve05I#ePingc{3u7iWhQ0s_RghRZg^8)8DP>6Fs%a5p-h+XMV1k8-5s7Eu zK@i{BmPjc5VW|M!N%oi6clLK*WIHAz)t$v1qBarLQ5b7GsJ=1o=Q3wou4Naf%osCD zXi7cO6wi4}gD4;h{5A!6?Y6L5hjd97R9?SBtmQlzb;5y8$Cmcqbh&q`gCI(D1h0DU z{NN>fe?DFn5&tk^d{t)TVR&kSe?n(8K?WJ+$Yg>YDE-1-H6EAwmbs^=&FqV$9N8XhlNG-z?2OI+EC@L7|MpD-E)4v!@{BsCuL^FIBsU;ZYavk zj&{$ulkzP}EeePNRRy-~Yn#vilg0P{YLL8%0;0gbQb5&$Fz6yBcec(Y$7ijF(nn!q ozrvykLFJBP^T0>(K8i8)dHewM9TpbR0+SyBBZE|;z(y7L0N1~qZvX%Q delta 94 zcmZoMXfc=|#>CJ*u~2NHo}wrd0|Nsi1A_nqLjgk$Ln=csLq0?4#6tDS1|lqz9oVEN yFJe{S+{sqQxLJXNon>RgM#jzT9Q+(W12zkCd}p4_FJj2ZFxiGjdUK4(3T6Nl5f { private DLAnnotationSymbolChooser dlSymbolChooser; + private DLDataSelectCreator dlDataSelectorCreator; + public DLAnnotationType(DLControl mtControl) { this.dlControl=mtControl; dlAnnotationSQL = new DLAnnotationSQL(this); @@ -92,6 +95,15 @@ public class DLAnnotationType extends DataAnnotationType { public DLControl getDlControl() { return dlControl; } + + + @Override + public AnnotationDataSelCreator getDataSelectCreator(String selectorName, boolean allowScores) { + if (dlDataSelectorCreator == null) { + dlDataSelectorCreator = new DLDataSelectCreator(dlControl, this); + } + return dlDataSelectorCreator; + }