4 Commits

Author SHA1 Message Date
c40271a3af JavaDoc 2026-04-08 14:47:53 +02:00
3785ab31b2 JavaDoc 2026-04-08 14:14:16 +02:00
c0fa3ec263 JavaDoc 2026-04-08 14:04:14 +02:00
c62a99089d Merge pull request 'Ben8Avril' (#11) from Ben8Avril into master
Reviewed-on: #11
2026-04-08 09:53:43 +00:00
16 changed files with 179 additions and 469 deletions

View File

@@ -18,5 +18,5 @@ Les fichiers de tests se trouvent dans le dossier ``tests``.
Actuellement, nous avons terminé la complétion/nettoyage par Moyenne/Régression Linéaire.
Nous allons donc voir pour l'interface graphique.
Le fichier qui permet de tester l'ouverture du fichier Test3 pour l'évaluation est le fichier ``ecoparasite.LectureEval``.
Ce fichier a été réalisé par Benjamin THOREL.
Le fichier qui permet de tester l'ouverture du fichier Test2 pour l'évaluation est le fichier ``ecoparasite.LectureEvaltest2``.
Ce fichier a été réalisé par Sébastien BOUSQUET.

View File

@@ -1,36 +1,7 @@
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.MackerelSerra;
import ecoparasite.poisson.Poisson;
import ecoparasite.representation.ValeursXY;
import java.util.HashSet;
import java.util.function.BiConsumer;
import java.util.function.Function;
public class Application {
public static void main(String[] args) throws InputFileException, RawDataOverflow {
RawData rawMackerel = InputFactory.readData("test2.csv", ",");
HashSet<Poisson> mackerelSet = MackerelSerra.parse(rawMackerel);
System.out.println( mackerelSet );
Function<Poisson,Double> getLength = Poisson::getLength;
Function<Poisson,Double> getInfes = Poisson::getInfestation;
BiConsumer<Poisson,Double> setInfes = Poisson::setInfestation;
mackerelSet = Completion.completeColumnsLinear( mackerelSet, getLength, getInfes, setInfes );
mackerelSet = Nettoyage.nettoieColumnsLinear( mackerelSet, getLength, getInfes, setInfes, false );
HashSet<ValeursXY> mackerelXY = ValeursXY.convertToXY( mackerelSet, getLength, getInfes );
public static void main(String[] args) {
System.out.println("Hello World");
}
}

View File

@@ -77,6 +77,13 @@ public class Poisson{
this.infestation = infestation;
}
/**
* Setter de l'attribut length
* @param length le Double de la nouvelle valeur de length
*/
public void setLength(Double length) {
this.length = length;
}
/**
* Setter de l'attribut des parties de poisson.

View File

@@ -0,0 +1,4 @@
package ecoparasite.representation;
public class ValeurXY {
}

View File

@@ -1,39 +0,0 @@
package ecoparasite.representation;
import java.util.HashSet;
import java.util.function.Function;
public class ValeursXY {
private double x;
private double y;
public ValeursXY(double x, double y){
this.x = x;
this.y = y;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public static <T,V extends Number> HashSet<ValeursXY> convertToXY(HashSet<T> list, Function<T,V> getX, Function<T,V> getY){
HashSet<ValeursXY> xy = new HashSet<ValeursXY>();
for(T item : list){
if(getX.apply(item) != null && getY.apply(item) != null){
xy.add( new ValeursXY(getX.apply(item).doubleValue(), getY.apply(item).doubleValue()));
}
}
return xy;
}
}

View File

@@ -1,27 +0,0 @@
package ecoparasite.svg;
public class Coordonnees {
private double x;
private double y;
public Coordonnees(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
}

View File

@@ -1,76 +0,0 @@
package ecoparasite.svg;
import ecoparasite.svg.elements.Element;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.UUID;
public class SVGFactory {
static final private String EXPORT_PATH = "export/";
static final private String EXTENSION = ".svg";
public static boolean createSVG(ArrayList<Element> mesElements){
String code = createSVGCode(mesElements);
try {
createFile(code);
} catch (Exception e) {
return false;
}
return true;
}
public static boolean createSVG(ArrayList<Element> mesElements, String filename) {
String code = createSVGCode(mesElements);
try {
createFile(code,filename);
} catch (Exception e) {
return false;
}
return true;
}
public static String createSVGCode(ArrayList<Element> mesElements){
String code = "<svg height=\"800\" width=\"800\" >";
for (Element e : mesElements){
code += e.toSVG();
}
code += "</svg>";
return code;
}
public static void createFile(String data) throws IOException {
String id = UUID.randomUUID().toString();
createFile(data,id);
}
public static void createFile(String data, String filename) throws IOException {
// create a FileWriter object with the file name
FileWriter writer = new FileWriter(EXPORT_PATH + filename + EXTENSION);
// write the string to the file
writer.write(data);
// close the writer
writer.close();
System.out.println("Successfully wrote text to file.");
}
}

View File

@@ -0,0 +1,111 @@
package ecoparasite.svg.SVGFactory;
import ecoparasite.representation.ValeurXY;
import ecoparasite.svg.elements.Element;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.UUID;
/**
* Classe Définissant de manière static les méthodes pour créer un fichier SVG de nos graphiques
*/
public class SVGFactory {
/**
* Chemin d'export et Extension du fichier
*/
static final private String EXPORT_PATH = "export/";
static final private String EXTENSION = ".svg";
/**
* Fonction createSVG permettant de créer le fichier SVG dans le dossier du chemin d'export.
* Le nom du fichier est defini automatiquement.
* @param mesElements tableau composé des différents éléments de notre graphique
* @return True si la fonction a réussi à créer le fichier, False sinon
*/
public static boolean createSVG(HashSet<Element> mesElements){
String code = createSVGCode(mesElements);
try {
createFile(code);
} catch (Exception e) {
return false;
}
return true;
}
/**
* Fonction createSVG permettant de créer le fichier SVG dans le dossier du chemin d'export.
* @param mesElements tableau composé des différents éléments de notre graphique
* @param filename String contenant le nom du fichier voulu
* @return True si la fonction a réussi à créer le fichier, False sinon
*/
public static boolean createSVG(HashSet<Element> mesElements, String filename) {
String code = createSVGCode(mesElements);
try {
createFile(code,filename);
} catch (Exception e) {
return false;
}
return true;
}
/**
* Permet la création du code de notre SVG
* @param mesElements tableau d'élement de notre graphiques
* @return une String contenant le code complet de notre SVG
*/
public static String createSVGCode(HashSet<Element> mesElements){
String code = "<svg height=\"800\" width=\"800\" >";
for (Element e : mesElements){
code += e.toSVG();
}
code += "</svg>";
return code;
}
/**
* Permet de lancer la création du fichier. Cette version ne prend pas de filename mais à la place créer un UUID random pour.
* @param data String contenant le code de notre SVG
* @throws IOException C'est une création de fichier, il peut y avoir des erreurs
*/
public static void createFile(String data) throws IOException {
String id = UUID.randomUUID().toString();
createFile(data,id);
}
/**
* Permet de créer un fichier SVG contenant notre graphique
* @param data String contenant le code de notre SVG
* @param filename String contenant le nom de notre fichier
* @throws IOException
*/
public static void createFile(String data, String filename) throws IOException {
// create a FileWriter object with the file name
FileWriter writer = new FileWriter(EXPORT_PATH + filename + EXTENSION);
// write the string to the file
writer.write(data);
// close the writer
writer.close();
System.out.println("Successfully wrote text to file.");
}
}

View File

@@ -1,49 +0,0 @@
package ecoparasite.svg.elements;
import ecoparasite.svg.Coordonnees;
public class Circle extends Element {
private int rayon;
private String color;
public Circle(Coordonnees coordonnees, int rayon, String color) {
super(coordonnees);
this.rayon = rayon;
this.color = color;
}
public Circle(Coordonnees coordonnees, int rayon) {
super(coordonnees);
this.rayon = rayon;
this.color = ElementsFactory.COLOR_RED;
}
public int getRayon() {
return rayon;
}
public void setRayon(int rayon) {
this.rayon = rayon;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
@Override
public String toSVG() {
StringBuilder svg = new StringBuilder();
svg.append("<circle ");
String str = String.format( "r=\"%d\" cx=\"%d\" cy=\"%d\" fill=\"%s\"", this.rayon, this.coordonnees.getX(), this.coordonnees.getY(), this.color);
svg.append( str );
svg.append(" />");
return svg.toString();
}
}

View File

@@ -1,31 +1,12 @@
package ecoparasite.svg.elements;
import ecoparasite.svg.Coordonnees;
public class Element {
abstract public class Element {
protected Coordonnees coordonnees;
public Element(Coordonnees coordonnees) {
this.coordonnees = coordonnees;
public Element() {
System.out.println("Un Element... Non implémenter encore");
}
public Coordonnees getCoordonnees() {
return coordonnees;
public String toSVG() {
return "une string";
}
public void setCoordonnees(Coordonnees coordonnees) {
this.coordonnees = coordonnees;
}
public void setCoordonnees(int x, int y) {
this.coordonnees = new Coordonnees(x, y);
}
/**
* Méthode abstraite qui va permettre de transformer notre élément en SVG.
* @return La String SVF
*/
abstract public String toSVG();
}

View File

@@ -1,68 +0,0 @@
package ecoparasite.svg.elements;
import ecoparasite.svg.Coordonnees;
import java.util.ArrayList;
import java.util.HashSet;
public class ElementsFactory {
final public static int SVG_SIZE = 800;
final public static int SVG_OFFSET = 50;
final public static int AXES_TEXT_SIZE = 10;
final public static String COLOR_RED = "red";
final public static String COLOR_BLUE = "blue";
final public static String COLOR_BLACK = "black";
/**
* Permet de générer les éléments axes du fichier SVG.
* @return
*/
public static ArrayList<Element> SVGAxes(String HName, String VName ){
final int begin = SVG_OFFSET + AXES_TEXT_SIZE + (AXES_TEXT_SIZE / 2);
final int end = SVG_SIZE - SVG_OFFSET - AXES_TEXT_SIZE - (AXES_TEXT_SIZE / 2);
Element V = new Line(
new Coordonnees( begin, begin ),
new Coordonnees( begin, SVG_SIZE - SVG_OFFSET ),
COLOR_BLACK,
2
);
Element H = new Line(
new Coordonnees( begin, SVG_SIZE - SVG_OFFSET ),
new Coordonnees( end, SVG_SIZE - SVG_OFFSET ),
COLOR_BLACK,
2
);
Element VLabel = new Text(
new Coordonnees( SVG_OFFSET, SVG_OFFSET ),
VName,
COLOR_BLACK,
AXES_TEXT_SIZE
);
Element HLabel = new Text(
new Coordonnees( SVG_SIZE - SVG_OFFSET - AXES_TEXT_SIZE, SVG_SIZE - SVG_OFFSET - AXES_TEXT_SIZE ),
HName,
COLOR_BLACK,
AXES_TEXT_SIZE
);
ArrayList<Element> SVGAxes = new ArrayList<>();
SVGAxes.add(V);
SVGAxes.add(H);
SVGAxes.add(VLabel);
SVGAxes.add(HLabel);
return SVGAxes;
}
public static ArrayList<Element> SVGAxes(){
return SVGAxes( "None", "None" );
}
}

View File

@@ -1,76 +0,0 @@
package ecoparasite.svg.elements;
import ecoparasite.svg.Coordonnees;
public class Line extends Element {
private Coordonnees coordonneesB;
private String color;
private int lineWidth;
public Line(Coordonnees coordonneesA, Coordonnees coordonneesB, String color, int lineWidth) {
super(coordonneesA);
this.coordonneesB = coordonneesB;
this.color = color;
this.lineWidth = lineWidth;
}
public Line(Coordonnees coordonneesA, Coordonnees coordonneesB) {
super(coordonneesA);
this.coordonneesB = coordonneesB;
this.color = ElementsFactory.COLOR_RED;
this.lineWidth = 1;
}
public Coordonnees getCoordonneesA() {
return coordonnees;
}
public void setCoordonneesA(Coordonnees coordonnees) {
this.coordonnees = coordonnees;
}
public Coordonnees getCoordonneesB() {
return coordonneesB;
}
public void setCoordonneesB(Coordonnees coordonnees) {
this.coordonneesB = coordonnees;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getLineWidth() {
return lineWidth;
}
public void setLineWidth(int lineWidth) {
this.lineWidth = lineWidth;
}
@Override
public String toSVG() {
StringBuilder svg = new StringBuilder();
svg.append("<line ");
String params = String.format( "x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\"stroke:%s;stroke-width:%d\"",
this.coordonnees.getX(),
this.coordonnees.getY(),
this.coordonneesB.getX(),
this.coordonneesB.getY(),
this.color,
this.lineWidth
);
svg.append(params);
svg.append( "/>" );
return svg.toString();
}
}

View File

@@ -1,62 +0,0 @@
package ecoparasite.svg.elements;
import ecoparasite.svg.Coordonnees;
public class Text extends Element {
private String text;
private String color;
private int size;
public Text(Coordonnees coordonnees, String text, String color, int size) {
super(coordonnees);
this.text = text;
this.color = color;
this.size = size;
}
public Text(Coordonnees coordonnees, String text) {
super(coordonnees);
this.text = text;
this.color = ElementsFactory.COLOR_BLACK;
this.size = ElementsFactory.AXES_TEXT_SIZE;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
@Override
public String toSVG() {
StringBuilder svg = new StringBuilder();
svg.append("<text ");
String params = String.format( "x=\"%d\" y=\"%d\" fill=\"%s\" font-size=\"%s\"", coordonnees.getX(), coordonnees.getY(), color, size);
svg.append(params);
svg.append(" >");
svg.append( this.text );
svg.append("</text>");
return svg.toString();
}
}

View File

@@ -0,0 +1,23 @@
package ecoparasite.poisson;
import ecoparasite.input.InputFactory;
import ecoparasite.input.InputFileException;
import ecoparasite.input.RawData;
import ecoparasite.input.RawDataOverflow;
import org.junit.jupiter.api.Test;
import java.util.HashSet;
import static org.junit.jupiter.api.Assertions.*;
class MackerelSerraTest {
@Test
void parse() throws InputFileException, RawDataOverflow {
RawData test = InputFactory.readData("test2.csv", ",");
HashSet<Poisson> testp = MackerelSerra.parse(test);
System.out.println(testp);
}
}

View File

@@ -0,0 +1,25 @@
package ecoparasite.svg.SVGFactory;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class SVGFactoryTest {
@Test
void createSVGCode() {
//String ret = SVGFactory.createSVGCode();
//System.out.println(ret);
}
@Test
void testCreateFile() {
//String ret = SVGFactory.createSVGCode();
//SVGFactory.createFile(ret);
}
}

View File

@@ -1,15 +0,0 @@
package ecoparasite.svg;
import ecoparasite.svg.elements.ElementsFactory;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class SVGFactoryTest {
@Test
public void generateSVGAxes(){
SVGFactory.createSVG( ElementsFactory.SVGAxes() );
}
}