diff --git a/repo/pamguard/org/x3/2.1.0/x3-2.1.0.jar b/repo/pamguard/org/x3/2.1.0/x3-2.1.0.jar index d6123190..b2e0e1ae 100644 Binary files a/repo/pamguard/org/x3/2.1.0/x3-2.1.0.jar and b/repo/pamguard/org/x3/2.1.0/x3-2.1.0.jar differ diff --git a/src/Resources/css/primer-dark.css b/src/Resources/css/primer-dark.css index ca9a4708..82062a73 100644 --- a/src/Resources/css/primer-dark.css +++ b/src/Resources/css/primer-dark.css @@ -1422,6 +1422,7 @@ Text { -color-cell-bg-odd: -color-bg-subtle; -color-cell-border: -color-border-default; -fx-border-color: -color-cell-border; + -fx-control-inner-background: -color-bg-default; -fx-border-width: 1px; -fx-border-radius: 0; -color-header-bg: -color-bg-subtle; @@ -3703,4 +3704,20 @@ Text { #label-title2 { -fx-font: bold 13pt -fx-font-family; + } + +/******************************************************************************* + * * + * Label * + * * + ******************************************************************************/ + + +.validatorfx-error { + -fx-text-fill: rgb(164, 0, 0); +} + +.validatorfx-warning { + -fx-text-fill: rgb(196, 160, 0); +} } diff --git a/src/clickDetector/ClickClassifiers/basicSweep/SweepClassifier.java b/src/clickDetector/ClickClassifiers/basicSweep/SweepClassifier.java index 5b814962..7dbc2840 100644 --- a/src/clickDetector/ClickClassifiers/basicSweep/SweepClassifier.java +++ b/src/clickDetector/ClickClassifiers/basicSweep/SweepClassifier.java @@ -412,7 +412,7 @@ public class SweepClassifier implements ClickIdentifier , PamSettings { } @Override - public ClassifyPaneFX getClassifierPane() { + public SweepClassifierPaneFX getClassifierPane() { if (fxPane==null) fxPane = new SweepClassifierPaneFX(this, clickControl); return fxPane; } diff --git a/src/clickDetector/layoutFX/ClickSettingsPane.java b/src/clickDetector/layoutFX/ClickSettingsPane.java index 197bd958..a62f3be0 100644 --- a/src/clickDetector/layoutFX/ClickSettingsPane.java +++ b/src/clickDetector/layoutFX/ClickSettingsPane.java @@ -40,6 +40,7 @@ import pamViewFX.fxNodes.PamVBox; import pamViewFX.fxNodes.pamDialogFX.PamDialogFX; import pamViewFX.fxNodes.utilityPanes.FilterPaneFX; import pamViewFX.fxNodes.utilityPanes.GroupedSourcePaneFX; +import pamViewFX.validator.PamValidator; /** * A pane to change click detector settings. @@ -175,7 +176,7 @@ public class ClickSettingsPane extends SettingsPane{ /** * The default pane width */ - public static double PREF_PANE_WIDTH=550; + public static double PREF_PANE_WIDTH=560; /** @@ -190,7 +191,7 @@ public class ClickSettingsPane extends SettingsPane{ this.clickControl=clickControl; mainPane= new PamBorderPane(); - clickValidator = new Validator(); + clickValidator = new PamValidator(); pamTabbedPane=new PamTabPane(); pamTabbedPane.setAddTabButton(false); diff --git a/src/clickDetector/layoutFX/clickClassifiers/SweepClassifierSetPaneFX.java b/src/clickDetector/layoutFX/clickClassifiers/SweepClassifierSetPaneFX.java index d5e1cbc8..477b5b78 100644 --- a/src/clickDetector/layoutFX/clickClassifiers/SweepClassifierSetPaneFX.java +++ b/src/clickDetector/layoutFX/clickClassifiers/SweepClassifierSetPaneFX.java @@ -19,8 +19,12 @@ import javafx.scene.control.TabPane; import javafx.scene.control.TabPane.TabClosingPolicy; import javafx.scene.control.TextField; import javafx.scene.control.Tooltip; +import javafx.scene.layout.GridPane; import javafx.scene.layout.Priority; import javafx.scene.text.Font; +import net.synedra.validatorfx.GraphicDecoration; +import net.synedra.validatorfx.ValidationMessage; +import net.synedra.validatorfx.Validator; import pamViewFX.fxNodes.PamBorderPane; import pamViewFX.fxNodes.PamGridPane; import pamViewFX.fxNodes.PamHBox; @@ -33,10 +37,24 @@ import pamViewFX.fxNodes.utilityPanes.PamToggleSwitch; import pamViewFX.fxNodes.utilityPanes.SimpleFilterPaneFX; import pamViewFX.fxNodes.utilsFX.PamUtilsFX; import pamViewFX.PamGuiManagerFX; -import net.synedra.validatorfx.Validator; +import pamViewFX.fxGlyphs.PamGlyphDude; + +import java.awt.BorderLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; import PamController.SettingsPane; +import PamUtils.PamUtils; import PamView.PamSymbol; +import PamView.dialog.PamGridBagContraints; import PamView.symbol.SymbolData; import clickDetector.ClickClassifiers.basicSweep.CodeHost; import clickDetector.ClickClassifiers.basicSweep.SweepClassifier; @@ -49,12 +67,12 @@ import clickDetector.ClickClassifiers.basicSweep.SweepClassifierSet; * */ public class SweepClassifierSetPaneFX extends SettingsPane { - + /** * Holds general options for the classifier. */ private OptionsBox optionBox; - + /** * Settings for pre-filtering of click */ @@ -84,7 +102,7 @@ public class SweepClassifierSetPaneFX extends SettingsPane { * Pane to change zero crossings */ private ZeroCrossingsBox zeroCrossingsBox; - + /** * Cloned reference to ClickTypeProperty. */ @@ -100,37 +118,45 @@ public class SweepClassifierSetPaneFX extends SettingsPane { */ private AmplitudeBlock amplitudeBlock; - private PamBorderPane mainPane = new PamBorderPane(); - private Validator validator = new Validator(); + /** + * Changes the bearing paramters fro clicks. + */ + private BearingBlock bearingBox; + + + private PamBorderPane mainPane = new PamBorderPane(); + public int classifierItemRow; - + + public SweepClassifierSetPaneFX(SweepClassifier sweepClassifier){ super(null); this.sweepClassifier=sweepClassifier; mainPane= new PamBorderPane(); mainPane.setCenter(createSweepPane()); } - + /** * Create pane with controls to change SweepClassiferSet class * @return pane with controls to create a sweep classifier. */ private Node createSweepPane(){ - + PamVBox holder=new PamVBox(); holder.setSpacing(15); holder.setPadding(new Insets(10,0,0,0)); optionBox=new OptionsBox(); - + /*********Waveform Tab************/ Tab waveformTab=new Tab("Waveform"); + waveformTab.setGraphic(PamGlyphDude.createPamIcon("mdi2w-waveform", PamGuiManagerFX.iconSize)); PamVBox waveformHolder=new PamVBox(5); waveformHolder.setPadding(new Insets(10,0,0,0)); - + clickLength=new ClickLengthBox(); filterBox=new FilterBox(); amplitudeBlock = new AmplitudeBlock(); @@ -138,9 +164,10 @@ public class SweepClassifierSetPaneFX extends SettingsPane { waveformHolder.getChildren().addAll(clickLength, filterBox, amplitudeBlock, zeroCrossingsBox); waveformTab.setContent(waveformHolder); - + /*********Spectrum Tab****************/ Tab spectrumTab=new Tab("Spectrum"); + spectrumTab.setGraphic(PamGlyphDude.createPamIcon("mdi2c-chart-bell-curve", PamGuiManagerFX.iconSize)); PamVBox spectrumHolder=new PamVBox(5); energyBox=new EnergyBandBox(); @@ -148,19 +175,32 @@ public class SweepClassifierSetPaneFX extends SettingsPane { spectrumHolder.getChildren().addAll(energyBox, freqBox); spectrumHolder.setPadding(new Insets(10,0,0,0)); spectrumTab.setContent(spectrumHolder); + + /*********Spectrum Tab****************/ + Tab bearingTab=new Tab("Bearing"); + spectrumTab.setGraphic(PamGlyphDude.createPamIcon("mdi2c-compass-outline", PamGuiManagerFX.iconSize)); + + PamVBox bearingHolder=new PamVBox(5); + + bearingBox=new BearingBlock(); + + bearingHolder.getChildren().addAll(bearingBox); + bearingHolder.setPadding(new Insets(10,0,0,0)); + bearingTab.setContent(bearingHolder); + /**********Main Layout**************/ - + TabPane tabPane= new TabPane(); tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); tabPane.getTabs().addAll(waveformTab, spectrumTab); - + holder.getChildren().add(optionBox); holder.getChildren().add(tabPane); - + return holder; } - + /** * Each section in the classifier can be enabled or disabled. * This is a generic abstract class for each pane. @@ -168,26 +208,33 @@ public class SweepClassifierSetPaneFX extends SettingsPane { * */ private abstract class SweepBox extends PamBorderPane { - + + + /** + * Validator to check settings are correct. + */ + private Validator validator = new Validator(); + + /** * Check box to enable pane */ - private PamToggleSwitch enableBox; - + protected PamToggleSwitch enableBox; + /** * Border pane to hold content */ private PamBorderPane borderPane; - - + + private Font disableFont; private Label label; - + SweepBox(String borderTitle, Boolean enableButton) { - //create holder pnae + //create holder pane borderPane=new PamBorderPane(); this.setCenter(borderPane); @@ -231,7 +278,17 @@ public class SweepClassifierSetPaneFX extends SettingsPane { //tP.setCenter( description = new Label("", JLabel.CENTER)); //this.setTop(tP); } - + + + /** + * Get the validator for the sweep box. + * @return + */ + public Validator getValidator() { + return validator; + } + + /** * Set a description for the sweep box. * @param desc - a description of the control @@ -239,11 +296,11 @@ public class SweepClassifierSetPaneFX extends SettingsPane { protected void setDescription(String desc) { label.setTooltip(new Tooltip(desc)); } - -// private void showTopStrip() { -// tP.setVisible(enableBox != null && description.getText().length() > 0); -// } - + + // private void showTopStrip() { + // tP.setVisible(enableBox != null && description.getText().length() > 0); + // } + /** * Set the controls to be anabled or disabled. * @param enabled - true to enable. @@ -253,18 +310,18 @@ public class SweepClassifierSetPaneFX extends SettingsPane { return; } enableBox.setSelected(enabled); - disbleControls(enabled); + disbleControls(!enabled); } - - + + protected boolean getEnableBox() { if (enableBox == null) { return false; } return enableBox.isSelected(); } - - + + /** * Get pane which holds content * @return the border pane. @@ -272,63 +329,63 @@ public class SweepClassifierSetPaneFX extends SettingsPane { public PamBorderPane getHolderPane() { return borderPane; } - + /** * Called whenever a new ClickTypeProperty is selected. Sets pane controls to show ClickTypeProperty params */ protected abstract void setParams(); - + /** * Called whenever a ClickTypeProperty should be generated from controls. * @return a new ClickTypeProperty generated from values set by user in controls. */ protected abstract boolean getParams(); - + /** * Disable all controls within a box. * @param disable - true to disable controls. */ protected abstract void disbleControls(boolean disable); } - - + + /** * General options for the sweep classifier set * @author Jamie Macaulay * */ private class OptionsBox extends SweepBox implements FFTLengthModeled, CodeHost { - + /** * Text field to set classifier name. */ private TextField nameField; - + /** * Pick a colour. */ private ColorPicker symbolColour; - + /** * Choose a symbol for the classifier */ private SymbolPicker symbolPicker; - + /** * Spinner to change the spinner code. */ private PamSpinner codeSpinner; - + /** * Channels box. */ private ComboBox channelsBox; - + /** * Click length spinner. */ private PamSpinner clickLengthSpinner; - + /** * Shows lengths of extraction samples in millis. */ @@ -343,19 +400,19 @@ public class SweepClassifierSetPaneFX extends SettingsPane { private ColorPicker fillColourPicker; OptionsBox() { - super("General Options", false); + super(null, false); this.getHolderPane().setCenter(createOptionsPane()); - + } - + //create the general options private Node createOptionsPane(){ - + PamGridPane pamGridPane=new PamGridPane(); pamGridPane.setHgap(5); pamGridPane.setVgap(5); -// pamGridPane.setPadding(new Insets(10,5,5,35)); + // pamGridPane.setPadding(new Insets(10,5,5,35)); pamGridPane.add(new Label("Name"), 0, 0); @@ -364,20 +421,20 @@ public class SweepClassifierSetPaneFX extends SettingsPane { pamGridPane.add(nameField, 1, 0); PamGridPane.setColumnSpan(nameField, 8); PamGridPane.setHgrow(nameField, Priority.ALWAYS); - - validator.createCheck() - .dependsOn("speciesname", nameField.textProperty()) - .withMethod(c -> { - String userName = c.get("speciesname"); - if (userName == null || userName.length()<=0) { - c.error("The classifier must have a name"); - } - }) - .decorates(nameField) - .immediate(); - ; - - + + getValidator().createCheck() + .dependsOn("speciesname", nameField.textProperty()) + .withMethod(c -> { + String userName = c.get("speciesname"); + if (userName == null || userName.length()<=0) { + c.error("The classifier must have a name"); + } + }) + .decorates(nameField) + .immediate(); + ; + + pamGridPane.add(new Label("Code"), 0, 1); codeSpinner=new PamSpinner (1, 500, 0, 1); @@ -385,23 +442,23 @@ public class SweepClassifierSetPaneFX extends SettingsPane { //codeSpinner.setPrefWidth(150); codeSpinner.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); pamGridPane.add(codeSpinner, 1, 1); - -// pamGridPane.add(new Label("Symbol"), 0,1); - + + // pamGridPane.add(new Label("Symbol"), 0,1); + //create colour picker to allow users to change symbol colour. symbolPicker=new SymbolPicker(); pamGridPane.add(symbolPicker, 3,1); - + pamGridPane.add(new Label("Symbol"), 2,1); - + lineColourPicker = new ColorPicker(); lineColourPicker.setStyle("-fx-color-label-visible: false ;"); lineColourPicker.setOnAction((action)->{ symbolPicker.setLineColour(lineColourPicker.getValue()); }); pamGridPane.add(lineColourPicker, 4, 1); - - + + fillColourPicker = new ColorPicker(); fillColourPicker.setStyle("-fx-color-label-visible: false ;"); fillColourPicker.setOnAction((action)->{ @@ -410,30 +467,30 @@ public class SweepClassifierSetPaneFX extends SettingsPane { pamGridPane.add(fillColourPicker, 5, 1); -// //create a button to allow users to change symbol shape. -// symbolColour=new ColorPicker(); -// pamGridPane.add(symbolColour, 3, 1); -// symbolColour.setOnAction((action)->{ -// symbolPicker.setFillColour(symbolColour.getValue()); -// }); - + // //create a button to allow users to change symbol shape. + // symbolColour=new ColorPicker(); + // pamGridPane.add(symbolColour, 3, 1); + // symbolColour.setOnAction((action)->{ + // symbolPicker.setFillColour(symbolColour.getValue()); + // }); + //channel options pamGridPane.add(new Label("Channels"), 0,2); - + channelsBox = new ComboBox(); for (int i = 0; i < 3; i++) { channelsBox.getItems().add(SweepClassifierSet.getChannelOptionsName(i)); } pamGridPane.add(channelsBox, 1,2); - + PamGridPane.setColumnSpan(channelsBox,8 ); - + //restrict parameter to click centre PamHBox clickCenterBox=new PamHBox(); clickCenterBox.setSpacing(5); clickCenterBox.getChildren().add(restrictLength = new CheckBox("Trim click")); - + clickLengthSpinner=new PamSpinner(4,102400,128,32); clickLengthSpinner.setEditable(true); //clickLengthSpinner.setPrefWidth(150); @@ -441,7 +498,7 @@ public class SweepClassifierSetPaneFX extends SettingsPane { clickLengthSpinner.valueProperty().addListener((obsVal, oldVal, newVal)->{ setLengthLabel(); }); - + clickCenterBox.getChildren().add(clickLengthSpinner); Label samplesLabel =new Label("samples"); clickCenterBox.getChildren().add(samplesLabel); @@ -450,33 +507,33 @@ public class SweepClassifierSetPaneFX extends SettingsPane { lengthTypeBox.getItems().add("around click center"); lengthTypeBox.getItems().add("from start of click"); clickCenterBox.setAlignment(Pos.CENTER_LEFT); - + restrictLength.setOnAction((action)->{ lengthTypeBox.setDisable(!restrictLength.isSelected()); clickLengthSpinner.setDisable(!restrictLength.isSelected()); samplesLabel.setDisable(!restrictLength.isSelected()); lengthMS.setDisable(!restrictLength.isSelected()); }); - -// //column constraints -// ColumnConstraints col1 = new ColumnConstraints(); -// col1.setPercentWidth(15); -// ColumnConstraints col2 = new ColumnConstraints(); -// col2.setPercentWidth(35); -// ColumnConstraints col3 = new ColumnConstraints(); -// col3.setPercentWidth(15); -// ColumnConstraints col4 = new ColumnConstraints(); -// col4.setPercentWidth(35); -// ColumnConstraints col4 = new ColumnConstraints(); -// col4.setPercentWidth(35); -// -// pamGridPane.getColumnConstraints().addAll(col1, col2, col3,col4); - + + // //column constraints + // ColumnConstraints col1 = new ColumnConstraints(); + // col1.setPercentWidth(15); + // ColumnConstraints col2 = new ColumnConstraints(); + // col2.setPercentWidth(35); + // ColumnConstraints col3 = new ColumnConstraints(); + // col3.setPercentWidth(15); + // ColumnConstraints col4 = new ColumnConstraints(); + // col4.setPercentWidth(35); + // ColumnConstraints col4 = new ColumnConstraints(); + // col4.setPercentWidth(35); + // + // pamGridPane.getColumnConstraints().addAll(col1, col2, col3,col4); + PamVBox holder = new PamVBox(); holder.setSpacing(5); holder.getChildren().addAll(pamGridPane,clickCenterBox); - + return holder; } @@ -501,7 +558,7 @@ public class SweepClassifierSetPaneFX extends SettingsPane { float sr = sweepClassifier.getClickDetector().getSampleRate(); lengthMS.setText(String.format("(%.2f ms)", fftLength * 1000 / sr)); } - + /** * Set the length in seconds. */ @@ -512,7 +569,8 @@ public class SweepClassifierSetPaneFX extends SettingsPane { @Override protected void setParams() { - + + //set basic data if (sweepClassifierSet == null) { //symbolViewer.setSymbol(null); symbolPicker.getSelectionModel().select(0); @@ -524,36 +582,49 @@ public class SweepClassifierSetPaneFX extends SettingsPane { nameField.setText(sweepClassifierSet.getName()); setCode(sweepClassifierSet.getSpeciesCode()); } + + if (sweepClassifierSet == null) { return; } + if (sweepClassifierSet.symbol!=null) { + //set the colours. + lineColourPicker.setValue(PamUtilsFX.awtToFXColor(sweepClassifierSet.symbol.getSymbolData().getLineColor())); + fillColourPicker.setValue(PamUtilsFX.awtToFXColor(sweepClassifierSet.symbol.getSymbolData().getFillColor())); + symbolPicker.setValue(sweepClassifierSet.symbol.getSymbolData().symbol); + symbolPicker.setLineColour(lineColourPicker.getValue()); + symbolPicker.setFillColour(fillColourPicker.getValue()); + } + + //set the click length data lengthTypeBox.getSelectionModel().select(sweepClassifierSet.restrictedBinstype); - + channelsBox.getSelectionModel().select(sweepClassifierSet.channelChoices); restrictLength.setSelected(sweepClassifierSet.restrictLength); setFFTLength(sweepClassifierSet.restrictedBins); - - -// nameField.setText(sweepClassifierSet.getName()); -// codeSpinner.getValueFactory().setValue(sweepClassifierSet.getSpeciesCode()); -// channelsBox.getSelectionModel().select(sweepClassifierSet.channelChoices); -// -// //length stuff -// clickLengthSpinner.getValueFactory().setValue(sweepClassifierSet.restrictedBins); - - + + + // nameField.setText(sweepClassifierSet.getName()); + // codeSpinner.getValueFactory().setValue(sweepClassifierSet.getSpeciesCode()); + // channelsBox.getSelectionModel().select(sweepClassifierSet.channelChoices); + // + // //length stuff + // clickLengthSpinner.getValueFactory().setValue(sweepClassifierSet.restrictedBins); + + } @Override protected boolean getParams() { sweepClassifierSet.setName(nameField.getText()); - + if (this.symbolPicker.getValue()==null) { return showWarning("You must pick a symbol"); } - + + //get the symbol data. SymbolData symbolData = new SymbolData(this.symbolPicker.getValue().getSymbol(), 10,10,true, PamUtilsFX.fxToAWTColor(this.lineColourPicker.getValue()), PamUtilsFX.fxToAWTColor(this.fillColourPicker.getValue())); sweepClassifierSet.symbol= new PamSymbol(symbolData); @@ -561,6 +632,9 @@ public class SweepClassifierSetPaneFX extends SettingsPane { return showWarning("You must enter a name for this type of click"); } sweepClassifierSet.setSpeciesCode(getCode()); + + System.out.println(" sweepClassifierSet: " + sweepClassifierSet + " classifierItemRow: " + + classifierItemRow + "sweepClassifierSet.getSpeciesCode(): " + sweepClassifierSet.getSpeciesCode()); if (sweepClassifier.codeDuplicated(sweepClassifierSet, classifierItemRow) || sweepClassifierSet.getSpeciesCode() <= 0){ return showWarning("You must enter a unique positive integer species code"); @@ -570,9 +644,9 @@ public class SweepClassifierSetPaneFX extends SettingsPane { } sweepClassifierSet.channelChoices = channelsBox.getSelectionModel().getSelectedIndex(); sweepClassifierSet.restrictLength = restrictLength.isSelected(); - + sweepClassifierSet.restrictedBinstype = lengthTypeBox.getSelectionModel().getSelectedIndex(); - + try { sweepClassifierSet.restrictedBins = clickLengthSpinner.getValue(); } @@ -580,10 +654,10 @@ public class SweepClassifierSetPaneFX extends SettingsPane { return showWarning("Invalid Restricted length value"); } return true; -// sweepClassifierSet.setName(nameField.getText()); -// sweepClassifierSet.setSpeciesCode(codeSpinner.getValue()); -// sweepClassifierSet.channelChoices=channelsBox.getSelectionModel().getSelectedIndex(); -// sweepClassifierSet.restrictedBins=clickLengthSpinner.getValue(); + // sweepClassifierSet.setName(nameField.getText()); + // sweepClassifierSet.setSpeciesCode(codeSpinner.getValue()); + // sweepClassifierSet.channelChoices=channelsBox.getSelectionModel().getSelectedIndex(); + // sweepClassifierSet.restrictedBins=clickLengthSpinner.getValue(); } @Override @@ -594,33 +668,33 @@ public class SweepClassifierSetPaneFX extends SettingsPane { public TextField getNameLabel() { return this.nameField; } - + } - + /** * Filter options for the sweep classifier set * @author Jamie Macaulay */ private class FilterBox extends SweepBox implements FFTLengthModeled { - + private SimpleFilterPaneFX simpleFilterPane; FilterBox() { super("Filter Options", true); this.getHolderPane().setCenter(createOptionsPane()); - + } - + //create the general options private Node createOptionsPane(){ - + PamGridPane pamGridPane=new PamGridPane(); pamGridPane.setHgap(5); pamGridPane.setVgap(5); - + simpleFilterPane=new SimpleFilterPaneFX(); - + return simpleFilterPane.getContentNode(); } @@ -634,16 +708,17 @@ public class SweepClassifierSetPaneFX extends SettingsPane { @Override public void setFFTLength(int fftLength) { // TODO Auto-generated method stub - + } @Override protected void setParams() { //set sample rate. + setEnableBox(sweepClassifierSet.enableFFTFilter); simpleFilterPane.setSampleRate(sweepClassifier.getClickDetector().getSampleRate()); if (sweepClassifierSet.fftFilterParams!=null) simpleFilterPane.setParams(sweepClassifierSet.fftFilterParams); - + } @Override @@ -659,21 +734,21 @@ public class SweepClassifierSetPaneFX extends SettingsPane { protected void disbleControls(boolean disable) { simpleFilterPane.setDisableFilterPane(disable); } - + } - + /** * Click length box. * @author Jamie Macaulay * */ private class ClickLengthBox extends SweepBox { - + /** * Spinner for peak smoothing */ PamSpinner smoothing; - + /** * Spinner for minimum click length in milliseconds */ @@ -683,7 +758,7 @@ public class SweepClassifierSetPaneFX extends SettingsPane { * Spinner for maximum click length in milliseconds */ PamSpinner maxLengthms; - + /** * Spinner for smoothing threshold. */ @@ -694,85 +769,117 @@ public class SweepClassifierSetPaneFX extends SettingsPane { super("Click Length", true); this.getHolderPane().setCenter(createClickLengthPane()); } - + private Node createClickLengthPane(){ - -// PamGridPane gridPane=new PamGridPane(); -// gridPane.setHgap(5); -// gridPane.setVgap(5); - + + // PamGridPane gridPane=new PamGridPane(); + // gridPane.setHgap(5); + // gridPane.setVgap(5); + //threshold -// gridPane.add(new Label("Smoothing"),0,0); + // gridPane.add(new Label("Smoothing"),0,0); smoothing=new PamSpinner(3,101,5,2); smoothing.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); //smoothing.setPrefWidth(100); -// gridPane.add(smoothing,1,0); -// gridPane.add(new Label("bins (must be odd)"),2,0); - + // gridPane.add(smoothing,1,0); + // gridPane.add(new Label("bins (must be odd)"),2,0); + //spinner -// gridPane.add(new Label("Threshold"),3,0); + // gridPane.add(new Label("Threshold"),3,0); threshold=new PamSpinner(1., 300., 6.,1.); threshold.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); //threshold.setPrefWidth(100); -// gridPane.add(threshold,4,0); -// gridPane.add(new Label("dB"),5,0); - + // gridPane.add(threshold,4,0); + // gridPane.add(new Label("dB"),5,0); + PamHBox clickLengthHolder1=new PamHBox(); clickLengthHolder1.setSpacing(5); clickLengthHolder1.getChildren().addAll(new Label("Smoothing"), - smoothing, new Label("bins (must be odd)"), new Label("Threshold"), threshold, new Label("dB")); + smoothing, new Label("bins"), new Label("Threshold"), threshold, new Label("dB")); clickLengthHolder1.setAlignment(Pos.CENTER_LEFT); - + //spinner -// gridPane.add(new Label("Click Length"),0,1); - - minLengthms=new PamSpinner(0.00, 1.00, 0.03,0.01); + // gridPane.add(new Label("Click Length"),0,1); + + minLengthms=new PamSpinner(0.00, 100.00, 0.03,0.01); minLengthms.setEditable(true); minLengthms.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); //minLengthms.setPrefWidth(130); - - maxLengthms=new PamSpinner(0.00, 1.00, 0.22,0.01); + + maxLengthms=new PamSpinner(0.00, 100.00, 0.22,0.01); maxLengthms.setEditable(true); maxLengthms.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); //maxLengthms.setPrefWidth(130); - + PamHBox clickLengthHolder2=new PamHBox(); clickLengthHolder2.setSpacing(5); clickLengthHolder2.getChildren().addAll(new Label("Click Length"), minLengthms, new Label("to"), maxLengthms, new Label("ms")); clickLengthHolder2.setAlignment(Pos.CENTER_LEFT); - -// gridPane.add(clickLengthHolder2,1,1); -// PamGridPane.setRowSpan(clickLengthHolder2, 5); -// PamGridPane.setFillWidth(clickLengthHolder2, false); - + // gridPane.add(clickLengthHolder2,1,1); + // PamGridPane.setRowSpan(clickLengthHolder2, 5); + // PamGridPane.setFillWidth(clickLengthHolder2, false); + + PamVBox vboxholder=new PamVBox(); vboxholder.setSpacing(5); vboxholder.getChildren().addAll(clickLengthHolder1, clickLengthHolder2); - + return vboxholder; } @Override protected void setParams() { - smoothing.getValueFactory().setValue(sweepClassifierSet.peakSmoothing); - minLengthms.getValueFactory().setValue(sweepClassifierSet.minLength); - maxLengthms.getValueFactory().setValue(sweepClassifierSet.maxLength); + if (sweepClassifierSet == null) { + return; + } + setEnableBox(sweepClassifierSet.enableLength); + smoothing.getValueFactory().setValue(sweepClassifierSet.lengthSmoothing); threshold.getValueFactory().setValue(sweepClassifierSet.lengthdB); + minLengthms.getValueFactory().setValue( sweepClassifierSet.minLength); + maxLengthms.getValueFactory().setValue(sweepClassifierSet.maxLength); + } @Override protected boolean getParams() { - sweepClassifierSet.peakSmoothing=smoothing.getValue(); - sweepClassifierSet.minLength=minLengthms.getValue(); - sweepClassifierSet.maxLength=maxLengthms.getValue(); - sweepClassifierSet.lengthdB=threshold.getValue(); + sweepClassifierSet.enableLength = getEnableBox(); + try { + sweepClassifierSet.lengthSmoothing = smoothing.getValue(); + sweepClassifierSet.lengthdB = threshold.getValue(); + } + catch (NumberFormatException e) { + return showWarning("Click Length Parameters", + "The length smoothing or threshold parameter is invalid"); + } + if (sweepClassifierSet.lengthSmoothing%2 == 0 || sweepClassifierSet.lengthSmoothing <= 0) { + return showWarning("The number of length smoothing bins must be odd and positive"); + } + if (sweepClassifierSet.lengthdB == 0) { + return showWarning("The length threshold cannot be zero dB"); + } + if (!sweepClassifierSet.enableLength) { + return true; + } + try { + sweepClassifierSet.minLength = minLengthms.getValue(); + sweepClassifierSet.maxLength = maxLengthms.getValue(); + } + catch (NumberFormatException e) { + return showWarning("Click Length Parameters", + "One or more click length parameters is invalid"); + } + if (sweepClassifierSet.maxLength <= sweepClassifierSet.minLength) { + return showWarning("Click Length Parameters", + "The maximum click length must be greater than the minimum"); + } return true; } + @Override protected void disbleControls(boolean disable) { smoothing.setDisable(disable); @@ -780,55 +887,47 @@ public class SweepClassifierSetPaneFX extends SettingsPane { maxLengthms.setDisable(disable); threshold.setDisable(disable); } - + } - + /** * Filter options for the sweep classifier set * @author Jamie Macaulay */ private class EnergyBandBox extends SweepBox { - + /** * Frequency pane for test band */ private FreqBandPane testBandFreqPane; - + /** * Frequency pane for the first control band. */ - private FreqBandPane contralBandFreqPane1; - - /** - * Frequency pane for the second control band. - */ - private FreqBandPane contralBandFreqPane2; - + private ArrayList contralBandFreqPanes; + + /** * Spinner for the first control band */ - PamSpinner thresholdSpinner1; + private ArrayList> thresholdSpinners; - /** - * Spinner for the second control band - */ - PamSpinner thresholdSpinner2; EnergyBandBox() { super("Energy Band", true); this.getHolderPane().setCenter(createOptionsPane()); - + } - + //create the general options private Node createOptionsPane(){ - + PamGridPane pamGridPane=new PamGridPane(); pamGridPane.setHgap(5); pamGridPane.setVgap(5); - + Label freqLabel=new Label("Frequency (Hz)"); pamGridPane.add(freqLabel, 0, 0); pamGridPane.add(new Label("Threshold (dB)"), 2, 0); @@ -840,58 +939,141 @@ public class SweepClassifierSetPaneFX extends SettingsPane { testBandFreqPane=new FreqBandPane(Orientation.HORIZONTAL); testBandFreqPane.setBandText(""); - pamGridPane.add(testBandFreqPane, 1, 1); - //control band 1 - pamGridPane.add(new Label("Control Band"), 0, 2); - contralBandFreqPane1=new FreqBandPane(Orientation.HORIZONTAL); - contralBandFreqPane1.setBandText(""); - pamGridPane.add(contralBandFreqPane1, 1, 2); - thresholdSpinner1=new PamSpinner(0,100.,6.,0); - thresholdSpinner1.setEditable(true); - pamGridPane.add(thresholdSpinner1, 2, 2); - thresholdSpinner1.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); - thresholdSpinner1.setPrefWidth(100); + + addValidatorFreqCheck(getValidator(), testBandFreqPane, "test band ", ("test_band")); - //control band 2 - pamGridPane.add(new Label("Control Band"), 0, 3); - contralBandFreqPane2=new FreqBandPane(Orientation.HORIZONTAL); - contralBandFreqPane2.setBandText(""); - pamGridPane.add(contralBandFreqPane2, 1, 3); - thresholdSpinner2=new PamSpinner(0,100.,6.,0); - thresholdSpinner2.setEditable(true); - thresholdSpinner2.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); - pamGridPane.add(thresholdSpinner2, 2, 3); - thresholdSpinner2.setPrefWidth(100); + + + pamGridPane.add(testBandFreqPane, 1, 1); + + + contralBandFreqPanes = new ArrayList(); + thresholdSpinners = new ArrayList>(); + + for (int i=0; i(0,100.,6.,0)); + thresholdSpinners.get(i).setEditable(true); + pamGridPane.add(thresholdSpinners.get(i), 2, i+2); + thresholdSpinners.get(i).getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); + thresholdSpinners.get(i).setMaxWidth(100); + + //add validation. + final int ii = i; + addValidatorFreqCheck(getValidator(), contralBandFreqPanes.get(i), ("controlband "+ii), ("controlband_"+ii)); + + contralBandFreqPanes.get(i).getLowPassFreq().valueProperty().addListener((obsVal, oldVal, newVal)->{ + getValidator().validate(); + }); + + contralBandFreqPanes.get(i).getLowPassFreq().valueProperty().addListener((obsVal, oldVal, newVal)->{ + getValidator().validate(); + }); + + + + } + return pamGridPane; } + + + @Override protected void setParams() { - //set sample rate. + setEnableBox(sweepClassifierSet.enableEnergyBands); + if (sweepClassifierSet == null) { + return; + } + + sweepClassifierSet.checkEnergyParamsAllocation(); + + testBandFreqPane.getLowPassFreq().getValueFactory().setValue(sweepClassifierSet.testEnergyBand[0]); + testBandFreqPane.getHighPassFreq().getValueFactory().setValue(sweepClassifierSet.testEnergyBand[1]); + + for (int j = 0; j < SweepClassifierSet.nControlBands; j++) { + + contralBandFreqPanes.get(j).getLowPassFreq().getValueFactory().setValue(sweepClassifierSet.controlEnergyBand[j][0]); + contralBandFreqPanes.get(j).getHighPassFreq().getValueFactory().setValue(sweepClassifierSet.controlEnergyBand[j][1]); + + thresholdSpinners.get(j).getValueFactory().setValue(sweepClassifierSet.energyThresholds[j]); + + } + + // for (int i = 0; i < 2; i++) { + // testEnergy[i].setText(String.format("%3.1f", sweepClassifierSet.testEnergyBand[i])); + // for (int j = 0; j < SweepClassifierSet.nControlBands; j++) { + // controlEnergy[j][i].setText(String.format("%3.1f", sweepClassifierSet.controlEnergyBand[j][i])); + // } + // } + // for (int j = 0; j < SweepClassifierSet.nControlBands; j++) { + // thresholds[j].setText(String.format("%3.1f", sweepClassifierSet.energyThresholds[j])); + // } } @Override protected boolean getParams() { - // TODO Auto-generated method stub - return false; + if ((sweepClassifierSet.enableEnergyBands = getEnableBox()) == false) { + return true; + } + if (sweepClassifierSet == null) { + return false; + } + sweepClassifierSet.checkEnergyParamsAllocation(); + + if (this.getValidator().containsErrors()) { + showValidatorWarning(getValidator()); + return false; + } + + try { + + sweepClassifierSet.testEnergyBand[0] = testBandFreqPane.getLowPassFreq().getValue().doubleValue(); + sweepClassifierSet.testEnergyBand[1] = testBandFreqPane.getHighPassFreq().getValue().doubleValue(); + + for (int j = 0; j < SweepClassifierSet.nControlBands; j++) { + sweepClassifierSet.controlEnergyBand[j][0] = contralBandFreqPanes.get(j).getLowPassFreq().getValue(); + sweepClassifierSet.controlEnergyBand[j][1] = contralBandFreqPanes.get(j).getHighPassFreq().getValue(); + + sweepClassifierSet.energyThresholds[j] = thresholdSpinners.get(j).getValue(); + } + + } + catch (NumberFormatException e) { + return showWarning("Invalid energy band parameter"); + } + if (sweepClassifierSet.testEnergyBand[1] <= sweepClassifierSet.testEnergyBand[0]) { + return showWarning("Energh Bands", "The high test band frequency must be greater than the low test band frequency"); + } + for (int j = 0; j < SweepClassifierSet.nControlBands; j++) { + if (sweepClassifierSet.controlEnergyBand[j][1] <= sweepClassifierSet.controlEnergyBand[j][0]) { + return showWarning("Energh Bands", "The high control band frequency must be greater than the low control band frequency"); + } + } + return true; } @Override protected void disbleControls(boolean disable) { testBandFreqPane.setDisableFreqPane(disable); - contralBandFreqPane1.setDisableFreqPane(disable); - contralBandFreqPane2.setDisableFreqPane(disable); - thresholdSpinner1.setDisable(disable); - thresholdSpinner2.setDisable(disable); + for (int j = 0; j < SweepClassifierSet.nControlBands; j++) { + contralBandFreqPanes.get(j).setDisableFreqPane(disable); + thresholdSpinners.get(j).setDisable(disable); + } } - + } - - + + /** * Block to specify peak frequency to search for. * @author Jamie Macaulay @@ -902,8 +1084,8 @@ public class SweepClassifierSetPaneFX extends SettingsPane { private PamToggleSwitch peakFreqCheckBox; private PamToggleSwitch peakWidthCheckBox; private PamToggleSwitch meanFreqCheckBox; - - + + /** * Pane to set frequency band range */ private FreqBandPane peakFreqPane; @@ -917,46 +1099,63 @@ public class SweepClassifierSetPaneFX extends SettingsPane { super("Peak and Mean Frequency", true); this.getHolderPane().setCenter(createFreqSearchPane()); } - + private Node createFreqSearchPane(){ + int gridy=0; + PamGridPane pamGridPane=new PamGridPane(); pamGridPane.setHgap(5); pamGridPane.setVgap(5); - - + + //search and integration range - pamGridPane.add(new Label("Search Range"),1,0); + pamGridPane.add(new Label("Search Range"),1,gridy); searchRange=new FreqBandPane(Orientation.HORIZONTAL); searchRange.setBandText(""); - pamGridPane.add(searchRange,2,0); - - pamGridPane.add(new Label("Smoothing"), 3,0); - - smoothing=new PamSpinner(3,101,5,2); - smoothing.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); - smoothing.setPrefWidth(100); - pamGridPane.add(smoothing, 4,0); - - pamGridPane.add(new Label("bins"), 5,0); + pamGridPane.add(searchRange,2,gridy); + GridPane.setColumnSpan(searchRange, GridPane.REMAINING); + gridy++; + + pamGridPane.add(new Label("Smooth"), 1,gridy); + + smoothing=new PamSpinner(3,101,5,2); + smoothing.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); + smoothing.setMaxWidth(100); + pamGridPane.add(smoothing, 2,gridy); + + GridPane.setMargin(smoothing, new Insets(0,0,0,5)); //bit of a hack to make sure everything lines up nicely with the frequency pane. + + //GridPane.setHgrow(smoothing, Priority.NEVER); + + pamGridPane.add(new Label("bins"), 3,gridy); + + + gridy++; //peak frequency peakFreqCheckBox=new PamToggleSwitch(""); peakFreqCheckBox.selectedProperty().addListener((obsVal, oldVal, newVal)->{ - peakFreqPane.setDisableFreqPane(!peakWidthCheckBox.isSelected()); + peakFreqPane.setDisableFreqPane(!peakFreqCheckBox.isSelected()); }); - - pamGridPane.add(peakFreqCheckBox,0,1); - - pamGridPane.add(new Label("Peak Frequency"),1,1); + + pamGridPane.add(peakFreqCheckBox,0,gridy); + + pamGridPane.add(new Label("Peak Frequency"),1,gridy); peakFreqPane=new FreqBandPane(Orientation.HORIZONTAL); + //peakFreqPane.setHgap(0); peakFreqPane.setBandText(""); - pamGridPane.add(peakFreqPane,2,1); - + pamGridPane.add(peakFreqPane,2,gridy); + GridPane.setColumnSpan(peakFreqPane, GridPane.REMAINING); + + addValidatorFreqCheck(getValidator(), peakFreqPane, "peak freq. ", "peak_freq"); + + gridy++; + //peak width peakWidthCheckBox=new PamToggleSwitch(""); peakWidthCheckBox.selectedProperty().addListener((obsVal, oldVal, newVal)->{ @@ -965,47 +1164,60 @@ public class SweepClassifierSetPaneFX extends SettingsPane { threshold.setDisable(!peakWidthCheckBox.isSelected()); }); - pamGridPane.add(peakWidthCheckBox,0,2); - - pamGridPane.add(new Label("Peak Width"),1,2); + + pamGridPane.add(peakWidthCheckBox,0,gridy); + pamGridPane.add(new Label("Peak Width"),1,gridy); peakWidthPane=new FreqBandPane(Orientation.HORIZONTAL); peakWidthPane.setBandText(""); - pamGridPane.add(peakWidthPane,2,2); - - pamGridPane.add(new Label("Threshold"), 3,2); + pamGridPane.add(peakWidthPane,2,gridy); + GridPane.setColumnSpan(peakWidthPane, GridPane.REMAINING); + addValidatorFreqCheck(getValidator(), peakWidthPane, "peak width ", "peak_width"); + + gridy++; + + pamGridPane.add(new Label(""), 1,gridy); + threshold=new PamSpinner(1., 300., 6.,1.); threshold.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); threshold.setPrefWidth(100); - - pamGridPane.add(threshold,4,2); - - pamGridPane.add(new Label("dB"), 5,2); + GridPane.setMargin(threshold, new Insets(0,0,0,5)); //bit of a hack to make sure everything lines up nicely with the frequency pane. + pamGridPane.add(threshold,2,gridy); + + pamGridPane.add(new Label("dB"), 3,gridy); + + + gridy++; //mean frequency meanFreqCheckBox=new PamToggleSwitch(""); meanFreqCheckBox.selectedProperty().addListener((obsVal, oldVal, newVal)->{ - meanFreq.setDisableFreqPane(!peakWidthCheckBox.isSelected()); + meanFreq.setDisableFreqPane(!meanFreqCheckBox.isSelected()); }); - - pamGridPane.add(meanFreqCheckBox,0,3); - pamGridPane.add(new Label("Mean Frequency"),1,3); + pamGridPane.add(meanFreqCheckBox,0,gridy); + + pamGridPane.add(new Label("Mean Frequency"),1,gridy); meanFreq=new FreqBandPane(Orientation.HORIZONTAL); meanFreq.setBandText(""); - pamGridPane.add(meanFreq,2,3); - + pamGridPane.add(meanFreq,2,gridy); + GridPane.setColumnSpan(meanFreq, GridPane.REMAINING); + + addValidatorFreqCheck(getValidator(), meanFreq, "mean freq. ", "mean_freq"); + + return pamGridPane; - + } @Override protected void setParams() { - // TODO Auto-generated method stub - + setEnableBox(sweepClassifierSet.enableEnergyBands); + + } @Override @@ -1016,13 +1228,25 @@ public class SweepClassifierSetPaneFX extends SettingsPane { @Override protected void disbleControls(boolean enable) { - // TODO Auto-generated method stub - + peakFreqCheckBox.setDisable(enable); + peakWidthCheckBox.setDisable(enable); + meanFreqCheckBox.setDisable(enable); + + + /** + * Pane to set frequency band range */ + peakFreqPane.setDisable(enable); + smoothing.setDisable(enable); + peakWidthPane.setDisable(enable); + threshold.setDisable(enable); + searchRange.setDisable(enable); + meanFreq.setDisable(enable); } - + } - - + + + /** * Block to specify peak frequency to search for. * @author Jamie Macaulay @@ -1033,12 +1257,12 @@ public class SweepClassifierSetPaneFX extends SettingsPane { /** * Spinner for the minimum number of zero crossings */ - private PamSpinner zeroCorssingsMin; - + private PamSpinner zeroCrossingsMin; + /** * Spinner for the maximum number of zero crossings */ - private PamSpinner zeroCorssingsMax; + private PamSpinner zeroCrossingsMax; /** * Spinner for the minimum zero crossing frequency sweep in kHz/ms @@ -1054,99 +1278,227 @@ public class SweepClassifierSetPaneFX extends SettingsPane { super("Zero Crossings", true); this.getHolderPane().setCenter(createZeroCrossPane()); } - + private Node createZeroCrossPane(){ - + PamGridPane pamGridPane=new PamGridPane(); pamGridPane.setHgap(5); pamGridPane.setVgap(5); - + //Number of zeros crossings - pamGridPane.add(new Label("Number of zero corssings"),0,0); - - zeroCorssingsMin=new PamSpinner(0,999999,0,1); - zeroCorssingsMin.setEditable(true); - zeroCorssingsMin.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); - zeroCorssingsMin.setPrefWidth(100); - pamGridPane.add(zeroCorssingsMin, 1,0); - + Label zeroLabel; + pamGridPane.add(zeroLabel = new Label("Number of zero crossings"),0,0); + + zeroCrossingsMin=new PamSpinner(0,999999,0,1); + zeroCrossingsMin.setEditable(true); + zeroCrossingsMin.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); + zeroCrossingsMin.setPrefWidth(100); + pamGridPane.add(zeroCrossingsMin, 1,0); + pamGridPane.add(new Label("to"),2,0); - - zeroCorssingsMax=new PamSpinner(0,999999,0,1); - zeroCorssingsMax.setEditable(true); - zeroCorssingsMax.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); - zeroCorssingsMax.setPrefWidth(100); - pamGridPane.add(zeroCorssingsMax, 3,0); - + + zeroCrossingsMax=new PamSpinner(0,999999,0,1); + zeroCrossingsMax.setEditable(true); + zeroCrossingsMax.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); + zeroCrossingsMax.setPrefWidth(100); + pamGridPane.add(zeroCrossingsMax, 3,0); + + //this.zeroCrossingsMax=zeroCorssingsMax; + + + + getValidator().createCheck() + .dependsOn("minzero", zeroCrossingsMin.valueProperty()) + .withMethod(c -> { + Integer minZero = c.get("minzero"); + if (minZero>=zeroCrossingsMax.getValue() && isPaneShowing()) { + c.error("Minimum zero corssing must be less than the maximum zero crossing"); + } + }) + .decorates(zeroCrossingsMin) + .immediate(); + + zeroCrossingsMin.valueProperty().addListener((obsVal, oldval, newVal)->{ + getValidator().validate(); //need to make sure the min undecorates if this changes + }); + + + getValidator().createCheck() + .dependsOn("maxzero", zeroCrossingsMax.valueProperty()) + .withMethod(c -> { + try { + Integer maxZero = c.get("maxzero"); + if (maxZero<=zeroCrossingsMin.getValue() && isPaneShowing()) { //For some reason the validator does not work with flip panes. + c.error("Maxmimum zero crossing must be greater than the minimum zero crossing"); + } + } + catch (Exception e) { + e.printStackTrace(); + } + }) + .decorates(zeroCrossingsMax) + .immediate(); + + GraphicDecoration.updateDecorations(zeroCrossingsMax); + // + // zeroCorssingsMax.valueProperty().addListener((obsVal, oldval, newVal)->{ + // getValidator().validate(); //need to make sure the min undecorates if this changes + // }); + + //zero crossing freuquency sweep - + pamGridPane.add(new Label("Zero crossing frequency sweep"),0,1); - + freqZeroMin=new PamSpinner(0.,999999.,0.,1.); freqZeroMin.setEditable(true); freqZeroMin.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); freqZeroMin.setPrefWidth(100); pamGridPane.add(freqZeroMin, 1,1); - + + + + zeroCrossingsMax.valueProperty().addListener((obsVal, oldval, newVal)->{ + getValidator().validate(); //need to make sure the min undecorates if this changes + }); + + pamGridPane.add(new Label("to"),2,1); - + freqZeroMax=new PamSpinner(0.,999999.,0,1); freqZeroMax.setEditable(true); freqZeroMax.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); freqZeroMax.setPrefWidth(100); pamGridPane.add(freqZeroMax, 3,1); - + + getValidator().createCheck() + .dependsOn("minzerofreq", freqZeroMin.valueProperty()) + .withMethod(c -> { + Double minFreq = c.get("minzerofreq"); + if (minFreq>=freqZeroMax.getValue() && isPaneShowing()) { + c.error("Minimum zero crossingsfrequency be less than the minimum."); + } + }) + .decorates(freqZeroMin) + .immediate(); + + + freqZeroMin.valueProperty().addListener((obsVal, oldval, newVal)->{ + getValidator().validate(); //need to make sure the min undecorates if this changes + }); + + + getValidator().createCheck() + .dependsOn("maxzerofreq", freqZeroMax.valueProperty()) + .withMethod(c -> { + Double maxZero = c.get("maxzerofreq"); + if (maxZero<=freqZeroMin.getValue() && isPaneShowing()) { + c.error("Maxmimum zero crossingsfrequency must be greater than the minimum."); + } + }) + .decorates(freqZeroMax) + .immediate(); + + + freqZeroMax.valueProperty().addListener((obsVal, oldval, newVal)->{ + getValidator().validate(); //need to make sure the min undecorates if this changes + }); + + pamGridPane.add(new Label("KHz/ms"),4,1); - + return pamGridPane; - + } @Override protected void setParams() { - // TODO Auto-generated method stub - + setEnableBox(sweepClassifierSet.enableZeroCrossings); + + sweepClassifierSet.checkZCAllocation(); + // setEnableBox(sweepClassifierSet.enableZeroCrossings); + //enableSweep.setSelected(sweepClassifierSet.enableSweep); + + zeroCrossingsMin.getValueFactory().setValue(sweepClassifierSet.nCrossings[0]); + zeroCrossingsMax.getValueFactory().setValue(sweepClassifierSet.nCrossings[1]); + + freqZeroMin.getValueFactory().setValue(sweepClassifierSet.zcSweep[0]); + freqZeroMax.getValueFactory().setValue(sweepClassifierSet.zcSweep[1]); + + getValidator().validate(); //need to make sure the min undecorates if this changes + + // for (int i = 0; i < 2; i++) { + // nZC[i].setText(String.format("%d", sweepClassifierSet.nCrossings[i])); + // zcRate[i].setText(String.format("%3.1f", sweepClassifierSet.zcSweep[i])); + // } + } @Override protected boolean getParams() { - // TODO Auto-generated method stub - return false; + + if (this.getValidator().containsErrors()) { + showValidatorWarning(getValidator()); + return false; + } + + if ((sweepClassifierSet.enableZeroCrossings = enableBox.isSelected()) == true) { + sweepClassifierSet.checkZCAllocation(); + + sweepClassifierSet.nCrossings = new int[2]; + sweepClassifierSet.nCrossings[0] = zeroCrossingsMin.getValue(); + sweepClassifierSet.nCrossings[1] = zeroCrossingsMax.getValue(); + + //return showWarning("Zero Crossings", "Invalid number of zero crossings"); + + } + if ((sweepClassifierSet.enableSweep = enableBox.isSelected()) == true) { + + sweepClassifierSet.zcSweep = new double[2]; + sweepClassifierSet.zcSweep[0] = freqZeroMin.getValue(); + sweepClassifierSet.zcSweep[1] = freqZeroMax.getValue(); + + //return showWarning("Zero Crossings", "Invalid zero crossing sweep parameter"); + } + + return true; } @Override protected void disbleControls(boolean disable) { - zeroCorssingsMin.setDisable(disable); - zeroCorssingsMax.setDisable(disable); + zeroCrossingsMin.setDisable(disable); + zeroCrossingsMax.setDisable(disable); freqZeroMin.setDisable(disable); freqZeroMax.setDisable(disable); } - + } - + /** * Controls to change the minimum and maximum amplitude range for the classifier. * @author Jamie Macaulay * */ private class AmplitudeBlock extends SweepBox { + + private TextField[] ampRange = new TextField[2]; - + public AmplitudeBlock() { super("Amplitude Range", true); setDescription("Set a minimum and maximum click amplitude for this type"); - + PamGridPane gridPane= new PamGridPane(); gridPane.setHgap(5); gridPane.setVgap(5); - + gridPane.add(new Label("Minimum"), 0, 0); gridPane.add(ampRange[0] = new TextField(), 1, 0); gridPane.add(new Label("Maximum"), 2, 0); gridPane.add(ampRange[1] = new TextField(), 3, 0); gridPane.add(new Label("dB"), 4,0); - + this.getHolderPane().setCenter(gridPane); } @@ -1162,10 +1514,18 @@ public class SweepClassifierSetPaneFX extends SettingsPane { for (int i = 0; i < 2; i++) { ampRange[i].setText(String.format("%3.1f", range[i])); } + + getValidator().validate(); //need to make sure the min undecorates if this change } @Override protected boolean getParams() { + + if (this.getValidator().containsErrors()) { + showValidatorWarning(getValidator()); + return false; + } + sweepClassifierSet.testAmplitude = getEnableBox(); if (getEnableBox()) { sweepClassifierSet.amplitudeRange = new double[2]; @@ -1184,17 +1544,181 @@ public class SweepClassifierSetPaneFX extends SettingsPane { @Override protected void disbleControls(boolean disable) { for (int i = 0; i < 2; i++) { - ampRange[i].setDisable(getEnableBox()); + ampRange[i].setDisable(!getEnableBox()); } + + } + } + + /** + * + * Parameters for testing bearing values. + * + * @author Jamie Macaulay + * + */ + private class BearingBlock extends SweepBox { + + /** + * The minimum correlation value. + */ + private JTextField minBearing; + + /** + * The maximum bearing field + */ + private JTextField maxBearing; + + /** + * The enable bearings check box. + */ + private JCheckBox enableBearings; + + /** + * True if using multi-channel data + */ + boolean multiChan = false; + + /** + * Combo box to select whetrher bearings should be kept or excluded within limits. + */ + private JComboBox bearingsExcludeBox; + + + BearingBlock() { + super("Bearings", false); + + JPanel p = new JPanel(); + + minBearing = new JTextField(5); + maxBearing = new JTextField(5); + + bearingsExcludeBox = new JComboBox(); + bearingsExcludeBox.addItem("Include only"); + bearingsExcludeBox.addItem("Exclude"); + + p.setLayout(new GridBagLayout()); + GridBagConstraints c = new PamGridBagContraints(); + + c.gridx = 0; + addComponent(p, enableBearings, c); + c.gridx += c.gridwidth; + addComponent(p, bearingsExcludeBox, c); + c.gridx += c.gridwidth; + addComponent(p, new JLabel("bearings between ", JLabel.RIGHT), c); + c.gridx += c.gridwidth; + addComponent(p, minBearing, c); + c.gridx += c.gridwidth; + addComponent(p, new JLabel(" and ", JLabel.RIGHT), c); + c.gridx += c.gridwidth; + addComponent(p, maxBearing, c); + c.gridx += c.gridwidth; + addComponent(p, new JLabel("(\u00B0)", JLabel.LEFT), c); + + add(BorderLayout.WEST, p); + + this.multiChan = checkMultiChan(); + + } + + @Override + protected void setParams() { + sweepClassifierSet.checkBearingAllocation(); +// setEnableBox(sweepClassifierSet.enableZeroCrossings); + enableBearings.setSelected(sweepClassifierSet.enableBearingLims); + + if (sweepClassifierSet.excludeBearingLims) bearingsExcludeBox.setSelectedIndex(1); + else bearingsExcludeBox.setSelectedIndex(0); + + this.minBearing.setText(String.format("%3.1f", Math.toDegrees(sweepClassifierSet.bearingLims[0]))); + this.maxBearing.setText(String.format("%3.1f", Math.toDegrees(sweepClassifierSet.bearingLims[1]))); + + this.multiChan = checkMultiChan(); + } + + + @Override + protected boolean getParams() { + if (enableBearings.isSelected()) { + + sweepClassifierSet.enableBearingLims = enableBearings.isSelected(); + sweepClassifierSet.excludeBearingLims = bearingsExcludeBox.getSelectedIndex()==1 ? true : false; + + try { + sweepClassifierSet.bearingLims[0] = Math.toRadians(Double.valueOf(minBearing.getText())); + } + catch (NumberFormatException e) { + return showWarning("Invalid minimum correlation value"); + } + + try { + sweepClassifierSet.bearingLims[1] = Math.toRadians(Double.valueOf(maxBearing.getText())); + } + catch (NumberFormatException e) { + return showWarning("Invalid maximum bearing limits value"); + } + } + return true; + } + + @Override + protected void enableControls() { + checkMultiChan(); + + enableBearings.setEnabled(multiChan); + bearingsExcludeBox.setEnabled(multiChan); + minBearing.setEnabled(multiChan); + maxBearing.setEnabled(multiChan); + + if (!multiChan) return; + + bearingsExcludeBox.setEnabled(enableBearings.isSelected()); + minBearing.setEnabled(enableBearings.isSelected()); + maxBearing.setEnabled(enableBearings.isSelected()); + } + + @Override + protected void disbleControls(boolean disable) { + // TODO Auto-generated method stub } } - /**~*main set and get params functions***/ + /** + * Check whether the click classifier is set up for multi-channel and set + * the dialog components uprightly + */ + private boolean checkMultiChan() { + boolean multiChan = false; + //do we have multi-channel clicks? + if (clickControl!=null) { + int[] chanGroups = clickControl.getClickParameters().getGroupedSourceParameters().getChannelGroups(); + multiChan = false; + + if (chanGroups==null) return multiChan; + + for (int i=0; i1) { + multiChan = true; + break; + } + } + } + else multiChan = true; +// Debug.out.println("Check multi-channel: " + multiChan); + + return multiChan; + } + + + /**~*main set and get params functions***/ + @Override public ClickTypeProperty getParams(ClickTypeProperty clickTypeProperty) { - + //set the classifier optionBox.getParams(); clickLength.getParams(); @@ -1205,16 +1729,16 @@ public class SweepClassifierSetPaneFX extends SettingsPane { amplitudeBlock.getParams(); currentClickProperty.setClickType(sweepClassifierSet); - + return currentClickProperty; } @Override public void setParams(ClickTypeProperty clickTypeProperty) { - + this.sweepClassifierSet=(SweepClassifierSet) clickTypeProperty.getClickType(); this.currentClickProperty=clickTypeProperty; - + optionBox.setParams(); clickLength.setParams(); filterBox.setParams(); @@ -1222,7 +1746,7 @@ public class SweepClassifierSetPaneFX extends SettingsPane { freqBox.setParams(); zeroCrossingsBox.setParams(); amplitudeBlock.setParams(); - + } @Override @@ -1238,7 +1762,7 @@ public class SweepClassifierSetPaneFX extends SettingsPane { @Override public void paneInitialized() { // TODO Auto-generated method stub - + } @@ -1246,10 +1770,97 @@ public class SweepClassifierSetPaneFX extends SettingsPane { return optionBox.getNameLabel().textProperty(); } + + + + /** + * Add a validator check to the frequency band pane to prevent minimum and maximum frequencies being above or below themselves and + * the maximum frequency being above Nyquist. + * @param freqBandPane - the frequency band pane. + * @param name - the name for user interface + * @param ID - the ID of the check. + */ + private void addValidatorFreqCheck(Validator validator, FreqBandPane freqBandPane, String name, String ID) { + + validator.createCheck() + .dependsOn("minfreq_"+ID, freqBandPane.getHighPassFreq().valueProperty()) + .withMethod(c -> { + Double minfreq = c.get("minfreq_"+ID); + if (minfreq>=freqBandPane.getLowPassFreq().getValue() && isPaneShowing()) { + c.error("Minimum frequency in " + name + "must be lower than the maximum frequency "); + } + }) + .decorates(freqBandPane.getHighPassFreq()) + .immediate(); + + validator.createCheck() + .dependsOn("maxfreq_"+ID, freqBandPane.getLowPassFreq().valueProperty()) + .withMethod(c -> { + Double maxFreq = c.get("maxfreq_"+ID); + if (maxFreq{ + validator.validate(); + }); + + freqBandPane.getHighPassFreq().valueProperty().addListener((obsVal, oldVal, newVal)->{ + validator.validate(); + }); + + + validator.createCheck() + .dependsOn("maxfreq_samplerate_"+ID, freqBandPane.getLowPassFreq().valueProperty()) + .withMethod(c -> { + Double maxFreq = c.get("maxfreq_samplerate_"+ID); + if (maxFreq>sweepClassifier.getClickDetector().getSampleRate()/2 && isPaneShowing()) { + c.error("The maximum frequency for " + name + " cannot be above the Nyquist frequency of " + sweepClassifier.getClickDetector().getSampleRate()/2 + "Hz"); + } + }) + .decorates(freqBandPane.getLowPassFreq()) + .immediate(); + + } + private boolean showWarning(String string) { PamDialogFX.showWarning(string); return false; } + + private boolean showWarning(String string, String string2) { + //PamController.getInstance(); + PamDialogFX.showWarning(null, string, string2); + return false; + } + + + /** + * Show a warning from the validator. + * @param validator - the validator to show warning for. + */ + private void showValidatorWarning(Validator validator) { + List validatorMessages = validator.getValidationResult().getMessages(); + + String messages = ""; + for (int i=0; i lowPassFreq; + private PamSpinner lowPassFreq; /** * Layout of the pane- either horizontal or vertical @@ -65,14 +67,14 @@ public class FreqBandPane extends PamGridPane { this.setHgap(5); this.setVgap(5); - highPassFreq=new PamSpinner(10.,500000.,1000.,2000.); + highPassFreq=new PamSpinner(0.,500000.,1000.,2000.); highPassFreq.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); - highPassFreq.getValueFactory().valueProperty().addListener((obs, before, after)->{ - if (after>=lowPassFreq.getValue()) lowPassFreq.getValueFactory().setValue(Math.min(sampleRate/2.,highPassFreq.getValue()+100)); - if (after>sampleRate/2.) highPassFreq.getValueFactory().setValue(sampleRate/2.); - }); +// highPassFreq.getValueFactory().valueProperty().addListener((obs, before, after)->{ +// if (after>=lowPassFreq.getValue()) lowPassFreq.getValueFactory().setValue(Math.min(sampleRate/2.,highPassFreq.getValue()+100)); +// if (after>sampleRate/2.) highPassFreq.getValueFactory().setValue(sampleRate/2.); +// }); highPassFreq.setEditable(true); - //highPassFreq.setPrefWidth(140); + highPassFreq.setMinWidth(FREQ_SPINNER_WIDTH); //highCut.setPrefColumnCount(6); if (orientation==Orientation.VERTICAL){ @@ -86,15 +88,15 @@ public class FreqBandPane extends PamGridPane { this.add(highPassHzLabel=new Label("Hz"), 2, 0); } - lowPassFreq=new PamSpinner(1.,500000.,2000.,2000.); + lowPassFreq=new PamSpinner(0.,500000.,2000.,2000.); lowPassFreq.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); - lowPassFreq.getValueFactory().valueProperty().addListener((obs, before, after)->{ - if (after<=highPassFreq.getValue()) highPassFreq.getValueFactory().setValue(Math.min(0,lowPassFreq.getValue()-100)); - if (after>sampleRate/2.) lowPassFreq.getValueFactory().setValue(sampleRate/2.); - - }); +// lowPassFreq.getValueFactory().valueProperty().addListener((obs, before, after)->{ +// if (after<=highPassFreq.getValue()) highPassFreq.getValueFactory().setValue(Math.min(0,lowPassFreq.getValue()-100)); +// if (after>sampleRate/2.) lowPassFreq.getValueFactory().setValue(sampleRate/2.); +// +// }); lowPassFreq.setEditable(true); - //lowPassFreq.setPrefWidth(140); + lowPassFreq.setMinWidth(FREQ_SPINNER_WIDTH); if (orientation==Orientation.VERTICAL){ diff --git a/src/pamViewFX/fxNodes/utilityPanes/GroupedSourcePaneFX.java b/src/pamViewFX/fxNodes/utilityPanes/GroupedSourcePaneFX.java index c8a3ebbe..c2fe9295 100644 --- a/src/pamViewFX/fxNodes/utilityPanes/GroupedSourcePaneFX.java +++ b/src/pamViewFX/fxNodes/utilityPanes/GroupedSourcePaneFX.java @@ -17,6 +17,7 @@ import pamViewFX.PamGuiManagerFX; import pamViewFX.fxNodes.PamGridPane; import pamViewFX.fxNodes.PamHBox; import pamViewFX.fxNodes.PamVBox; +import pamViewFX.validator.PamValidator; import PamUtils.PamUtils; import PamView.GroupedSourceParameters; import PamguardMVC.PamConstants; @@ -76,7 +77,7 @@ public class GroupedSourcePaneFX extends SourcePaneFX { @Override protected void createPanel() { - channelValidator = new Validator(); + channelValidator = new PamValidator(); sourcePane=new PamGridPane(); sourcePane.setVgap(5); diff --git a/src/pamViewFX/validator/PamValidator.java b/src/pamViewFX/validator/PamValidator.java new file mode 100644 index 00000000..54d4b3c6 --- /dev/null +++ b/src/pamViewFX/validator/PamValidator.java @@ -0,0 +1,17 @@ +package pamViewFX.validator; + +import net.synedra.validatorfx.Validator; + +/** + * Extension of the validator class to add PAMGuard specific functions. + * @author Jamie Macaulay + * + */ +public class PamValidator extends Validator { + + public PamValidator() { + super(); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/rawDeepLearningClassifier/dataPlotFX/DLPredictionPlotInfoFX.java b/src/rawDeepLearningClassifier/dataPlotFX/DLPredictionPlotInfoFX.java index 90672357..aa1f5739 100644 --- a/src/rawDeepLearningClassifier/dataPlotFX/DLPredictionPlotInfoFX.java +++ b/src/rawDeepLearningClassifier/dataPlotFX/DLPredictionPlotInfoFX.java @@ -22,6 +22,7 @@ import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; import javafx.scene.shape.Polygon; import rawDeepLearningClassifier.DLControl; +import rawDeepLearningClassifier.dlClassification.DLClassName; import rawDeepLearningClassifier.dlClassification.DLDataUnit; /** @@ -79,6 +80,16 @@ public class DLPredictionPlotInfoFX extends GenericLinePlotInfo { probabilityScaleInfo = new GenericScaleInfo(-0.1, 1.1, ParameterType.PROBABILITY, ParameterUnits.PROBABILITY); frequencyInfo = new GenericScaleInfo(0, 1, ParameterType.FREQUENCY, ParameterUnits.HZ); + + DLClassName[] classNames = getDlControl().getDLModel().getClassNames(); + + //make sure this is initialised otherwise the plot won't work when first created. + if (dlPredParams.lineInfos==null ) dlPredParams.lineInfos = new LineInfo[classNames.length]; + for (int i=0; i { // Thread.currentThread().setContextClassLoader(newCL); // } - //first open the model and get the correct parameters. - genericModel = new PamGenericModel(genericParams.modelPath); +// if (genericModel!=null) { +// System.out.println(Paths.get(genericModel.getModel().getName())); +// System.out.println(Paths.get(genericParams.modelPath)); +// System.out.println(Paths.get(genericModel.getModel().getName()).equals(Paths.get(genericParams.modelPath))); +// } + + //first open the model and get the correct parameters. + //21/11/2022 - Added a null and filename check here to stop the mdoel reloading everytime PAMGuard hits a new file or + //is stopped or started - this was causing a memory leak. + if (genericModel==null || !Paths.get(genericModel.getModel().getName()).equals(Paths.get(genericParams.modelPath))) { + //System.out.println(Paths.get(genericParams.modelPath)); + genericModel = new PamGenericModel(genericParams.modelPath); + + //System.out.println("LOAD A NEW MODEL: "); + //System.out.println(genericModel.getModel().getModelPath().getFileName()); + } //is this a waveform or a spectrogram model? DLTransform transform = genericParams.dlTransfroms.get(genericParams.dlTransfroms.size()-1); diff --git a/src/rawDeepLearningClassifier/dlClassification/genericModel/PamGenericModel.java b/src/rawDeepLearningClassifier/dlClassification/genericModel/PamGenericModel.java index b06f38cc..f81da14d 100644 --- a/src/rawDeepLearningClassifier/dlClassification/genericModel/PamGenericModel.java +++ b/src/rawDeepLearningClassifier/dlClassification/genericModel/PamGenericModel.java @@ -55,7 +55,7 @@ public class PamGenericModel { */ private Shape outShape = null; - + private SpectrogramTranslator specTranslator; @@ -64,6 +64,8 @@ public class PamGenericModel { public PamGenericModel(String modelPath) throws MalformedModelException, IOException{ + + //System.out.println("NEW GENERIC MODEL:"); File file = new File(modelPath); @@ -95,7 +97,6 @@ public class PamGenericModel { if (model == null) { System.err.println("Generic Model: Could not load model: " + modelPath); } - else { if (model!=null && model.describeInput()!=null) { System.out.println("Generic Model: Input: " + model.describeInput().toString()); @@ -117,7 +118,6 @@ public class PamGenericModel { //predictor for the model if using wavePredictor = model.newPredictor(waveTranslator); - } } @@ -201,8 +201,6 @@ public class PamGenericModel { } - - public Model getModel() { return model; } diff --git a/src/rawDeepLearningClassifier/dlClassification/ketos/KetosWorker.java b/src/rawDeepLearningClassifier/dlClassification/ketos/KetosWorker.java index 546f5b89..d39c40ce 100644 --- a/src/rawDeepLearningClassifier/dlClassification/ketos/KetosWorker.java +++ b/src/rawDeepLearningClassifier/dlClassification/ketos/KetosWorker.java @@ -1,6 +1,7 @@ package rawDeepLearningClassifier.dlClassification.ketos; import java.io.File; +import java.nio.file.Paths; import java.util.ArrayList; import org.jamdev.jdl4pam.ketos.KetosModel; @@ -15,6 +16,7 @@ import PamModel.PamModel.PluginClassloader; import rawDeepLearningClassifier.DLControl; import rawDeepLearningClassifier.dlClassification.animalSpot.StandardModelParams; import rawDeepLearningClassifier.dlClassification.genericModel.DLModelWorker; +import rawDeepLearningClassifier.dlClassification.genericModel.PamGenericModel; /** * @@ -30,7 +32,12 @@ public class KetosWorker extends DLModelWorker { /** * The ketos model */ - private KetosModel ketosModel; + private KetosModel ketosModel; + + /** + * Thelast loaded model path., + */ + private String currentPath; /** @@ -56,7 +63,15 @@ public class KetosWorker extends DLModelWorker { Thread.currentThread().setContextClassLoader(newCL); } //first open the model and get the correct parameters. - ketosModel = new KetosModel(new File(ketosDLParams.modelPath)); + //21/11/2022 - Added a null and filename check here to stop the mdoel reloading everytime PAMGuard hits a new file or + //is stopped or started - this was causing a memory leak. + if (ketosModel==null || currentPath ==null || !Paths.get(currentPath).equals(Paths.get(ketosDLParams.modelPath))) { + //System.out.println(Paths.get(genericParams.modelPath)); + this.currentPath = ketosDLParams.modelPath; + ketosModel = new KetosModel(new File(ketosDLParams.modelPath)); + //System.out.println("LOAD A NEW MODEL: "); + //System.out.println(genericModel.getModel().getModelPath().getFileName()); + } } catch (Exception e) { e.printStackTrace(); diff --git a/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/DataTransformPaneFactory.java b/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/DataTransformPaneFactory.java index c8010c09..04e3299c 100644 --- a/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/DataTransformPaneFactory.java +++ b/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/DataTransformPaneFactory.java @@ -91,7 +91,8 @@ public class DataTransformPaneFactory { case SPECTROGRAM: settingsPane = new FFTTransformPane((SimpleTransform) dlTransfrom, new String[]{"FFT Length ", "FFT Hop"}, new String[]{"", ""}); // ((SimpleTransformPane) settingsPane).setSpinnerMinMaxValues(0, 4, Integer.MAX_VALUE, 4); - ((SimpleTransformPane) settingsPane).setSpinnerMinMaxValues(1, 4, Integer.MAX_VALUE, 4); + + ((FFTTransformPane) settingsPane).setSpinnerMinMaxValues(1, 4, Integer.MAX_VALUE, 4); // //make an FFT spinner here with doubling FFT lengths - DOES NOT WORK FOR SOME REASON... // ((SimpleTransformPane) settingsPane).getSpinners().get(0).setValueFactory(new SpinnerValueFactory.ListSpinnerValueFactory<>(createStepList())); // ((SimpleTransformPane) settingsPane).getSpinners().get(0).getValueFactory().setValue(4); diff --git a/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/SimpleTransformPane.java b/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/SimpleTransformPane.java index 2d987963..21bcf508 100644 --- a/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/SimpleTransformPane.java +++ b/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/SimpleTransformPane.java @@ -89,7 +89,7 @@ public class SimpleTransformPane extends DLTransformPane { int row = 0; int column = 0; - if (simpleTransfrom.getParams()!=null) { +// if (simpleTransfrom.getParams()!=null) { for (int i=0; i