Skip to content
Snippets Groups Projects
Commit 4b20ff19 authored by Hugo Desmons's avatar Hugo Desmons
Browse files

Modification affichage ajout de donnée

Ouverture du menu via le bouton
ajout spinner editable
parent 0afd800b
No related branches found
No related tags found
No related merge requests found
...@@ -16,38 +16,28 @@ ...@@ -16,38 +16,28 @@
<HBox alignment="CENTER" layoutX="10.0" layoutY="109.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0"> <HBox alignment="CENTER" layoutX="10.0" layoutY="109.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
<children> <children>
<Label text="Sepal Length" /> <Label text="Sepal Length" />
<Spinner /> <Spinner fx:id="sepalLengthSpinner"/>
</children> </children>
</HBox> </HBox>
<HBox alignment="CENTER" layoutX="10.0" layoutY="102.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0"> <HBox alignment="CENTER" layoutX="10.0" layoutY="102.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
<children> <children>
<Label text="Sepal Width" /> <Label text="Sepal Width" />
<Spinner /> <Spinner fx:id="sepalWidthSpinner"/>
</children> </children>
</HBox> </HBox>
<HBox alignment="CENTER" layoutX="10.0" layoutY="102.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0"> <HBox alignment="CENTER" layoutX="10.0" layoutY="102.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
<children> <children>
<Label text="Petal Length" /> <Label text="Petal Length" />
<Spinner /> <Spinner fx:id="petalLengthSpinner" />
</children> </children>
</HBox> </HBox>
<HBox alignment="CENTER" layoutX="10.0" layoutY="17.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0"> <HBox alignment="CENTER" layoutX="10.0" layoutY="17.0" prefHeight="17.0" prefWidth="335.0" spacing="20.0">
<children> <children>
<Label text="Sepal Width" /> <Label text="Petal Width" />
<Spinner /> <Spinner fx:id="petalWidthSpinner" />
</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>
</children> </children>
</HBox> </HBox>
<Button fx:id="confirmAdd" mnemonicParsing="false" text="Valider" /> <Button fx:id="confirmAdd" mnemonicParsing="false" onAction="#validate" text="Valider" />
</children></VBox> </children></VBox>
</children></AnchorPane> </children></AnchorPane>
</Scene> </Scene>
......
...@@ -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
private Spinner<Double> petalLengthSpinner;
@FXML @FXML
Stage stage; private Spinner<Double> petalWidthSpinner;
@FXML @FXML
Button confirmAdd; 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