Skip to content
Snippets Groups Projects
Commit b798085a authored by Matisse DEKEISER's avatar Matisse DEKEISER
Browse files

Merge branch 'hugo-desmons' into 'master'

Modification affichage ajout de donnée

See merge request sae302/2024/H4_SAE3.3!8
parents 3d8a9acf 4b20ff19
No related branches found
No related tags found
No related merge requests found
...@@ -5,34 +5,41 @@ ...@@ -5,34 +5,41 @@
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.stage.*?> <?import javafx.stage.*?>
<Stage fx:id="stage" xmlns="http://javafx.com/javafx/17.0.12" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.univlille.sae.classification.controller.AddDataController"> <Stage fx:id="stage" xmlns="http://javafx.com/javafx/17.0.12" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.univlille.sae.classification.controller.AddDataController">
<scene> <scene>
<Scene> <Scene>
<AnchorPane prefHeight="200" prefWidth="200"> <AnchorPane prefHeight="200" prefWidth="200">
<children> <children>
<VBox alignment="CENTER" prefHeight="224.0" prefWidth="384.0" spacing="20.0"> <VBox alignment="CENTER" prefHeight="279.0" prefWidth="384.0" spacing="20.0">
<children>
<HBox alignment="CENTER" prefHeight="18.0" prefWidth="335.0" spacing="20.0">
<children>
<Label text="Valeur 1" />
<TextField />
</children>
</HBox>
<HBox alignment="CENTER" layoutX="10.0" layoutY="47.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
<children>
<Label text="Valeur 2" />
<ChoiceBox prefHeight="26.0" prefWidth="163.0" />
</children>
</HBox>
<HBox alignment="CENTER" layoutX="10.0" layoutY="109.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
<children> <children>
<Label text="Valeur 3" /> <HBox alignment="CENTER" layoutX="10.0" layoutY="109.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
<Spinner /> <children>
</children> <Label text="Sepal Length" />
</HBox> <Spinner fx:id="sepalLengthSpinner"/>
<Button fx:id="confirmAdd" mnemonicParsing="false" text="Valider" /> </children>
</children></VBox> </HBox>
</children></AnchorPane> <HBox alignment="CENTER" layoutX="10.0" layoutY="102.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
<children>
<Label text="Sepal Width" />
<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 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="Petal Width" />
<Spinner fx:id="petalWidthSpinner" />
</children>
</HBox>
<Button fx:id="confirmAdd" mnemonicParsing="false" onAction="#validate" text="Valider" />
</children></VBox>
</children></AnchorPane>
</Scene> </Scene>
</scene> </scene>
</Stage> </Stage>
\ No newline at end of file
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<HBox alignment="CENTER" prefHeight="169.0" prefWidth="691.0" spacing="50.0"> <HBox alignment="CENTER" prefHeight="169.0" prefWidth="691.0" spacing="50.0">
<children> <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="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" /> <Button fx:id="classifyData" disable="true" mnemonicParsing="false" prefHeight="26.0" prefWidth="157.0" text="Classifier une donnée" />
</children> </children>
</HBox> </HBox>
......
package fr.univlille.sae.classification.controller; package fr.univlille.sae.classification.controller;
import fr.univlille.sae.classification.model.ClassificationModel;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Button; 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 javafx.stage.Stage;
import java.io.IOException;
import java.util.function.UnaryOperator;
public class AddDataController { public class AddDataController {
@FXML
private Stage stage;
@FXML
private Button confirmAdd;
@FXML
private Spinner<Double> sepalLengthSpinner;
@FXML
private Spinner<Double> sepalWidthSpinner;
@FXML @FXML
Stage stage; private Spinner<Double> petalLengthSpinner;
@FXML @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();
}
} }
...@@ -2,15 +2,16 @@ package fr.univlille.sae.classification.controller; ...@@ -2,15 +2,16 @@ package fr.univlille.sae.classification.controller;
import fr.univlille.sae.classification.model.ClassificationModel; import fr.univlille.sae.classification.model.ClassificationModel;
import fr.univlille.sae.classification.view.LoadDataView; import fr.univlille.sae.classification.view.LoadDataView;
import fr.univlille.sae.classification.view.AddDataView;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.chart.*; import javafx.scene.chart.*;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.stage.*; import javafx.stage.*;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
public class MainStageController { public class MainStageController {
...@@ -52,6 +53,18 @@ public class MainStageController { ...@@ -52,6 +53,18 @@ public class MainStageController {
loadDataView.show(); 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();
} }
......
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();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment