Skip to content

Commit

Permalink
print errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MarreTeint authored Oct 17, 2022
1 parent 3a6dd21 commit 561517a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions monochromateur.iml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.8.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.8.1" level="project" />
<orderEntry type="library" name="JavaFX" level="project" />
</component>
</module>
16 changes: 14 additions & 2 deletions src/main/java/com/monochromateur/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ protected void plotDatas() {
progress.setVisible(false);
button.setVisible(true);
comPort.closePort();
//TODO add an error message on the UI
javafx.application.Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Error sending start command");
alert.setContentText("Please select another COM port and try again");
alert.showAndWait();
});
return;
}

Expand Down Expand Up @@ -105,6 +111,7 @@ protected void plotDatas() {
//send series to main thread
int finalMaxat = maxat;
javafx.application.Platform.runLater(() -> {
result.setAnimated(true);
result.getData().clear();
result.getData().add(series);
result.setCreateSymbols(false);
Expand All @@ -123,6 +130,11 @@ protected void plotDatas() {
}
else {
System.out.println("No COM port selected");
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Select a COM port");
alert.setHeaderText("No COM port selected");
alert.setContentText("Please select a COM port and try again");
alert.showAndWait();
}
}

Expand All @@ -136,7 +148,7 @@ protected void sliderMoved() {
javafx.application.Platform.runLater(() -> {
result.setAnimated(false);
if(result.getData().size()>1) {
result.getData().remove(1);
result.getData().remove(1);
}
result.getData().add(series);
slideX.setText(String.valueOf((int)slide.getValue()));
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/com/monochromateur/View.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
</padding>
<LineChart fx:id="result" prefHeight="529.0" prefWidth="719.0">
<xAxis>
<NumberAxis autoRanging="false" label="Longeur d'onde" lowerBound="400" side="BOTTOM" tickLength="10.0" tickUnit="10.0" upperBound="800" />
<NumberAxis autoRanging="false" label="Longeur d'onde (en nm)" lowerBound="400" side="BOTTOM" tickLength="10.0" tickUnit="10.0" upperBound="800" />
</xAxis>
<yAxis>
<NumberAxis autoRanging="false" label="Absorbance" side="LEFT" />
<NumberAxis autoRanging="false" label="Absorbance (en %)" side="LEFT" />
</yAxis>
</LineChart>
<HBox alignment="CENTER" prefHeight="64.0" prefWidth="661.0">
Expand All @@ -28,10 +28,10 @@
<Slider fx:id="slide" majorTickUnit="1" max="800.0" min="400.0" onMouseDragged="#sliderMoved" showTickLabels="true" showTickMarks="true" snapToTicks="true" visible="false" />
<HBox fx:id="displayData" alignment="CENTER" prefHeight="43.0" prefWidth="661.0" visible="false">
<children>
<Label text="Longeur d'onde : " />
<Label text="Longeur d'onde (en nm) : " />
<Label fx:id="slideX" text="" />
<Separator orientation="VERTICAL" prefHeight="17.0" prefWidth="23.0" />
<Label text=" Absorbance : " />
<Label text=" Absorbance (en %) : " />
<Label fx:id="slideY" text="" />

</children>
Expand Down
Binary file modified target/classes/com/monochromateur/Controller.class
Binary file not shown.
8 changes: 4 additions & 4 deletions target/classes/com/monochromateur/View.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
</padding>
<LineChart fx:id="result" prefHeight="529.0" prefWidth="719.0">
<xAxis>
<NumberAxis autoRanging="false" label="Longeur d'onde" lowerBound="400" side="BOTTOM" tickLength="10.0" tickUnit="10.0" upperBound="800" />
<NumberAxis autoRanging="false" label="Longeur d'onde (en nm)" lowerBound="400" side="BOTTOM" tickLength="10.0" tickUnit="10.0" upperBound="800" />
</xAxis>
<yAxis>
<NumberAxis autoRanging="false" label="Absorbance" side="LEFT" />
<NumberAxis autoRanging="false" label="Absorbance (en %)" side="LEFT" />
</yAxis>
</LineChart>
<HBox alignment="CENTER" prefHeight="64.0" prefWidth="661.0">
Expand All @@ -28,10 +28,10 @@
<Slider fx:id="slide" majorTickUnit="1" max="800.0" min="400.0" onMouseDragged="#sliderMoved" showTickLabels="true" showTickMarks="true" snapToTicks="true" visible="false" />
<HBox fx:id="displayData" alignment="CENTER" prefHeight="43.0" prefWidth="661.0" visible="false">
<children>
<Label text="Longeur d'onde : " />
<Label text="Longeur d'onde (en nm) : " />
<Label fx:id="slideX" text="" />
<Separator orientation="VERTICAL" prefHeight="17.0" prefWidth="23.0" />
<Label text=" Absorbance : " />
<Label text=" Absorbance (en %) : " />
<Label fx:id="slideY" text="" />

</children>
Expand Down

0 comments on commit 561517a

Please sign in to comment.