From c13bb289ed4f89a1a9b9b7855148e5cd23b51c5e Mon Sep 17 00:00:00 2001 From: Lycano Date: Wed, 8 Apr 2026 16:00:42 +0200 Subject: [PATCH 1/4] JavaDoc --- src/ecoparasite/poisson/Poisson.java | 9 +++++ src/ecoparasite/svg/SVGFactory.java | 58 ++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/src/ecoparasite/poisson/Poisson.java b/src/ecoparasite/poisson/Poisson.java index f0deeee..97ef6ea 100644 --- a/src/ecoparasite/poisson/Poisson.java +++ b/src/ecoparasite/poisson/Poisson.java @@ -77,6 +77,13 @@ public class Poisson{ this.infestation = infestation; } + /** + * Setter de l'attribut length + * @param length le Double de la nouvelle valeur de la length + */ + public void setLength(Double length) { + this.length = length; + } /** * Setter de l'attribut des parties de poisson. @@ -95,4 +102,6 @@ public class Poisson{ String result = "[ %5s : %4f mm, %4f g, %4f taux d'infestation ]"; return String.format(result, this.getClass().getSimpleName(), this.getLength(), this.getWeight(), this.getInfestation() ); } + + } diff --git a/src/ecoparasite/svg/SVGFactory.java b/src/ecoparasite/svg/SVGFactory.java index 0c695d5..d65e2e2 100644 --- a/src/ecoparasite/svg/SVGFactory.java +++ b/src/ecoparasite/svg/SVGFactory.java @@ -1,10 +1,13 @@ package ecoparasite.svg; +import ecoparasite.representation.ValeursXY; import ecoparasite.svg.elements.Element; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.UUID; public class SVGFactory { @@ -73,4 +76,59 @@ public class SVGFactory { } + public static HashMap< String ,HashSet> PointAXES(HashSet h){ + + //Définition initial + HashSet x = new HashSet<>(); + HashSet y = new HashSet<>(); + HashSet offset = new HashSet<>(); + HashMap< String, HashSet > map = new HashMap<>(); + + //Définition des min et max + double max_x = Double.MIN_VALUE; + double min_x = Double.MAX_VALUE; + double max_y = Double.MIN_VALUE; + double min_y = Double.MAX_VALUE; + + //Trouvé les min et max + for (ValeursXY var : h) { + + if (max_x < var.getX()){ + max_x = var.getX(); + } else if (min_x > var.getX()){ + min_x = var.getX(); + } + + if (max_y < var.getY()){ + max_y = var.getY(); + } else if (min_y > var.getY()){ + min_y = var.getY(); + } + + } + + double step_x = (max_x - min_x); //TODO + double step_y = (max_y - min_y); //TODO + + + //TODO + + + return null; + } + + /** + * retourne une valeur arrondi "joli" adapter à un graphique + * @param value + * @param step + * @return + */ + public static double roundMin(double value, double step) { + return Math.floor(value / step) * step; + } + + public static double roundMax(double value, double step) { + return Math.ceil(value / step) * step; + } + } From 7305393f6c1819b127a4c16301fdae0cbee6891d Mon Sep 17 00:00:00 2001 From: Lycano Date: Mon, 20 Apr 2026 16:39:00 +0200 Subject: [PATCH 2/4] JavaDoc --- src/ecoparasite/LectureEval.java | 122 ---------------------------- src/ecoparasite/svg/SVGFactory.java | 44 +++++++++- 2 files changed, 41 insertions(+), 125 deletions(-) delete mode 100644 src/ecoparasite/LectureEval.java diff --git a/src/ecoparasite/LectureEval.java b/src/ecoparasite/LectureEval.java deleted file mode 100644 index ba1cf62..0000000 --- a/src/ecoparasite/LectureEval.java +++ /dev/null @@ -1,122 +0,0 @@ -package ecoparasite; - -import ecoparasite.completion.Completion; -import ecoparasite.input.InputFactory; -import ecoparasite.input.InputFileException; -import ecoparasite.input.RawData; -import ecoparasite.input.RawDataOverflow; -import ecoparasite.nettoyage.Nettoyage; -import ecoparasite.poisson.Poisson; -import ecoparasite.population.Population; -import ecoparasite.population.PopulationArgInterval; -import ecoparasite.population.PopulationArgs; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.function.BiConsumer; -import java.util.function.Function; - -public class LectureEval { - - public static HashSet parseEval( RawData popRaw ){ - - HashSet popEspece = new HashSet<>(); - - int index = 1; - try { - while(true){ - HashMap fields = popRaw.getEntry(index); - - String espece = fields.get("Espèce"); - - Population population = new Population(espece); - - if( population.getTotal() == null ){ - population.setTotal( new PopulationArgs() ); - } - for( String k: fields.keySet() ){ - if( k.equals("Espèce") ) - continue; - - LectureEval.applyValueForPopEval( population.getTotal(), k, fields.get(k) ); - } - - popEspece.add(population); - index++; - } - } catch (RawDataOverflow e) { - // Fin de la liste. - } - - return popEspece; - } - - public static void applyValueForPopEval( PopulationArgs popArgs, String column, String value ){ - - if( value == null || value == "" ) // On n'ajoute pas les valeurs nulles. - return; - - switch (column){ - case "zone": - popArgs.setZone(value); - break; - case "N": - popArgs.setNumber( Integer.parseInt(value) ); - break; - case "Prevalence": - popArgs.setPrevalence(PopulationArgInterval.fromString(value)); - break; - case "LT mm": - popArgs.setLength(PopulationArgInterval.fromString(value)); - break; - case "Masse g": - popArgs.setWidth(PopulationArgInterval.fromString(value)); - break; - default: - break; - } - } - - public static void main(String[] args) throws RawDataOverflow { - - RawData popRaw; - try { - popRaw = InputFactory.readData("test3.csv", "," ); - } catch(InputFileException e) { - System.out.println(e.getMessage()); - return; - } - - HashSet pop = parseEval(popRaw); - - // System.out.println( popRaw.getEntry(1) ); - - for( Population p: pop){ - System.out.println(p); - } - - // Complétion de la masse. - Function getWeight = population -> { - return population.getTotal().getWidth() != null ? population.getTotal().getWidth().transformToDouble() : null; - }; - BiConsumer setWeight = (population, aDouble) -> { - population.getTotal().setWidth(new PopulationArgInterval(aDouble,aDouble)); - }; - - // Complétion de la masse. - pop = Completion.completeColumnsMoyenne(pop, getWeight, setWeight); - System.out.println("---"); - for( Population p: pop){ - System.out.println(p); - } - - // Nettoyage de la masse. - pop = Nettoyage.nettoieColumnsMoyenne(pop, getWeight, setWeight, false); - System.out.println("---"); - for( Population p: pop){ - System.out.println(p); - } - - } - -} diff --git a/src/ecoparasite/svg/SVGFactory.java b/src/ecoparasite/svg/SVGFactory.java index d65e2e2..9076133 100644 --- a/src/ecoparasite/svg/SVGFactory.java +++ b/src/ecoparasite/svg/SVGFactory.java @@ -107,16 +107,54 @@ public class SVGFactory { } - double step_x = (max_x - min_x); //TODO - double step_y = (max_y - min_y); //TODO + double range_x = max_x-min_x; + double range_y = max_y-min_y; + int target = 10; // Ideal Number of Gradation - //TODO + double step_x = niceStep(range_x,target); + double step_y = niceStep(range_y,target); + + double nicemin_x = roundMin(min_x,step_x); + double nicemax_x = roundMax(max_x,step_x); + double nicemin_y = roundMin(min_y,step_y); + double nicemax_y = roundMax(max_y,step_y); + + HashSet axe_x = new HashSet<>(); + HashSet axe_y = new HashSet<>(); return null; } + /** + * Fonction de calcul d'un step rond + * Cette fonction est basé sur une idée demandée à ChatGPT + * @param range écart entre la plus petite et la plus grande valeur + * @param targetTicks nombre de gradation ideal + * @return + */ + public static double niceStep(double range, int targetTicks) { + + double rawStep = range / targetTicks; + + double exponent = Math.floor(Math.log10(rawStep)); + double fraction = rawStep / Math.pow(10, exponent); + + double niceFraction; + + if (fraction < 1.5) + niceFraction = 1; + else if (fraction < 3) + niceFraction = 2; + else if (fraction < 7) + niceFraction = 5; + else + niceFraction = 10; + + return niceFraction * Math.pow(10, exponent); + } + /** * retourne une valeur arrondi "joli" adapter à un graphique * @param value From 35274a963bd6763b5732dde9efbdf2b5dd6c6a48 Mon Sep 17 00:00:00 2001 From: Lycano Date: Wed, 22 Apr 2026 11:05:14 +0200 Subject: [PATCH 3/4] JavaDoc --- src/ecoparasite/svg/SVGFactory.java | 41 ++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/ecoparasite/svg/SVGFactory.java b/src/ecoparasite/svg/SVGFactory.java index 9076133..4e9cf9e 100644 --- a/src/ecoparasite/svg/SVGFactory.java +++ b/src/ecoparasite/svg/SVGFactory.java @@ -76,13 +76,9 @@ public class SVGFactory { } - public static HashMap< String ,HashSet> PointAXES(HashSet h){ + public static HashMap< String ,HashSet> PointAXES(HashSet h){ - //Définition initial - HashSet x = new HashSet<>(); - HashSet y = new HashSet<>(); - HashSet offset = new HashSet<>(); - HashMap< String, HashSet > map = new HashMap<>(); + HashMap< String, HashSet > map = new HashMap<>(); //Définition des min et max double max_x = Double.MIN_VALUE; @@ -120,11 +116,38 @@ public class SVGFactory { double nicemin_y = roundMin(min_y,step_y); double nicemax_y = roundMax(max_y,step_y); - HashSet axe_x = new HashSet<>(); - HashSet axe_y = new HashSet<>(); + // Compléter un Hashset de Double pour X et pour Y et Offset X et Y. TODO + HashSet axeX = new HashSet<>(); + HashSet axeY = new HashSet<>(); + HashSet OffsetX = new HashSet<>(); + HashSet OffsetY = new HashSet<>(); + Double ix = nicemin_x; + while ( ix <= nicemax_x ) { + axeX.add(ix); + ix+=step_x; + }; + map.put("AxeX", axeX); - return null; + Double iy = nicemin_y; + while ( iy <= nicemax_y ) { + axeY.add(iy); + iy+=step_y; + } + map.put("AxeY",axeY); + + double offsetX = min_x - nicemin_x; + double offsetY = min_y - nicemin_y; + + HashSet offsetXHash = new HashSet<>(); + offsetXHash.add(offsetX); + HashSet offsetYHash = new HashSet<>(); + offsetYHash.add(offsetY); + + map.put("OffsetX", offsetXHash); + map.put("OffsetY", offsetYHash); + + return map; } /** From 90ebe643938313e4ea0c941f73afb0c07362c4ce Mon Sep 17 00:00:00 2001 From: Lycano Date: Wed, 22 Apr 2026 11:17:31 +0200 Subject: [PATCH 4/4] JavaDoc et Gradation des axes Dones --- src/ecoparasite/svg/SVGFactory.java | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/ecoparasite/svg/SVGFactory.java b/src/ecoparasite/svg/SVGFactory.java index 4e9cf9e..575f998 100644 --- a/src/ecoparasite/svg/SVGFactory.java +++ b/src/ecoparasite/svg/SVGFactory.java @@ -15,6 +15,11 @@ public class SVGFactory { static final private String EXPORT_PATH = "export/"; static final private String EXTENSION = ".svg"; + /** + * Permet la création du fichier SVG + * @param mesElements un array des elements à ajouter dans le svg + * @return True si la création est un succès, False sinon + */ public static boolean createSVG(ArrayList mesElements){ String code = createSVGCode(mesElements); @@ -28,6 +33,12 @@ public class SVGFactory { return true; } + /** + * Permet la création du fichier SVG (Polymorphisme pour ajouter un nom de fichier) + * @param mesElements un Array des elements à ajouter dans le SVG + * @param filename une String représentant le nom du fichier choisi + * @return True si la création est un succès, False sinon + */ public static boolean createSVG(ArrayList mesElements, String filename) { String code = createSVGCode(mesElements); @@ -41,6 +52,11 @@ public class SVGFactory { return true; } + /** + * Fonction basique de transformation des éléments en code SVG + * @param mesElements un array contenant les éléments à mettre dans le svg + * @return une String contenant la totalité du code SVG de notre graphique + */ public static String createSVGCode(ArrayList mesElements){ String code = ""; @@ -56,11 +72,22 @@ public class SVGFactory { return code; } + /** + * fonction qui créer le fichier, ici avec une ID random comme nom de fichier + * @param data une String contenant le contenue du fichier désiré (ici pour le SVG) + * @throws IOException Déclenché par un échec de la création du fichier + */ public static void createFile(String data) throws IOException { String id = UUID.randomUUID().toString(); createFile(data,id); } + /** + * Permet la création du fichier + * @param data une String contenant le contenue du fichier désiré + * @param filename une String contenant le nom du fichier voulu + * @throws IOException Déclenché par un échec de la création du fichier + */ public static void createFile(String data, String filename) throws IOException { // create a FileWriter object with the file name @@ -76,6 +103,15 @@ public class SVGFactory { } + /** + * Permet de renvoyer des valeurs "clean" pour l'affichage des axes + * @param h Contient les Coordonnées de chacun des points de nos données + * @return une HashMap de String et de Hashset de Double. + * Avec la String "AxeX", un Hashset de Double contenant les valeurs des gradations de l'axe X + * Avec la String "AxeY", un Hashset de Double contenant les valeurs des gragations de l'axe Y + * Avec la String "OffsetX", un Hashset de Double contenant uniquement la valeur de l'offset des points par rapport à l'axe X + * Avec la String "OffsetY", un Hashset de Double contenant uniquement la valeur de l'offset des points par rapport à l'axe Y + */ public static HashMap< String ,HashSet> PointAXES(HashSet h){ HashMap< String, HashSet > map = new HashMap<>();