diff --git a/res/stages/add-data-stage.fxml b/res/stages/add-data-stage.fxml
index 5664fe16de967a88ff1e86ec5910e1b08a76fd09..a32cefd3e02211965d0e8a0bd98bd9fde8f96bfb 100644
--- a/res/stages/add-data-stage.fxml
+++ b/res/stages/add-data-stage.fxml
@@ -16,38 +16,28 @@
<HBox alignment="CENTER" layoutX="10.0" layoutY="109.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
<children>
<Label text="Sepal Length" />
- <Spinner />
+ <Spinner fx:id="sepalLengthSpinner"/>
</children>
</HBox>
<HBox alignment="CENTER" layoutX="10.0" layoutY="102.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
<children>
<Label text="Sepal Width" />
- <Spinner />
+ <Spinner fx:id="sepalWidthSpinner"/>
</children>
</HBox>
<HBox alignment="CENTER" layoutX="10.0" layoutY="102.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
<children>
<Label text="Petal Length" />
- <Spinner />
+ <Spinner fx:id="petalLengthSpinner" />
</children>
</HBox>
<HBox alignment="CENTER" layoutX="10.0" layoutY="17.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
<children>
- <Label text="Sepal Width" />
- <Spinner />
- </children>
- </HBox>
- <HBox alignment="CENTER" layoutX="10.0" layoutY="102.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
- <children>
- <HBox alignment="CENTER" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
- <children>
- <Label text="Variety" />
- <ChoiceBox prefHeight="26.0" prefWidth="137.0" />
- </children>
- </HBox>
+ <Label text="Petal Width" />
+ <Spinner fx:id="petalWidthSpinner" />
</children>
</HBox>
- <Button fx:id="confirmAdd" mnemonicParsing="false" text="Valider" />
+ <Button fx:id="confirmAdd" mnemonicParsing="false" onAction="#validate" text="Valider" />
</children></VBox>
</children></AnchorPane>
</Scene>
diff --git a/res/stages/main-stage.fxml b/res/stages/main-stage.fxml
index 89ef33782292135bf05d3465c298c5a4b7d52903..d32296897275d3818030eeb4d0d56a5d10b3403e 100644
--- a/res/stages/main-stage.fxml
+++ b/res/stages/main-stage.fxml
@@ -30,7 +30,7 @@
<HBox alignment="CENTER" prefHeight="169.0" prefWidth="691.0" spacing="50.0">
<children>
<Button fx:id="loadData" mnemonicParsing="false" onAction="#openLoadData" prefHeight="27.0" prefWidth="185.0" text="Charger un jeu de données" />
- <Button fx:id="addData" mnemonicParsing="false" prefHeight="26.0" prefWidth="141.0" text="Ajouter une donnée" />
+ <Button fx:id="addData" mnemonicParsing="false" onAction="#openAddData" prefHeight="26.0" prefWidth="141.0" text="Ajouter une donnée" />
<Button fx:id="classifyData" disable="true" mnemonicParsing="false" prefHeight="26.0" prefWidth="157.0" text="Classifier une donnée" />
</children>
</HBox>
diff --git a/src/main/java/fr/univlille/sae/classification/controller/AddDataController.java b/src/main/java/fr/univlille/sae/classification/controller/AddDataController.java
index d0251194dec93f29e2a89a9bc93696542324af41..a8b0864644c24785dcb1d6db4133e2c663a48745 100644
--- a/src/main/java/fr/univlille/sae/classification/controller/AddDataController.java
+++ b/src/main/java/fr/univlille/sae/classification/controller/AddDataController.java
@@ -1,15 +1,67 @@
package fr.univlille.sae.classification.controller;
+import fr.univlille.sae.classification.model.ClassificationModel;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
+import javafx.scene.control.Spinner;
+import javafx.scene.control.SpinnerValueFactory;
+import javafx.scene.control.TextFormatter;
import javafx.stage.Stage;
+import java.io.IOException;
+import java.util.function.UnaryOperator;
+
public class AddDataController {
+
+ @FXML
+ private Stage stage;
+
+ @FXML
+ private Button confirmAdd;
+
+ @FXML
+ private Spinner<Double> sepalLengthSpinner;
+
+ @FXML
+ private Spinner<Double> sepalWidthSpinner;
+
@FXML
- Stage stage;
+ private Spinner<Double> petalLengthSpinner;
@FXML
- Button confirmAdd;
+ private Spinner<Double> petalWidthSpinner;
+
+ @FXML
+ public void initialize() {
+ sepalLengthSpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(0.0, 200.0, 3.0,0.1));
+ sepalWidthSpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(0.0, 200.0, 3.0, 0.1));
+ petalLengthSpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(0.0, 200.0, 3.0, 0.1));
+ petalWidthSpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(0.0, 200.0, 3.0, 0.1));
+
+ // Permet d'écrire dans la case du spinners
+ sepalLengthSpinner.setEditable(true);
+ sepalWidthSpinner.setEditable(true);
+ petalLengthSpinner.setEditable(true);
+ petalWidthSpinner.setEditable(true);
+
+
+ confirmAdd.setOnAction(event -> handleConfirmAdd());
+ }
+
+ private void handleConfirmAdd() {
+ double sepalLength = sepalLengthSpinner.getValue();
+ double sepalWidth = sepalWidthSpinner.getValue();
+ double petalLength = petalLengthSpinner.getValue();
+ double petalWidth = petalWidthSpinner.getValue();
+
+ stage.close();
+ }
+
+ public void validate() throws IOException {
+
+ ClassificationModel.getClassificationModel().ajouterDonnee(sepalLengthSpinner.getValue(), sepalWidthSpinner.getValue(), petalLengthSpinner.getValue(), petalWidthSpinner.getValue());
+ stage.close();
+ }
}
diff --git a/src/main/java/fr/univlille/sae/classification/controller/MainStageController.java b/src/main/java/fr/univlille/sae/classification/controller/MainStageController.java
index 1088c4e59fb1f0e005cc636bcff1cf5e0509e738..43599c8041b94d95e3569264fc937c30a3d38c7d 100644
--- a/src/main/java/fr/univlille/sae/classification/controller/MainStageController.java
+++ b/src/main/java/fr/univlille/sae/classification/controller/MainStageController.java
@@ -2,15 +2,16 @@ package fr.univlille.sae.classification.controller;
import fr.univlille.sae.classification.model.ClassificationModel;
import fr.univlille.sae.classification.view.LoadDataView;
+import fr.univlille.sae.classification.view.AddDataView;
import javafx.fxml.FXML;
-import javafx.fxml.FXMLLoader;
+
import javafx.scene.chart.*;
import javafx.scene.control.Button;
import javafx.stage.*;
-import java.io.File;
+
import java.io.IOException;
-import java.net.URL;
+
public class MainStageController {
@@ -52,6 +53,18 @@ public class MainStageController {
loadDataView.show();
+ }
+
+ /**
+ * Ouvre l'interface d'ajout de donnée.
+ * @throws IOException
+ */
+ public void openAddData() throws IOException {
+
+ AddDataView addDataView = new AddDataView(ClassificationModel.getClassificationModel(), stage);
+ addDataView.show();
+
+
}
diff --git a/src/main/java/fr/univlille/sae/classification/view/AddDataView.java b/src/main/java/fr/univlille/sae/classification/view/AddDataView.java
new file mode 100644
index 0000000000000000000000000000000000000000..9d57add41e32b0d34ea7d74c15bb130ab009d32a
--- /dev/null
+++ b/src/main/java/fr/univlille/sae/classification/view/AddDataView.java
@@ -0,0 +1,45 @@
+package fr.univlille.sae.classification.view;
+
+import fr.univlille.sae.classification.model.ClassificationModel;
+import javafx.fxml.FXMLLoader;
+import javafx.stage.Modality;
+import javafx.stage.Stage;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+public class AddDataView {
+
+ private ClassificationModel model;
+ private Stage owner;
+
+ public AddDataView(ClassificationModel model, Stage owner) {
+ this.model = model;
+ this.owner = owner;
+ }
+
+
+
+ public void show() throws IOException {
+
+ FXMLLoader loader = new FXMLLoader();
+ URL fxmlFileUrl = new File(System.getProperty("user.dir") + File.separator + "res" + File.separator + "stages" + File.separator + "add-data-stage.fxml").toURI().toURL();
+
+ if (fxmlFileUrl == null) {
+ System.out.println("Impossible de charger le fichier fxml");
+ System.exit(-1);
+ }
+ loader.setLocation(fxmlFileUrl);
+ Stage root = loader.load();
+
+ root.setResizable(false);
+ root.initOwner(owner);
+ root.initModality(Modality.APPLICATION_MODAL);
+ root.setTitle("Ajout de donée");
+
+ root.showAndWait();
+
+ }
+
+}