diff --git a/src/main/java/fr/univlille/sae/classification/controller/AxesSettingsController.java b/src/main/java/fr/univlille/sae/classification/controller/AxesSettingsController.java
index 4d46b665df7f0e25db3c4ee6ba42c65c302e169f..16cae7a159098b17cb3abc58e7f1c52e33d2dc7d 100644
--- a/src/main/java/fr/univlille/sae/classification/controller/AxesSettingsController.java
+++ b/src/main/java/fr/univlille/sae/classification/controller/AxesSettingsController.java
@@ -25,11 +25,13 @@ public class AxesSettingsController{
public void setSelectOrd(String[] fields){
selectOrd.getItems().clear();
selectOrd.getItems().addAll(fields);
+ selectOrd.setValue(mainStageView.getActualY());
}
public void setSelectAbs(String[] fields){
selectAbs.getItems().clear();
selectAbs.getItems().addAll(fields);
+ selectAbs.setValue(mainStageView.getActualX());
}
public void setMainStageView(MainStageView mainStageView) {
diff --git a/src/main/java/fr/univlille/sae/classification/model/Iris.java b/src/main/java/fr/univlille/sae/classification/model/Iris.java
index 8d4d2c0e60e9f6f8ae667506c7d8a83257f40dad..20d5b2e9880f0b9bb4926e7137cf55f7e1b9b836 100644
--- a/src/main/java/fr/univlille/sae/classification/model/Iris.java
+++ b/src/main/java/fr/univlille/sae/classification/model/Iris.java
@@ -1,7 +1,7 @@
package fr.univlille.sae.classification.model;
-import java.util.Set;
import com.opencsv.bean.*;
+import javafx.scene.paint.Color;
public class Iris extends LoadableData{
@@ -13,6 +13,8 @@ public class Iris extends LoadableData{
private double petalWidth;
@CsvBindByName(column = "petal.length")
private double petalLength;
+ @CsvBindByName(column = "variety")
+ private String variety;
public Iris(double sepalWidth, double sepalLength, double petalWidth, double petalLength) {
this(sepalWidth, sepalLength, petalWidth, petalLength, "undefined");
@@ -22,12 +24,13 @@ public class Iris extends LoadableData{
//
}
- public Iris(double sepalWidth, double sepalLength, double petalWidth, double petalLength, String classification) {
+ public Iris(double sepalWidth, double sepalLength, double petalWidth, double petalLength, String variety) {
super();
this.sepalWidth = sepalWidth;
this.sepalLength = sepalLength;
this.petalWidth = petalWidth;
this.petalLength = petalLength;
+ this.variety = variety;
}
public double getSepalWidth() {
@@ -46,6 +49,10 @@ public class Iris extends LoadableData{
return petalLength;
}
+ public String getVariety() {
+ return variety;
+ }
+
public double getDataType(String axes){
if(axes==null){
return sepalWidth;
@@ -64,6 +71,19 @@ public class Iris extends LoadableData{
}
}
+ public Color getColor(){
+ switch (this.variety){
+ case "Setosa":
+ return Color.RED;
+ case "Versicolor":
+ return Color.BLUE;
+ case "Virginica":
+ return Color.GREEN;
+ default:
+ return Color.BLACK;
+ }
+ }
+
public String[] getAttributesName() {
String[] names = new String[]{
"sepalWidth",
diff --git a/src/main/java/fr/univlille/sae/classification/model/LoadableData.java b/src/main/java/fr/univlille/sae/classification/model/LoadableData.java
index 3e4743db17e065f2c8644084bb54d8ad14eeadd3..fba0fb716aefea3f9a0fb81e584f41671130891c 100644
--- a/src/main/java/fr/univlille/sae/classification/model/LoadableData.java
+++ b/src/main/java/fr/univlille/sae/classification/model/LoadableData.java
@@ -8,13 +8,18 @@ public abstract class LoadableData {
private String classification;
-
protected LoadableData() {
}
+
+ public void addClassification(String classificationType) {
+ this.classificationTypes.add(classificationType);
+ }
+
public String getClassification() {
return this.classification;
}
+
public static Set<String> getClassificationTypes() {
return classificationTypes;
}
diff --git a/src/main/java/fr/univlille/sae/classification/view/MainStageView.java b/src/main/java/fr/univlille/sae/classification/view/MainStageView.java
index 4a74452b4b16edf17f1847ec391fd8e74c31388b..b06f124bfa471bb7d9c86c0a8e1ed59985ad3c57 100644
--- a/src/main/java/fr/univlille/sae/classification/view/MainStageView.java
+++ b/src/main/java/fr/univlille/sae/classification/view/MainStageView.java
@@ -13,11 +13,15 @@ import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.chart.ScatterChart;
import javafx.scene.chart.XYChart;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
public class MainStageView implements Observer {
@@ -61,12 +65,17 @@ public class MainStageView implements Observer {
scatterChart.getData().clear();
if(!(observable instanceof ClassificationModel)) throw new IllegalStateException();
XYChart.Series series1 = new XYChart.Series();
- series1.setName("Dice Launch");
scatterChart.getData().add(series1);
- for(LoadableData i : model.getDatas()) {
- if(model.getType() == DataType.IRIS) {
- series1.getData().add(new XYChart.Data<>(((Iris)i).getDataType(actualX),
- ((Iris)i).getDataType(actualY)));
+ if(model.getType() == DataType.IRIS) {
+ series1.setName("Iris");
+ for(LoadableData i : model.getDatas()) {
+ Iris iris = (Iris)i;
+ 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);
+ series1.getData().add(dataPoint);
}
}
}
@@ -76,14 +85,6 @@ public class MainStageView implements Observer {
}
- public String getActualX() {
- return actualX;
- }
-
- public String getActualY() {
- return actualY;
- }
-
public void setActualX(String actualX) {
this.actualX = actualX;
}
@@ -92,6 +93,14 @@ public class MainStageView implements Observer {
this.actualY = actualY;
}
+ public String getActualX() {
+ return actualX;
+ }
+
+ public String getActualY() {
+ return actualY;
+ }
+
public Observable getModel() {
return this.model;
}