From f764a80882da24935637e29fa19f48d1541a7f18 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 5 May 2024 12:13:06 +0200 Subject: [PATCH] [docs] Some comments, code cleanup et README update --- README.md | 21 ++++++++----------- src/main/java/fr/u_paris/gla/project/App.java | 21 ------------------- .../gla/project/idfm/CSVImageProvider.java | 10 +++++---- .../project/idfm/CSVSchedulesProvider.java | 2 +- .../gla/project/idfm/CSVStreamProvider.java | 2 +- .../u_paris/gla/project/idfm/ImagePair.java | 11 ++++++++++ .../u_paris/gla/project/io/ImageFormat.java | 5 ----- .../u_paris/gla/project/utils/ApiUtils.java | 10 ++++++++- .../u_paris/gla/project/utils/CSVTools.java | 16 -------------- 9 files changed, 37 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 51a3cee..1c67b92 100644 --- a/README.md +++ b/README.md @@ -18,31 +18,28 @@ Afin de compiler et lancer les tests, exécutez simplement mvn verify ``` -Afin de vérifier les tests via JaCoCo. -Les résultats du test sont dans `target/site/jacoco/index.html`. - -```bash -mvn clean jacoco:prepare-agent install jacoco:report -``` - -Par la suite, `mvn jacoco:report` suffit. - Dans sa version initiale, le programme fournit est un simple code qui se lance en terminal ou en application graphique. Une fois le programme compilé, vous trouverez un jar executable dans le dossier target. Au nom de jar près (version changeante), vous pourrez l'exécuter avec: ``` -java -jar target/project-2024.1.0.0-SNAPSHOT.jar --info +java -jar target/project-2024.1.0.0-SNAPSHOT.jar ``` L'option de lancement `--info` causera l'affichage dans la console d'informations de l'application. L'option de lancement `--gui` causera l'ouverture d'une fenêtre affichant le logo de l'Université de Paris. +Sans option, le programme Pathfinder sera lancé. + ## Tests JaCoCo -``` +Afin de vérifier la couverture des tests via JaCoCo: + +```bash mvn clean jacoco:prepare-agent install jacoco:report ``` -Puis ouvrir le fichier `./target/site/jacoco/index.html`. +Les résultats seront stockés dans `target/site/jacoco/index.html`. + +Par la suite, ```mvn jacoco:report``` suffit. diff --git a/src/main/java/fr/u_paris/gla/project/App.java b/src/main/java/fr/u_paris/gla/project/App.java index 043ad3e..357df3e 100644 --- a/src/main/java/fr/u_paris/gla/project/App.java +++ b/src/main/java/fr/u_paris/gla/project/App.java @@ -64,7 +64,6 @@ public class App { } } else { - // testRelease(); run(); } } @@ -83,26 +82,6 @@ public class App { SwingUtilities.invokeLater(() -> new View(graph, finder, s)); } - public static void testRelease(){ - Parse parse = new Parse(); - parse.parseFiles(); - Stop source = parse.getTmp().get("Porte d'Ivry").get(0); - Stop destination = parse.getTmp().get("Châtelet").get(0); - System.out.println("Itinéraire de Porte d'Ivry à Châtelet"); - List result = parse.getItinerary(source, destination, 43200); - for(Path element : result){ - System.out.println(element.getCurrentStop()); - } - System.out.println("°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°"); - System.out.println("Itinéraire de Porte d'Ivry à Châtelet"); - source = parse.getTmp().get("Saint-Jacques").get(0); - destination = parse.getTmp().get("Porte d'Ivry").get(0); - result = parse.getItinerary(source, destination, 43200); - for(Path element : result){ - System.out.println(element.getCurrentStop()); - } - - } /** @param out the output stream */ public static void printAppInfos(PrintStream out) { Properties props = readApplicationProperties(); diff --git a/src/main/java/fr/u_paris/gla/project/idfm/CSVImageProvider.java b/src/main/java/fr/u_paris/gla/project/idfm/CSVImageProvider.java index 04341ee..bd91c79 100644 --- a/src/main/java/fr/u_paris/gla/project/idfm/CSVImageProvider.java +++ b/src/main/java/fr/u_paris/gla/project/idfm/CSVImageProvider.java @@ -60,6 +60,12 @@ public final class CSVImageProvider { return Arrays.copyOf(this.line, this.line.length); } + /** + * This function returns a list of ImagePair, which represents the name of the line and the link to the + * image of the line details. + * The list is created once and then store in a static variable. + * @return an ArrayList of ImagePair + */ public static ArrayList getLineImageMap() { if (lineImageMap != null) return lineImageMap; @@ -72,10 +78,6 @@ public final class CSVImageProvider { String detail = line[ImageFormat.LINE_DETAIL_INDEX]; String imageUrl = line[ImageFormat.IMAGE_URL_INDEX]; - int index = (int) lineImageMap.stream() - .filter(pair -> pair.getLine().equals(label)) - .count(); - lineImageMap.add(new ImagePair(label, detail, imageUrl)); }); } diff --git a/src/main/java/fr/u_paris/gla/project/idfm/CSVSchedulesProvider.java b/src/main/java/fr/u_paris/gla/project/idfm/CSVSchedulesProvider.java index 4f993ce..e700f8b 100644 --- a/src/main/java/fr/u_paris/gla/project/idfm/CSVSchedulesProvider.java +++ b/src/main/java/fr/u_paris/gla/project/idfm/CSVSchedulesProvider.java @@ -71,7 +71,7 @@ public class CSVSchedulesProvider { } /** - * Move to the the nextDescription of a Transport line + * Move to the nextDescription of a Transport line */ private void skipToNextDescription() { if (this.currentDescription.hasNext()) { diff --git a/src/main/java/fr/u_paris/gla/project/idfm/CSVStreamProvider.java b/src/main/java/fr/u_paris/gla/project/idfm/CSVStreamProvider.java index f31339d..068ee68 100644 --- a/src/main/java/fr/u_paris/gla/project/idfm/CSVStreamProvider.java +++ b/src/main/java/fr/u_paris/gla/project/idfm/CSVStreamProvider.java @@ -202,7 +202,7 @@ public final class CSVStreamProvider { } while (currentSegmentStart == null); } - /** Store current trace' data as a String array + /** Store current trace data as a String array * @return The newly generated line of text */ public String[] next() { diff --git a/src/main/java/fr/u_paris/gla/project/idfm/ImagePair.java b/src/main/java/fr/u_paris/gla/project/idfm/ImagePair.java index 90d7d01..8ecc562 100644 --- a/src/main/java/fr/u_paris/gla/project/idfm/ImagePair.java +++ b/src/main/java/fr/u_paris/gla/project/idfm/ImagePair.java @@ -5,8 +5,19 @@ package fr.u_paris.gla.project.idfm; * These getters ables a ComboBox to show the label returned by toString, and get a specific value when the object is returned */ public class ImagePair { + /** + * The name of the line + */ private final String line; + + /** + * The label that will be shown in the ComboBox + */ private final String label; + + /** + * The link of the line details + */ private final String value; public ImagePair(String label, String label_detail, String value){ diff --git a/src/main/java/fr/u_paris/gla/project/io/ImageFormat.java b/src/main/java/fr/u_paris/gla/project/io/ImageFormat.java index e10a671..ca53199 100644 --- a/src/main/java/fr/u_paris/gla/project/io/ImageFormat.java +++ b/src/main/java/fr/u_paris/gla/project/io/ImageFormat.java @@ -3,11 +3,6 @@ */ package fr.u_paris.gla.project.io; -import java.time.format.DateTimeFormatter; -import java.time.format.ResolverStyle; -import java.util.ArrayList; -import java.util.List; - /** * A tool class for the Image format. */ diff --git a/src/main/java/fr/u_paris/gla/project/utils/ApiUtils.java b/src/main/java/fr/u_paris/gla/project/utils/ApiUtils.java index 3a40845..bc5f24e 100644 --- a/src/main/java/fr/u_paris/gla/project/utils/ApiUtils.java +++ b/src/main/java/fr/u_paris/gla/project/utils/ApiUtils.java @@ -17,9 +17,17 @@ public class ApiUtils { private static final Logger LOGGER = Logger .getLogger(IDFMNetworkExtractor.class.getName()); - // OpenStreetMap API URL + /** + * OpenStreetMap API URL + */ private static final String OSM_URL = "https://nominatim.openstreetmap.org/search"; + /** + * This function returns the GPS location of a string, using OSM API. + * The string can be anything, and adress, a street, a place. + * @param term the term to search + * @return the GPS location, (0,0) if not result + */ public static double[] getGPSLocation(String term) { try { String urlString = String.format("%s?q=%s&format=json", OSM_URL, URLEncoder.encode(term, StandardCharsets.UTF_8)); diff --git a/src/main/java/fr/u_paris/gla/project/utils/CSVTools.java b/src/main/java/fr/u_paris/gla/project/utils/CSVTools.java index 6b51854..c9a1fd8 100644 --- a/src/main/java/fr/u_paris/gla/project/utils/CSVTools.java +++ b/src/main/java/fr/u_paris/gla/project/utils/CSVTools.java @@ -87,20 +87,4 @@ public final class CSVTools { } } } - - // /** Save our current CSV variable's data into an actual file - // * @param filename the saved file's name and path - // * @param contentLineConsumer our data variable - // * @throws IOException if we can't write the data into the file - // */ - // public static void writeCSVToFile(String filename, - // Stream contentLinesConsumer) throws IOException { - // try (FileWriter writer = new FileWriter(filename, StandardCharsets.UTF_8)) { - // CSVWriterBuilder wBuilder = new CSVWriterBuilder(writer).withSeparator(';'); - // try (ICSVWriter csv = wBuilder.build()) { - // contentLinesConsumer.forEachOrdered(line -> Arrays.stream(line).forEach(csv::writeNext)); - // } - // } - // } - }