diff --git a/res/stages/main-stage.fxml b/res/stages/main-stage.fxml index c2f1a365d2da7440bf55d75c78c8c07b4d89f91c..1e6fdc9b6536a7d946ca517c86d9cf002de7367b 100644 --- a/res/stages/main-stage.fxml +++ b/res/stages/main-stage.fxml @@ -44,11 +44,11 @@ </Label> <VBox layoutY="345.0" prefHeight="78.0" prefWidth="678.0"> <children> - <HBox fx:id="legend" alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="10.0"> + <VBox fx:id="legend" alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="10.0"> <padding> <Insets left="2.0" right="2.0" /> </padding> - </HBox> + </VBox> </children></VBox> </children> <HBox.margin> diff --git a/src/main/java/fr/univlille/sae/classification/controller/DataVisualizationController.java b/src/main/java/fr/univlille/sae/classification/controller/DataVisualizationController.java index 31ace1cf8e0f0d659a02f57e13ab024e84dda1f9..5ef74cc7e39ae4b8cb3dd04ad4ae9900740f78e6 100644 --- a/src/main/java/fr/univlille/sae/classification/controller/DataVisualizationController.java +++ b/src/main/java/fr/univlille/sae/classification/controller/DataVisualizationController.java @@ -21,7 +21,7 @@ public abstract class DataVisualizationController { Label AxesSelected; @FXML - HBox legend; + VBox legend; @FXML @@ -148,9 +148,9 @@ public abstract class DataVisualizationController { - public void loadLegend(VBox hbox) { + public void loadLegend(VBox vBox) { this.legend.getChildren().clear(); - this.legend.getChildren().addAll(hbox.getChildren()); + this.legend.getChildren().addAll(vBox.getChildren()); } 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 670de56e73a5d89c5793525fd64709cc165ad66d..d1b6696c9a3b53870870913fb953e819b3f1a413 100644 --- a/src/main/java/fr/univlille/sae/classification/model/LoadableData.java +++ b/src/main/java/fr/univlille/sae/classification/model/LoadableData.java @@ -50,18 +50,40 @@ public abstract class LoadableData { public static void setClassificationTypes(Set<String> classificationTypes) { LoadableData.classificationTypes = classificationTypes; LoadableData.classification.clear(); - + int nbOfColors = classificationTypes.size() + 1; int nb = 0; for(String s : classificationTypes) { // Génération de couleurs avec une plage évitant le blanc - LoadableData.classification.put(s, getColor(nb++)); + LoadableData.classification.put(s, getColor(nb++, nbOfColors)); + } + + LoadableData.classification.put("undefined", getColor(nb,nbOfColors)); + } + + + private static Color getColor(int nb, int totalColors) { + // Ratio pour répartir les couleurs uniformément + double ratio = (double) nb / (double) totalColors; + + // Utilisation de fonctions trigonométriques pour des transitions douces + double red = 0.5 + 0.4 * Math.sin(2 * Math.PI * ratio); // Oscille entre 0.1 et 0.9 + double green = 0.5 + 0.4 * Math.sin(2 * Math.PI * ratio + Math.PI / 3); // Décalage de phase + double blue = 0.5 + 0.4 * Math.sin(2 * Math.PI * ratio + 2 * Math.PI / 3); // Décalage de phase + + // Réduction de la luminosité pour éviter le blanc et gris clair + double maxComponent = Math.max(red, Math.max(green, blue)); + if (maxComponent > 0.8) { + red *= 0.8 / maxComponent; + green *= 0.8 / maxComponent; + blue *= 0.8 / maxComponent; } - LoadableData.classification.put("undefined", getColor(nb)); + // Conversion en objet Color + return Color.color(red, green, blue); } - private static Color getColor(int i) { + /* private static Color getColor(int i) { double ratio = (double) i / classificationTypes.size(); // Réduire les composantes pour éviter les tons clairs @@ -73,6 +95,8 @@ public abstract class LoadableData { } + */ + /** * Définit la classification de l'objet. * @param classification classification à définir. diff --git a/src/main/java/fr/univlille/sae/classification/utils/ViewUtil.java b/src/main/java/fr/univlille/sae/classification/utils/ViewUtil.java index 5f5e3ec640f5d0fbd37259a0e98b4da606e79e93..8613467602476d7429b0085881ba871cfac2c9dd 100644 --- a/src/main/java/fr/univlille/sae/classification/utils/ViewUtil.java +++ b/src/main/java/fr/univlille/sae/classification/utils/ViewUtil.java @@ -92,21 +92,19 @@ public class ViewUtil { tempHBox.getChildren().addAll(rectangle, label); line.getChildren().add(tempHBox); - } - } if(colorsString.length < 7) legend.getChildren().add(line); /** - for(String s : colors.keySet()) { - Circle c = new Circle(5); - c.setFill(colors.get(s)); - label = new Label(s); - tempHBox = new HBox(); - tempHBox.getChildren().addAll(c, label); - - hbox.getChildren().add(tempHBox); - } + for(String s : colors.keySet()) { + Circle c = new Circle(5); + c.setFill(colors.get(s)); + label = new Label(s); + tempHBox = new HBox(); + tempHBox.getChildren().addAll(c, label); + + hbox.getChildren().add(tempHBox); + } */ return legend; 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 585ffe0e0fb8e2cf44cb61795e03be485325dfa6..36661733bc711b9951119c79df26b58938cdbedb 100644 --- a/src/main/java/fr/univlille/sae/classification/view/MainStageView.java +++ b/src/main/java/fr/univlille/sae/classification/view/MainStageView.java @@ -13,6 +13,7 @@ import javafx.scene.chart.ScatterChart; import javafx.scene.chart.XYChart; import javafx.scene.control.*; import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; import javafx.scene.shape.*; import javafx.stage.Stage; @@ -58,7 +59,7 @@ public class MainStageView extends DataVisualizationView implements Observer { FXMLLoader loader = new FXMLLoader(); try { - URL fxmlFileUrl = getClass().getClassLoader().getResource("stages" + File.separator + "main-stage.fxml"); + URL fxmlFileUrl = getClass().getClassLoader().getResource("stages"+File.separator+"main-stage.fxml"); if (fxmlFileUrl == null) { System.out.println("Impossible de charger le fichier fxml");