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

Merge remote-tracking branch 'origin/master' into hugo-desmons

# Conflicts:
#	src/main/java/fr/univlille/sae/classification/controller/DataVisualizationController.java
#	src/main/java/fr/univlille/sae/classification/utils/ViewUtil.java
#	src/main/java/fr/univlille/sae/classification/view/DataStageView.java
#	src/main/java/fr/univlille/sae/classification/view/MainStageView.java
parents 08d9b972 3611137d
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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());
}
......
......@@ -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));
}
LoadableData.classification.put("undefined", getColor(nb));
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;
}
private static Color getColor(int i) {
// Conversion en objet Color
return Color.color(red, green, blue);
}
/* 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.
......
......@@ -92,8 +92,6 @@ public class ViewUtil {
tempHBox.getChildren().addAll(rectangle, label);
line.getChildren().add(tempHBox);
}
}
if(colorsString.length < 7) legend.getChildren().add(line);
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment