Skip to content
Snippets Groups Projects
Commit 0d5fcf3b authored by Matias Mennecart's avatar Matias Mennecart
Browse files

Merge branch 'hugo-desmons' into 'master'

Merge branch Hugo-desmons to Master

See merge request sae302/2024/H4_SAE3.3!10
parents 2e195644 917c3aab
Branches
Tags
No related merge requests found
package fr.univlille.sae.classification.controller;
import fr.univlille.sae.classification.model.ClassificationModel;
import fr.univlille.sae.classification.model.Iris;
import fr.univlille.sae.classification.view.MainStageView;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Spinner;
......@@ -31,6 +33,8 @@ public class AddDataController {
@FXML
private Spinner<Double> petalWidthSpinner;
MainStageView mainStageView;
@FXML
public void initialize() {
sepalLengthSpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(0.0, 200.0, 3.0,0.1));
......@@ -44,23 +48,16 @@ public class AddDataController {
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 setMainStageView(MainStageView mainStageView) {
this.mainStageView = mainStageView;
}
public void validate() throws IOException {
System.out.println("validé");
ClassificationModel.getClassificationModel().ajouterDonnee(sepalLengthSpinner.getValue(), sepalWidthSpinner.getValue(), petalLengthSpinner.getValue(), petalWidthSpinner.getValue());
mainStageView.update(mainStageView.getModel(),new Iris(sepalWidthSpinner.getValue(),sepalLengthSpinner.getValue(),petalWidthSpinner.getValue(),petalLengthSpinner.getValue()));
stage.close();
}
......
......@@ -3,7 +3,6 @@ package fr.univlille.sae.classification.controller;
import fr.univlille.sae.classification.model.ClassificationModel;
import fr.univlille.sae.classification.view.AxesSettingsView;
import fr.univlille.sae.classification.view.LoadDataView;
import fr.univlille.sae.classification.view.MainStageView;
import fr.univlille.sae.classification.view.AddDataView;
import fr.univlille.sae.classification.view.MainStageView;
import javafx.fxml.FXML;
......@@ -75,9 +74,8 @@ public class MainStageController {
*/
public void openAddData() throws IOException {
AddDataView addDataView = new AddDataView(ClassificationModel.getClassificationModel(), stage);
AddDataView addDataView = new AddDataView(ClassificationModel.getClassificationModel(), stage, mainStageView);
addDataView.show();
}
}
......
package fr.univlille.sae.classification.view;
import fr.univlille.sae.classification.controller.AddDataController;
import fr.univlille.sae.classification.controller.AxesSettingsController;
import fr.univlille.sae.classification.model.ClassificationModel;
import javafx.fxml.FXMLLoader;
import javafx.stage.Modality;
......@@ -13,10 +15,12 @@ public class AddDataView {
private ClassificationModel model;
private Stage owner;
private MainStageView mainStageView;
public AddDataView(ClassificationModel model, Stage owner) {
public AddDataView(ClassificationModel model, Stage owner, MainStageView mainStageView) {
this.model = model;
this.owner = owner;
this.mainStageView = mainStageView;
}
......@@ -33,6 +37,10 @@ public class AddDataView {
loader.setLocation(fxmlFileUrl);
Stage root = loader.load();
AddDataController controller = loader.getController();
controller.setMainStageView(mainStageView);
root.setResizable(false);
root.initOwner(owner);
root.initModality(Modality.APPLICATION_MODAL);
......
......@@ -90,7 +90,26 @@ public class MainStageView implements Observer {
@Override
public void update(Observable observable, Object data) {
if(scatterChart == null) throw new IllegalStateException();
if(!(observable instanceof ClassificationModel)) throw new IllegalStateException();
if(data instanceof Iris) {
Iris iris = (Iris) data;
if(actualX == null || actualY == null) {
controller.setAxesSelected("Aucuns axes sélectionnés");
return;
}
XYChart.Data<Double, Double> dataPoint = new XYChart.Data<>(
iris.getDataType(actualX),
iris.getDataType(actualY)
);
Circle circle = new Circle(5);
circle.setFill(iris.getColor());
dataPoint.setNode(circle);
if (!scatterChart.getData().isEmpty()) {
XYChart.Series series = (XYChart.Series) scatterChart.getData().get(0);
series.getData().add(dataPoint);
}
}
}
public void setActualX(String actualX) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment