From 2ab6b5ec669c4224510a1fb74d157e7d72c46786 Mon Sep 17 00:00:00 2001 From: Jamie Mac Date: Mon, 13 Mar 2023 16:55:53 +0000 Subject: [PATCH] Updates to JFX version --- src/clickDetector/ClickTemplate.java | 1 - .../dlClassification/ketos/KetosWorker.java | 3 +- .../layoutFX/FFTSpinnerBug.java | 67 +++++++++++++++++++ .../layoutFX/FFTSpinnerBugLauncher.java | 11 +++ .../dlTransfroms/FFTTransformPane.java | 9 ++- .../dlTransfroms/SimpleTransformPane.java | 3 +- 6 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 src/rawDeepLearningClassifier/layoutFX/FFTSpinnerBug.java create mode 100644 src/rawDeepLearningClassifier/layoutFX/FFTSpinnerBugLauncher.java diff --git a/src/clickDetector/ClickTemplate.java b/src/clickDetector/ClickTemplate.java index 61a4b4ef..3d778229 100644 --- a/src/clickDetector/ClickTemplate.java +++ b/src/clickDetector/ClickTemplate.java @@ -1,7 +1,6 @@ package clickDetector; import java.awt.Color; -import java.awt.Paint; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; diff --git a/src/rawDeepLearningClassifier/dlClassification/ketos/KetosWorker.java b/src/rawDeepLearningClassifier/dlClassification/ketos/KetosWorker.java index d39c40ce..b52a22b7 100644 --- a/src/rawDeepLearningClassifier/dlClassification/ketos/KetosWorker.java +++ b/src/rawDeepLearningClassifier/dlClassification/ketos/KetosWorker.java @@ -84,7 +84,8 @@ public class KetosWorker extends DLModelWorker { String jsonString = DLTransformsParser.readJSONString(new File(ketosModel.getAudioReprFile())); //convert the JSON string to a parameters object. - KetosParams ketosParams = new KetosParams(jsonString); + KetosParams ketosParams = new KetosParams(jsonString); + //important to add this for Ketos models because the JSON string does not necessarily contain and output shape. //System.out.println("----Default output shape: " + ketosParams.defaultOutputShape + " " + ketosModel.getOutShape()); if (ketosParams.defaultOutputShape==null) { diff --git a/src/rawDeepLearningClassifier/layoutFX/FFTSpinnerBug.java b/src/rawDeepLearningClassifier/layoutFX/FFTSpinnerBug.java new file mode 100644 index 00000000..8671d5e8 --- /dev/null +++ b/src/rawDeepLearningClassifier/layoutFX/FFTSpinnerBug.java @@ -0,0 +1,67 @@ +package rawDeepLearningClassifier.layoutFX; + +import javafx.application.Application; +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.control.SpinnerValueFactory.ListSpinnerValueFactory; +import javafx.stage.Stage; +import javafx.util.StringConverter; +import pamViewFX.fxNodes.PamBorderPane; +import pamViewFX.fxNodes.PamSpinner; +import rawDeepLearningClassifier.layoutFX.dlTransfroms.FFTTransformPane; + +public class FFTSpinnerBug extends Application{ + + protected static final String INITAL_VALUE = "0"; + + public static void main(String[] args) { + Application.launch(args); + } + + @Override + public void start(Stage stage) { + //System.out.println("Create step list: " + createStepList().size()); + PamSpinner spinner = new PamSpinner(FFTTransformPane.createStepList()); + spinner.getValueFactory().setConverter(new NumberConverter()); + spinner.setPrefWidth(80); + + PamBorderPane pane = new PamBorderPane(); + + pane.setCenter(spinner); + + pane.setPadding(new Insets(20,20,20,20)); + + Scene scene = new Scene(pane, 350, 300); + + System.out.println("Size before: " + ((ListSpinnerValueFactory) spinner.getValueFactory()).getItems().size()); + spinner.getValueFactory().setValue(1019); + System.out.println("Size after: " + ((ListSpinnerValueFactory) spinner.getValueFactory()).getItems().size()); + + + for (int i=0; i<((ListSpinnerValueFactory) spinner.getValueFactory()).getItems().size(); i++) { + System.out.println("List value: " + i + ": " + ((ListSpinnerValueFactory) spinner.getValueFactory()).getItems().get(i)); + + } + + stage.setTitle("Hello Spinner"); + stage.setScene(scene); + stage.show(); + } + + + class NumberConverter extends StringConverter { + @Override + public String toString(Number object) { + // TODO Auto-generated method stub + return object.toString(); + } + + @Override + public Number fromString(String string) { + return Integer.valueOf(string); + } + + } + + +} diff --git a/src/rawDeepLearningClassifier/layoutFX/FFTSpinnerBugLauncher.java b/src/rawDeepLearningClassifier/layoutFX/FFTSpinnerBugLauncher.java new file mode 100644 index 00000000..f1adec21 --- /dev/null +++ b/src/rawDeepLearningClassifier/layoutFX/FFTSpinnerBugLauncher.java @@ -0,0 +1,11 @@ +package rawDeepLearningClassifier.layoutFX; + + +public class FFTSpinnerBugLauncher { + + public static void main(String[] args) { + FFTSpinnerBug.main(args); + } + + +} diff --git a/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/FFTTransformPane.java b/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/FFTTransformPane.java index 3fb80d6e..2c8bb696 100644 --- a/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/FFTTransformPane.java +++ b/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/FFTTransformPane.java @@ -9,7 +9,7 @@ import pamViewFX.fxNodes.PamSpinner; import javafx.util.StringConverter; /** - * Transform pane for fourier transform + * Transform pane for Fourier transform * @author Jamie Macaulay * */ @@ -29,7 +29,6 @@ public class FFTTransformPane extends SimpleTransformPane { return spinner; } else return super.createSpinner(i); - } @@ -46,8 +45,9 @@ public class FFTTransformPane extends SimpleTransformPane { return stepSizeListLength; } + + class NumberConverter extends StringConverter { - @Override public String toString(Number object) { // TODO Auto-generated method stub @@ -61,4 +61,7 @@ public class FFTTransformPane extends SimpleTransformPane { } + + + } diff --git a/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/SimpleTransformPane.java b/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/SimpleTransformPane.java index 21bcf508..386bff18 100644 --- a/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/SimpleTransformPane.java +++ b/src/rawDeepLearningClassifier/layoutFX/dlTransfroms/SimpleTransformPane.java @@ -191,6 +191,7 @@ public class SimpleTransformPane extends DLTransformPane { //Set the new numbers Number[] params = new Number[spinners.size()]; for (int i=0; i