From 0ddaac2318e041934269f7fcc3a4a2028325f9ad Mon Sep 17 00:00:00 2001 From: Ian Robinson Date: Wed, 31 Aug 2022 17:51:27 -0400 Subject: [PATCH 1/4] initial cleanup --- .../tripoli/gui/dataViews/plots/BeamShapeLinePlot.java | 4 ++-- .../peakShapePlots/PeakShapesTaskExperiment.java | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapesTaskExperiment.java diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/BeamShapeLinePlot.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/BeamShapeLinePlot.java index 613de60f..bc77cbf9 100644 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/BeamShapeLinePlot.java +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/BeamShapeLinePlot.java @@ -97,8 +97,8 @@ public void paint(GraphicsContext g2d) { g2d.stroke(); g2d.setFill(Paint.valueOf("Red")); - g2d.fillOval(mapX(xAxisData[leftBoundary]) - 2, mapY(yAxisData[leftBoundary]) - 4, 7, 7); - g2d.fillOval(mapX(xAxisData[rightBoundary]) - 2, mapY(yAxisData[rightBoundary]) - 4, 7, 7); + g2d.fillOval(mapX(xAxisData[leftBoundary]) - 3.5, mapY(yAxisData[leftBoundary]) - 3.5, 7, 7); + g2d.fillOval(mapX(xAxisData[rightBoundary]) - 3.5, mapY(yAxisData[rightBoundary]) - 3.5, 7, 7); g2d.beginPath(); g2d.setLineDashes(0); diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapesTaskExperiment.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapesTaskExperiment.java deleted file mode 100644 index ff1c6da8..00000000 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapesTaskExperiment.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.cirdles.tripoli.gui.dataViews.plots.plotsControllers.peakShapePlots; - -public class PeakShapesTaskExperiment { -} From 5cbebce133013317bf4d5e2a1b048b3da4b431ad Mon Sep 17 00:00:00 2001 From: Ian Robinson Date: Thu, 1 Sep 2022 10:42:33 -0400 Subject: [PATCH 2/4] codacy cleanup --- .../PeakShapePlotsController.java | 57 ------------------- .../peakShapePlots/PeakShapePlotsWindow.java | 4 +- .../PeakShapeProcessor_OPPhoenix.java | 13 +++-- .../utilities/mathUtilities/MatLabTest.java | 10 ---- .../mathUtilities/SplineBasisModelTest.java | 10 ---- 5 files changed, 9 insertions(+), 85 deletions(-) diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsController.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsController.java index ee2a379d..ae444b2f 100644 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsController.java +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsController.java @@ -269,63 +269,6 @@ public void processFilesAndShowPeakCentre(String groupValue) { double[] finalYAxis; double[] finalXAxis; -// PeakShapesService service; -// // Trying to get data from peakShapeTask -// for (int j = 0; j < fileGroups.size(); j++) { -// if (fileGroups.get(j).equalsIgnoreCase(groupValue)) { -// for (int h = 0; h < resourceGroups.get(j).size(); h++) { -// final double[] testXAxis = new double[resourceGroups.get(j).size()]; -// final double[] testYAxis = new double[resourceGroups.get(j).size()]; -// -// testXAxis[h] = h + 1; -// for (int i = 0; i < resourceGroups.get(j).size(); i++) { -// resourceBrowserTarget = resourceGroups.get(j).get(i); -// service = new PeakShapesService(resourceBrowserTarget.toPath()); -// service.start(); -// int finalI = i; -// int finalJ = j; -// PeakShapesService finalService = service; -// service.setOnSucceeded(evt -> { -// if (finalI != resourceGroups.get(finalJ).size() - 1) { -// AbstractPlotBuilder beamShapePlotBuilder = ((PeakShapesTask) finalService.getPeakShapesTask()).getBeamShapePlotBuilder(); -// AbstractPlotBuilder gBeamPlotBuilder = ((PeakShapesTask) finalService.getPeakShapesTask()).getGBeamPlotBuilder(); -// testYAxis[finalI] = ((PeakShapesTask) finalService.getPeakShapesTask()).getPeakWidth(); -// } else { -// LinePlotBuilder peakCentrePlotBuilder = LinePlotBuilder.initializeLinePlot(testXAxis, testYAxis, "PeakCentre Plot"); -// -// AbstractDataView peakCentreLinePlot = new PeakCentresLinePlot(new Rectangle(peakCentrePlotScrollPane.getWidth(), peakCentrePlotScrollPane.getHeight()), peakCentrePlotBuilder); -// -// peakCentrePlotScrollPane.widthProperty().addListener(new ChangeListener() { -// @Override -// public void changed(ObservableValue observable, Number oldValue, Number newValue) { -// peakCentreLinePlot.setMyWidth(newValue.intValue()); -// peakCentreLinePlot.repaint(); -// } -// }); -// -// peakCentrePlotScrollPane.heightProperty().addListener(new ChangeListener() { -// @Override -// public void changed(ObservableValue observable, Number oldValue, Number newValue) { -// peakCentreLinePlot.setMyHeight(newValue.intValue()); -// peakCentreLinePlot.repaint(); -// } -// }); -// -// peakCentreLinePlot.preparePanel(); -// peakCentrePlotScrollPane.setContent(peakCentreLinePlot); -// resourceBrowserTarget = null; -// } -// -// }); -// -// } -// System.out.println(Arrays.toString(testXAxis)); -// } -// -// } -// } - - // Work in progress todo double[] xAxis = new double[resourceGroups.get(groupValue).size()]; double[] yAxis = new double[resourceGroups.get(groupValue).size()]; for (int k = 0; k < resourceGroups.get(groupValue).size(); k++) { diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsWindow.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsWindow.java index 0afc9f28..84bdd4cd 100644 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsWindow.java +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsWindow.java @@ -35,8 +35,8 @@ public class PeakShapePlotsWindow { public static final double PLOT_WINDOW_HEIGHT = 600.0; public static final double SCROLLBAR_THICKNESS = 15.0; public static Window plottingWindow; - private final double xOffset = 0; - private final double yOffset = 0; +// private final double xOffset = 0; +// private final double yOffset = 0; public Stage plottingStage; private Stage primaryStage; diff --git a/TripoliCore/src/main/java/org/cirdles/tripoli/sessions/analysis/massSpectrometerModels/dataSourceProcessors/PeakShapeProcessor_OPPhoenix.java b/TripoliCore/src/main/java/org/cirdles/tripoli/sessions/analysis/massSpectrometerModels/dataSourceProcessors/PeakShapeProcessor_OPPhoenix.java index 3e57c0cf..9dd4470b 100644 --- a/TripoliCore/src/main/java/org/cirdles/tripoli/sessions/analysis/massSpectrometerModels/dataSourceProcessors/PeakShapeProcessor_OPPhoenix.java +++ b/TripoliCore/src/main/java/org/cirdles/tripoli/sessions/analysis/massSpectrometerModels/dataSourceProcessors/PeakShapeProcessor_OPPhoenix.java @@ -60,15 +60,16 @@ public PeakShapeOutputDataRecord prepareInputDataModelFromFile(Path inputDataFil for (String line : contentsByLine) { if (!line.isEmpty()) { switch (phase) { - case 0 -> headerLine.add(line.split("\\s*,\\s*")); - case 1 -> columnNames.add(line.split("\\s*,\\s*")); - case 2 -> { + case 0: + headerLine.add(line.split("\\s*,\\s*")); + case 1: + columnNames.add(line.split("\\s*,\\s*")); + case 2: String[] cols = line.split("\\s*,\\s*"); masses.add(Double.parseDouble(cols[0])); intensity.add(Double.parseDouble(cols[1])); - } - default -> { - } + default: + break; } if (phase == 1) { diff --git a/TripoliCore/src/test/java/org/cirdles/tripoli/utilities/mathUtilities/MatLabTest.java b/TripoliCore/src/test/java/org/cirdles/tripoli/utilities/mathUtilities/MatLabTest.java index fbebe277..684a5b9c 100644 --- a/TripoliCore/src/test/java/org/cirdles/tripoli/utilities/mathUtilities/MatLabTest.java +++ b/TripoliCore/src/test/java/org/cirdles/tripoli/utilities/mathUtilities/MatLabTest.java @@ -1,7 +1,5 @@ package org.cirdles.tripoli.utilities.mathUtilities; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.ojalgo.matrix.store.MatrixStore; import org.ojalgo.matrix.store.PhysicalStore; @@ -14,14 +12,6 @@ class MatLabTest { - @BeforeEach - void setUp() { - } - - @AfterEach - void tearDown() { - } - @Test void kronTest() { PhysicalStore.Factory storeFactory = Primitive64Store.FACTORY; diff --git a/TripoliCore/src/test/java/org/cirdles/tripoli/utilities/mathUtilities/SplineBasisModelTest.java b/TripoliCore/src/test/java/org/cirdles/tripoli/utilities/mathUtilities/SplineBasisModelTest.java index 40910aa5..76b14ffc 100644 --- a/TripoliCore/src/test/java/org/cirdles/tripoli/utilities/mathUtilities/SplineBasisModelTest.java +++ b/TripoliCore/src/test/java/org/cirdles/tripoli/utilities/mathUtilities/SplineBasisModelTest.java @@ -1,7 +1,5 @@ package org.cirdles.tripoli.utilities.mathUtilities; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.ojalgo.matrix.store.MatrixStore; import org.ojalgo.matrix.store.Primitive64Store; @@ -12,14 +10,6 @@ class SplineBasisModelTest { - @BeforeEach - void setUp() { - } - - @AfterEach - void tearDown() { - } - @Test void bBase() { Primitive64Store test = MatLab.linspace(204.83994725925928, 205.10565274074074, 1000); From dd783d3b0d964137c9fd77b76f4eb15dc4d086c7 Mon Sep 17 00:00:00 2001 From: Ian Robinson Date: Thu, 1 Sep 2022 19:08:40 -0400 Subject: [PATCH 3/4] PeakProcessor fix and key pressed added --- .../PeakShapePlotsController.java | 24 ++++++++++++++++++- .../PeakShapeProcessor_OPPhoenix.java | 15 ++++++------ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsController.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsController.java index ae444b2f..c8d209cd 100644 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsController.java +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsController.java @@ -4,6 +4,7 @@ import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.control.*; +import javafx.scene.input.KeyCode; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.VBox; import javafx.scene.shape.Rectangle; @@ -205,8 +206,8 @@ private void populateListOfGroups() { listViewOfGroupResourcesInFolder.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { // Files will be manipulated here when group is selected processFilesAndShowPeakCentre(newValue); - populateListOfResources(newValue); setCurrentGroup(newValue); + populateListOfResources(newValue); gBeamPlotScrollPane.setContent(null); beamShapePlotScrollPane.setContent(null); eventLogTextArea.textProperty().unbind(); @@ -242,10 +243,18 @@ private void populateListOfResources(String groupValue) { listViewOfResourcesInFolder = new ListView<>(); listViewOfResourcesInFolder.setCellFactory(param -> new ResourceDisplayName2()); eventLogTextArea.textProperty().unbind(); + int initialIndex; ObservableList items = FXCollections.observableArrayList(resourceGroups.get(groupValue)); listViewOfResourcesInFolder.setItems(items); + listViewOfResourcesInFolder.getSelectionModel().selectFirst(); + resourceBrowserTarget = listViewOfResourcesInFolder.getSelectionModel().getSelectedItem(); + initialIndex = listViewOfResourcesInFolder.getSelectionModel().getSelectedIndex(); + processDataFileAndShowPlotsOfPeakShapes(); + peakCentreLinePlot.getGraphicsContext2D().setLineWidth(1.0); + peakCentreLinePlot.getGraphicsContext2D().strokeOval(peakCentreLinePlot.mapX(peakCentreLinePlot.getxAxisData()[initialIndex]) - 6, peakCentreLinePlot.mapY(peakCentreLinePlot.getyAxisData()[initialIndex]) - 6, 12, 12); + listViewOfResourcesInFolder.setOnMouseClicked(click -> { peakCentreLinePlot.repaint(); @@ -259,6 +268,19 @@ private void populateListOfResources(String groupValue) { } }); + listViewOfResourcesInFolder.setOnKeyPressed(key -> { + peakCentreLinePlot.repaint(); + int index; + if (key.getCode() == KeyCode.DOWN || key.getCode() == KeyCode.UP) { + resourceBrowserTarget = listViewOfResourcesInFolder.getSelectionModel().getSelectedItem(); + index = listViewOfResourcesInFolder.getSelectionModel().getSelectedIndex(); + processDataFileAndShowPlotsOfPeakShapes(); + peakCentreLinePlot.getGraphicsContext2D().setLineWidth(1.0); + peakCentreLinePlot.getGraphicsContext2D().strokeOval(peakCentreLinePlot.mapX(peakCentreLinePlot.getxAxisData()[index]) - 6, peakCentreLinePlot.mapY(peakCentreLinePlot.getyAxisData()[index]) - 6, 12, 12); + } + }); + + listViewOfResourcesInFolder.prefHeightProperty().bind(eventAnchorPane.heightProperty()); listViewOfResourcesInFolder.prefWidthProperty().bind(eventAnchorPane.widthProperty()); eventAnchorPane.getChildren().add(listViewOfResourcesInFolder); diff --git a/TripoliCore/src/main/java/org/cirdles/tripoli/sessions/analysis/massSpectrometerModels/dataSourceProcessors/PeakShapeProcessor_OPPhoenix.java b/TripoliCore/src/main/java/org/cirdles/tripoli/sessions/analysis/massSpectrometerModels/dataSourceProcessors/PeakShapeProcessor_OPPhoenix.java index 9dd4470b..6dda0de4 100644 --- a/TripoliCore/src/main/java/org/cirdles/tripoli/sessions/analysis/massSpectrometerModels/dataSourceProcessors/PeakShapeProcessor_OPPhoenix.java +++ b/TripoliCore/src/main/java/org/cirdles/tripoli/sessions/analysis/massSpectrometerModels/dataSourceProcessors/PeakShapeProcessor_OPPhoenix.java @@ -60,16 +60,17 @@ public PeakShapeOutputDataRecord prepareInputDataModelFromFile(Path inputDataFil for (String line : contentsByLine) { if (!line.isEmpty()) { switch (phase) { - case 0: - headerLine.add(line.split("\\s*,\\s*")); - case 1: - columnNames.add(line.split("\\s*,\\s*")); - case 2: + case 0 -> headerLine.add(line.split("\\s*,\\s*")); + case 1 -> columnNames.add(line.split("\\s*,\\s*")); + case 2 -> { String[] cols = line.split("\\s*,\\s*"); masses.add(Double.parseDouble(cols[0])); intensity.add(Double.parseDouble(cols[1])); - default: - break; + } + default -> { + masses = null; + intensity = null; + } } if (phase == 1) { From e1996e1df9bd14c26d833d88a78488ad5d71750a Mon Sep 17 00:00:00 2001 From: Ian Robinson Date: Sat, 3 Sep 2022 18:56:09 -0400 Subject: [PATCH 4/4] potential auto-selection fix --- .../dataViews/plots/BeamShapeLinePlot.java | 2 +- .../gui/dataViews/plots/GBeamLinePlot.java | 2 +- .../PeakShapePlotsController.java | 177 ++++++++++++------ 3 files changed, 120 insertions(+), 61 deletions(-) diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/BeamShapeLinePlot.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/BeamShapeLinePlot.java index d1b0d2d3..a5b8ec63 100644 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/BeamShapeLinePlot.java +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/BeamShapeLinePlot.java @@ -127,7 +127,7 @@ public void paint(GraphicsContext g2d) { text.setText(bigDecimal.toString()); textWidth = (int) text.getLayoutBounds().getWidth(); g2d.fillText(text.getText(),// - (float) mapX(minX) - textWidth + 5f, + (float) mapX(minX) - textWidth - 5f, (float) mapY(bigDecimal.doubleValue()) + verticalTextShift); } diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/GBeamLinePlot.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/GBeamLinePlot.java index 92236a7a..e39a695a 100644 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/GBeamLinePlot.java +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/GBeamLinePlot.java @@ -127,7 +127,7 @@ public void paint(GraphicsContext g2d) { text.setText(bigDecimal.toString()); textWidth = (int) text.getLayoutBounds().getWidth(); g2d.fillText(text.getText(),// - (float) mapX(minX) - textWidth + 5f, + (float) mapX(minX) - textWidth - 5f, (float) mapY(bigDecimal.doubleValue()) + verticalTextShift); } diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsController.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsController.java index c8d209cd..02a9a8f9 100644 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsController.java +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/peakShapePlots/PeakShapePlotsController.java @@ -203,20 +203,20 @@ private void populateListOfGroups() { ObservableList items = FXCollections.observableArrayList(resourceGroups.keySet().stream().toList()); listViewOfGroupResourcesInFolder.setItems(items); + + listViewOfGroupResourcesInFolder.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { // Files will be manipulated here when group is selected - processFilesAndShowPeakCentre(newValue); setCurrentGroup(newValue); + processFilesAndShowPeakCentre(newValue); populateListOfResources(newValue); - gBeamPlotScrollPane.setContent(null); - beamShapePlotScrollPane.setContent(null); eventLogTextArea.textProperty().unbind(); eventLogTextArea.setText("Select File From Plot"); }); - listViewOfGroupResourcesInFolder.getSelectionModel().selectFirst(); - setCurrentGroup(listViewOfGroupResourcesInFolder.getSelectionModel().getSelectedItem()); + + listViewOfGroupResourcesInFolder.getSelectionModel().selectFirst(); listViewOfGroupResourcesInFolder.prefHeightProperty().bind(resourceListAnchorPane.prefHeightProperty()); listViewOfGroupResourcesInFolder.prefWidthProperty().bind(resourceListAnchorPane.prefWidthProperty()); resourceListAnchorPane.getChildren().add(listViewOfGroupResourcesInFolder); @@ -239,53 +239,6 @@ private void populateListOfGroups() { } - private void populateListOfResources(String groupValue) { - listViewOfResourcesInFolder = new ListView<>(); - listViewOfResourcesInFolder.setCellFactory(param -> new ResourceDisplayName2()); - eventLogTextArea.textProperty().unbind(); - int initialIndex; - - ObservableList items = FXCollections.observableArrayList(resourceGroups.get(groupValue)); - listViewOfResourcesInFolder.setItems(items); - - listViewOfResourcesInFolder.getSelectionModel().selectFirst(); - resourceBrowserTarget = listViewOfResourcesInFolder.getSelectionModel().getSelectedItem(); - initialIndex = listViewOfResourcesInFolder.getSelectionModel().getSelectedIndex(); - processDataFileAndShowPlotsOfPeakShapes(); - peakCentreLinePlot.getGraphicsContext2D().setLineWidth(1.0); - peakCentreLinePlot.getGraphicsContext2D().strokeOval(peakCentreLinePlot.mapX(peakCentreLinePlot.getxAxisData()[initialIndex]) - 6, peakCentreLinePlot.mapY(peakCentreLinePlot.getyAxisData()[initialIndex]) - 6, 12, 12); - - - listViewOfResourcesInFolder.setOnMouseClicked(click -> { - peakCentreLinePlot.repaint(); - int index; - if (click.getClickCount() == 1) { - resourceBrowserTarget = listViewOfResourcesInFolder.getSelectionModel().getSelectedItem(); - index = listViewOfResourcesInFolder.getSelectionModel().getSelectedIndex(); - peakCentreLinePlot.getGraphicsContext2D().setLineWidth(1.0); - peakCentreLinePlot.getGraphicsContext2D().strokeOval(peakCentreLinePlot.mapX(peakCentreLinePlot.getxAxisData()[index]) - 6, peakCentreLinePlot.mapY(peakCentreLinePlot.getyAxisData()[index]) - 6, 12, 12); - processDataFileAndShowPlotsOfPeakShapes(); - } - }); - - listViewOfResourcesInFolder.setOnKeyPressed(key -> { - peakCentreLinePlot.repaint(); - int index; - if (key.getCode() == KeyCode.DOWN || key.getCode() == KeyCode.UP) { - resourceBrowserTarget = listViewOfResourcesInFolder.getSelectionModel().getSelectedItem(); - index = listViewOfResourcesInFolder.getSelectionModel().getSelectedIndex(); - processDataFileAndShowPlotsOfPeakShapes(); - peakCentreLinePlot.getGraphicsContext2D().setLineWidth(1.0); - peakCentreLinePlot.getGraphicsContext2D().strokeOval(peakCentreLinePlot.mapX(peakCentreLinePlot.getxAxisData()[index]) - 6, peakCentreLinePlot.mapY(peakCentreLinePlot.getyAxisData()[index]) - 6, 12, 12); - } - }); - - - listViewOfResourcesInFolder.prefHeightProperty().bind(eventAnchorPane.heightProperty()); - listViewOfResourcesInFolder.prefWidthProperty().bind(eventAnchorPane.widthProperty()); - eventAnchorPane.getChildren().add(listViewOfResourcesInFolder); - } - public void processFilesAndShowPeakCentre(String groupValue) { double[] finalYAxis; @@ -336,20 +289,68 @@ public void processFilesAndShowPeakCentre(String groupValue) { } + private void populateListOfResources(String groupValue) { + listViewOfResourcesInFolder = new ListView<>(); + listViewOfResourcesInFolder.setCellFactory(param -> new ResourceDisplayName2()); + eventLogTextArea.textProperty().unbind(); + int initialIndex; + + ObservableList items = FXCollections.observableArrayList(resourceGroups.get(groupValue)); + listViewOfResourcesInFolder.setItems(items); + + + + listViewOfResourcesInFolder.setOnMouseClicked(click -> { + peakCentreLinePlot.repaint(); + int index; + if (click.getClickCount() == 1) { + resourceBrowserTarget = listViewOfResourcesInFolder.getSelectionModel().getSelectedItem(); + index = listViewOfResourcesInFolder.getSelectionModel().getSelectedIndex(); + peakCentreLinePlot.getGraphicsContext2D().setLineWidth(1.0); + peakCentreLinePlot.getGraphicsContext2D().strokeOval(peakCentreLinePlot.mapX(peakCentreLinePlot.getxAxisData()[index]) - 6, peakCentreLinePlot.mapY(peakCentreLinePlot.getyAxisData()[index]) - 6, 12, 12); + processDataFileAndShowPlotsOfPeakShapes(); + } + }); + + listViewOfResourcesInFolder.setOnKeyPressed(key -> { + peakCentreLinePlot.repaint(); + int index; + if (key.getCode() == KeyCode.DOWN || key.getCode() == KeyCode.UP) { + resourceBrowserTarget = listViewOfResourcesInFolder.getSelectionModel().getSelectedItem(); + index = listViewOfResourcesInFolder.getSelectionModel().getSelectedIndex(); + processDataFileAndShowPlotsOfPeakShapes(); + peakCentreLinePlot.getGraphicsContext2D().setLineWidth(1.0); + peakCentreLinePlot.getGraphicsContext2D().strokeOval(peakCentreLinePlot.mapX(peakCentreLinePlot.getxAxisData()[index]) - 6, peakCentreLinePlot.mapY(peakCentreLinePlot.getyAxisData()[index]) - 6, 12, 12); + } + }); + + listViewOfResourcesInFolder.getSelectionModel().selectFirst(); + initialIndex = listViewOfResourcesInFolder.getSelectionModel().getSelectedIndex(); + resourceBrowserTarget = listViewOfResourcesInFolder.getSelectionModel().getSelectedItem(); + peakCentreLinePlot.getGraphicsContext2D().setLineWidth(1.0); + peakCentreLinePlot.getGraphicsContext2D().strokeOval(peakCentreLinePlot.mapX(peakCentreLinePlot.getxAxisData()[initialIndex]) - 6, peakCentreLinePlot.mapY(peakCentreLinePlot.getyAxisData()[initialIndex]) - 6, 12, 12); + processDataFileAndShowPlotsOfPeakShapes(); + + listViewOfResourcesInFolder.prefHeightProperty().bind(eventAnchorPane.heightProperty()); + listViewOfResourcesInFolder.prefWidthProperty().bind(eventAnchorPane.widthProperty()); + eventAnchorPane.getChildren().add(listViewOfResourcesInFolder); + } + + + public void processDataFileAndShowPlotsOfPeakShapes() { if (resourceBrowserTarget != null && resourceBrowserTarget.isFile()) { final PeakShapesService service = new PeakShapesService(resourceBrowserTarget.toPath()); eventLogTextArea.textProperty().bind(service.valueProperty()); - service.start(); - service.setOnSucceeded(evt -> { - AbstractPlotBuilder gBeamPlotBuilder = ((PeakShapesTask) service.getPeakShapesTask()).getGBeamPlotBuilder(); + try { + AbstractPlotBuilder[] plots = BeamDataOutputDriverExperiment.modelTest(resourceBrowserTarget.toPath(), this::processFilesAndShowPeakCentre); AbstractDataView gBeamLinePlot = new GBeamLinePlot( new Rectangle(gBeamPlotScrollPane.getWidth(), gBeamPlotScrollPane.getHeight()), - (GBeamLinePlotBuilder) gBeamPlotBuilder + (GBeamLinePlotBuilder) plots[1] ); gBeamPlotScrollPane.widthProperty().addListener((observable, oldValue, newValue) -> { @@ -370,12 +371,11 @@ public void processDataFileAndShowPlotsOfPeakShapes() { gBeamPlotScrollPane.setContent(gBeamLinePlot); - AbstractPlotBuilder beamShapePlotBuilder = ((PeakShapesTask) service.getPeakShapesTask()).getBeamShapePlotBuilder(); AbstractDataView beamShapeLinePlot = new BeamShapeLinePlot( new Rectangle(beamShapePlotScrollPane.getWidth(), beamShapePlotScrollPane.getHeight()), - (BeamShapeLinePlotBuilder) beamShapePlotBuilder + (BeamShapeLinePlotBuilder) plots[0] ); beamShapePlotScrollPane.widthProperty().addListener((observable, oldValue, newValue) -> { @@ -394,7 +394,66 @@ public void processDataFileAndShowPlotsOfPeakShapes() { beamShapeLinePlot.preparePanel(); beamShapePlotScrollPane.setContent(beamShapeLinePlot); - }); + }catch (Exception e){ + e.printStackTrace(); + } + + + + +// service.start(); +// service.setOnSucceeded(evt -> { +// AbstractPlotBuilder gBeamPlotBuilder = ((PeakShapesTask) service.getPeakShapesTask()).getGBeamPlotBuilder(); +// +// AbstractDataView gBeamLinePlot = new GBeamLinePlot( +// new Rectangle(gBeamPlotScrollPane.getWidth(), +// gBeamPlotScrollPane.getHeight()), +// (GBeamLinePlotBuilder) gBeamPlotBuilder +// ); +// +// gBeamPlotScrollPane.widthProperty().addListener((observable, oldValue, newValue) -> { +// if (newValue.intValue() > 100) { +// gBeamLinePlot.setMyWidth(newValue.intValue() - SCROLLBAR_THICKNESS); +// gBeamLinePlot.repaint(); +// } +// }); +// +// gBeamPlotScrollPane.heightProperty().addListener((observable, oldValue, newValue) -> { +// if (newValue.intValue() > 100) { +// gBeamLinePlot.setMyHeight(newValue.intValue() - SCROLLBAR_THICKNESS); +// gBeamLinePlot.repaint(); +// } +// }); +// +// gBeamLinePlot.preparePanel(); +// gBeamPlotScrollPane.setContent(gBeamLinePlot); +// +// +// AbstractPlotBuilder beamShapePlotBuilder = ((PeakShapesTask) service.getPeakShapesTask()).getBeamShapePlotBuilder(); +// +// AbstractDataView beamShapeLinePlot = new BeamShapeLinePlot( +// new Rectangle(beamShapePlotScrollPane.getWidth(), +// beamShapePlotScrollPane.getHeight()), +// (BeamShapeLinePlotBuilder) beamShapePlotBuilder +// ); +// +// beamShapePlotScrollPane.widthProperty().addListener((observable, oldValue, newValue) -> { +// if (newValue.intValue() > 100) { +// beamShapeLinePlot.setMyWidth(newValue.intValue() - SCROLLBAR_THICKNESS); +// beamShapeLinePlot.repaint(); +// } +// }); +// +// beamShapePlotScrollPane.heightProperty().addListener((observable, oldValue, newValue) -> { +// if (newValue.intValue() > 100) { +// beamShapeLinePlot.setMyHeight(newValue.intValue() - SCROLLBAR_THICKNESS); +// beamShapeLinePlot.repaint(); +// } +// }); +// +// beamShapeLinePlot.preparePanel(); +// beamShapePlotScrollPane.setContent(beamShapeLinePlot); +// }); } else { eventLogTextArea.textProperty().unbind(); eventLogTextArea.setText("Please Choose Folder");