Skip to content
Snippets Groups Projects
Commit b32395fb authored by Hugo Debuyser's avatar Hugo Debuyser Committed by Matias Mennecart
Browse files

Test d'affichage de couleur pour Iris et modification des paramètres des axes

parent b5812879
Branches
Tags
No related merge requests found
......@@ -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) {
......
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",
......
......@@ -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;
}
......
......@@ -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)));
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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment