diff --git a/src/ecoparasite/Application.java b/src/ecoparasite/Application.java index da367b6..7cd212b 100644 --- a/src/ecoparasite/Application.java +++ b/src/ecoparasite/Application.java @@ -20,16 +20,13 @@ import ecoparasite.svg.SVGFactory; import ecoparasite.svg.elements.Element; import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Scanner; +import java.util.*; import java.util.function.BiConsumer; import java.util.function.Function; public class Application { - static final String[] VALID_FILES = {"mackerel.97442.csv", "merlu2018_75164.csv","ParasitesPeru2021.csv"}; + static final String[] VALID_FILES = {"Campagne/mackerel.97442.csv", "Campagne/merlu2018_75164.csv","Combinés/ParasitesPeru2021.csv"}; public static void validFileName(File dir, HashSet listeName){ @@ -51,30 +48,24 @@ public class Application { String name = ""; boolean isValid = false; + /* File dir = new File("data"); HashSet listeName = new HashSet<>(); Application.validFileName(dir,listeName); + */ while (!isValid) { System.out.println("Veuillez rentrez le nom du fichier :"); name = sc.nextLine(); - if (listeName.contains(name)){ - for (int i = 0; i < 3; i++) { - if (VALID_FILES[i] == name){ - isValid = true; - break; - } + for (int i = 0; i < 3; i++) { + if (name.contains(VALID_FILES[i])){ + isValid = true; + break; } - if (!isValid){ - System.out.println("Ce Fichier existe mais n'est pas valide"); - } - } else { - System.out.println("Ce Fichier n'existe pas dans le dossier data."); } - } return name; @@ -166,21 +157,18 @@ public class Application { } // Nettoyage de la taille. - Function getWeight = population -> { + Function getLength = population -> { return population.getTotal().getLength() != null ? population.getTotal().getLength().transformToDouble() : null; }; - BiConsumer setWeight = (population, aDouble) -> { + BiConsumer setLength = (population, aDouble) -> { population.getTotal().setLength(aDouble != null ? new PopulationArgInterval(aDouble,aDouble) : null); }; Function getInfes = population -> { return population.getTotal().getAbondance() != null ? population.getTotal().getPrevalence().transformToDouble() : null; }; - BiConsumer setInfes = (population, aDouble) -> { - population.getTotal().setAbondance(aDouble != null ? new PopulationArgInterval(aDouble,aDouble) : null); - }; - popSet = Nettoyage.nettoieColumns(popSet, getWeight, setWeight, false); + popSet = Nettoyage.nettoieColumns(popSet, getLength, setLength, false); System.out.println("---"); index = 1; for( Population p: popSet){ @@ -188,14 +176,14 @@ public class Application { } // Complétion de la masse. - popSet = Completion.completeColumnsMoyenne(popSet, getWeight, setWeight); + popSet = Completion.completeColumnsMoyenne(popSet, getLength, setLength); System.out.println("---"); for( Population p: popSet){ System.out.println(String.valueOf(index++) + p); } - HashSet merluXY = ValeursXY.convertToXY( popSet, getLength, getInfes ); - HashMap> axes = SVGBuilder.calcPointAxes( merluXY ); + HashSet popXY = ValeursXY.convertToXY( popSet, getLength, getInfes ); + HashMap> axes = SVGBuilder.calcPointAxes( popXY ); System.out.println( axes ); SVGBuilder axesInstance; @@ -209,10 +197,12 @@ public class Application { ArrayList elements = new ArrayList<>(); - elements.addAll(buildAxes(XLabel, YLabel)); - elements.addAll(buildXTicks()); - elements.addAll(buildYTicks()); - elements.addAll(buildPoints(points)); + elements.addAll(axesInstance.buildAxes("Taille en mm", "Abondance")); + elements.addAll(axesInstance.buildXTicks()); + elements.addAll(axesInstance.buildYTicks()); + elements.addAll(axesInstance.buildPoints(popXY)); + + SVGFactory.createSVG(elements); } public static void main(String[] args) throws InputFileException, RawDataOverflow {