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

Fix d'exceptions

parent 0d5fcf3b
Branches
No related tags found
No related merge requests found
...@@ -57,7 +57,6 @@ public class AddDataController { ...@@ -57,7 +57,6 @@ public class AddDataController {
public void validate() throws IOException { public void validate() throws IOException {
System.out.println("validé"); System.out.println("validé");
ClassificationModel.getClassificationModel().ajouterDonnee(sepalLengthSpinner.getValue(), sepalWidthSpinner.getValue(), petalLengthSpinner.getValue(), petalWidthSpinner.getValue()); 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(); stage.close();
} }
......
package fr.univlille.sae.classification.controller; package fr.univlille.sae.classification.controller;
import fr.univlille.sae.classification.model.ClassificationModel;
import fr.univlille.sae.classification.view.MainStageView; import fr.univlille.sae.classification.view.MainStageView;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Button; import javafx.scene.control.Button;
...@@ -41,7 +42,8 @@ public class AxesSettingsController{ ...@@ -41,7 +42,8 @@ public class AxesSettingsController{
public void validate(){ public void validate(){
mainStageView.setActualX(selectAbs.getValue().toString()); mainStageView.setActualX(selectAbs.getValue().toString());
mainStageView.setActualY(selectOrd.getValue().toString()); mainStageView.setActualY(selectOrd.getValue().toString());
mainStageView.update(mainStageView.getModel());
mainStageView.update(ClassificationModel.getClassificationModel());
stage.close(); stage.close();
} }
} }
...@@ -2,6 +2,7 @@ package fr.univlille.sae.classification.controller; ...@@ -2,6 +2,7 @@ package fr.univlille.sae.classification.controller;
import fr.univlille.sae.classification.model.ClassificationModel; import fr.univlille.sae.classification.model.ClassificationModel;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
...@@ -29,10 +30,6 @@ public class LoadDataController { ...@@ -29,10 +30,6 @@ public class LoadDataController {
File file; File file;
public void loadData() {
System.out.println("Loading data");
stage.close();
}
public void openFileChooser() { public void openFileChooser() {
...@@ -49,7 +46,14 @@ public class LoadDataController { ...@@ -49,7 +46,14 @@ public class LoadDataController {
public void validate() throws IOException { public void validate() throws IOException {
if (file == null) { if (file == null) {
stage.close(); Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Erreur de chargement du fichier");
alert.setHeaderText(null);
alert.initOwner(stage);
alert.setContentText("Le chargement du fichier à echoué, veuillez reessayer !");
alert.showAndWait();
openFileChooser();
return;
//throw exception //throw exception
} }
ClassificationModel.getClassificationModel().loadData(file); ClassificationModel.getClassificationModel().loadData(file);
......
...@@ -4,6 +4,7 @@ import fr.univlille.sae.classification.controller.AddDataController; ...@@ -4,6 +4,7 @@ import fr.univlille.sae.classification.controller.AddDataController;
import fr.univlille.sae.classification.controller.AxesSettingsController; import fr.univlille.sae.classification.controller.AxesSettingsController;
import fr.univlille.sae.classification.model.ClassificationModel; import fr.univlille.sae.classification.model.ClassificationModel;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.control.Alert;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
...@@ -41,6 +42,16 @@ public class AddDataView { ...@@ -41,6 +42,16 @@ public class AddDataView {
controller.setMainStageView(mainStageView); controller.setMainStageView(mainStageView);
if(model.getDatas().isEmpty()) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Erreur");
alert.setHeaderText(null);
alert.setContentText("Veuillez d'abord charger les données avant pouvoir ajouter un point");
alert.showAndWait();
return;
}
root.setResizable(false); root.setResizable(false);
root.initOwner(owner); root.initOwner(owner);
root.initModality(Modality.APPLICATION_MODAL); root.initModality(Modality.APPLICATION_MODAL);
......
...@@ -5,6 +5,7 @@ import fr.univlille.sae.classification.controller.MainStageController; ...@@ -5,6 +5,7 @@ import fr.univlille.sae.classification.controller.MainStageController;
import fr.univlille.sae.classification.model.ClassificationModel; import fr.univlille.sae.classification.model.ClassificationModel;
import fr.univlille.sae.classification.model.LoadableData; import fr.univlille.sae.classification.model.LoadableData;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.control.Alert;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
...@@ -43,9 +44,19 @@ public class AxesSettingsView { ...@@ -43,9 +44,19 @@ public class AxesSettingsView {
root.setTitle("Configuration des axes"); root.setTitle("Configuration des axes");
AxesSettingsController controller = loader.getController(); AxesSettingsController controller = loader.getController();
controller.setMainStageView(mainStageView);
if(model.getDatas().isEmpty()) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Erreur");
alert.setHeaderText(null);
alert.setContentText("Veuillez d'abord charger les données avant de modifier les parametres");
alert.showAndWait();
return;
}
LoadableData dataType = model.getDatas().get(0); LoadableData dataType = model.getDatas().get(0);
controller.setMainStageView(mainStageView);
controller.setSelectAbs(dataType.getAttributesName()); controller.setSelectAbs(dataType.getAttributesName());
controller.setSelectOrd(dataType.getAttributesName()); controller.setSelectOrd(dataType.getAttributesName());
......
...@@ -20,9 +20,7 @@ import javafx.stage.Stage; ...@@ -20,9 +20,7 @@ import javafx.stage.Stage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Random;
public class MainStageView implements Observer { public class MainStageView implements Observer {
...@@ -75,7 +73,9 @@ public class MainStageView implements Observer { ...@@ -75,7 +73,9 @@ public class MainStageView implements Observer {
} }
else{ else{
scatterChart.getData().add(series1); scatterChart.getData().add(series1);
for(LoadableData i : model.getDatas()) { List<LoadableData> points = new ArrayList<>(model.getDatas());
points.addAll(model.getDataToClass());
for(LoadableData i : points) {
Iris iris = (Iris)i; Iris iris = (Iris)i;
XYChart.Data<Double, Double> dataPoint = new XYChart.Data<>(iris.getDataType(actualX), XYChart.Data<Double, Double> dataPoint = new XYChart.Data<>(iris.getDataType(actualX),
iris.getDataType(actualY)); iris.getDataType(actualY));
...@@ -128,7 +128,4 @@ public class MainStageView implements Observer { ...@@ -128,7 +128,4 @@ public class MainStageView implements Observer {
return actualY; return actualY;
} }
public Observable getModel() {
return this.model;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment