diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e6e24e7..12daa94 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,25 +1,25 @@ # Comment contribuer à ce projet -2 cas sont possibles pour contribuer à ce projet: +2 cas sont possibles pour contribuer à ce projet : -- Vous ête un étudiant et l'utilisez pour créer votre projet, dans ce cas reportez vous +- Vous ête un étudiant et l'utilisez pour créer votre projet, dans ce cas, reportez-vous à [la section étudiant](#etudiant) -- Vous êtes un enseignant améliorant ce modèle, dans ce cas reportez vous +- Vous êtes un enseignant améliorant ce modèle, dans ce cas, reportez-vous à [la section enseignant](#enseignant) ## Etudiant -Vous ne devez pas contribuer directement à ce projet mais devez en effectuer un fork. Une fois cela -effectué vous devez: +Vous ne devez pas contribuer directement à ce projet, mais devez en effectuer un fork. Une fois cela +effectué, vous devez : -- [x] Ajouter votre identifiant de groupe au champs `groupId` du fichier [pom.xml](pom.xml) sous la +- [x] Ajouter votre identifiant de groupe au champ `groupId` du fichier [pom.xml](pom.xml) sous la forme de `fr.u-paris.gla.votreequipe` -- [ ] Modifier le package principal afin de refleter le nouveau nom de groupe. -- [ ] Adapter le fichier [README](README.md) au contenu de votre projet specifique -- [ ] Adapter ce fichier (CONTRIBUTING.md) à vos propres instructions de contribution, notamment: - - [ ] Convention de style de codage - - [ ] Convention d'utilisation de git - - [ ] Lien avec d'autres projets et d'autres dépôts. +- [x] Modifier le package principal afin de refléter le nouveau nom de groupe. +- [x] Adapter le fichier [README](README.md) au contenu de votre projet spécifique +- [x] Adapter ce fichier (CONTRIBUTING.md) à vos propres instructions de contribution, notamment : + - [x] Convention de style de codage + - [x] Convention d'utilisation de Git + - [x] Lien avec d'autres projets et d'autres dépôts. - [x] Modifier le fichier `application.properties` au besoin. ## Convention de style @@ -41,9 +41,9 @@ séparées, intégrées dans la branche dev une fois terminée. La branche main ne doit contenir que des versions stables de ce modèle. -Le code est écrit en Java, manipulé par l'outils de construction maven et doit suivre les -conventions usuelles du langage et de l'outils. +Le code est écrit en Java, manipulé par l'outil de construction maven et doit suivre les +conventions usuelles du langage et de l'outil. Le package principal du code Java est `fr.u_paris.gla.project` Le fichier de properties `application.properties` permet d'accéder depuis le code Java aux diverses -informations inscrite dans maven. +informations inscrites dans maven. diff --git a/README.md b/README.md index 8b56aa0..c118e1a 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Dans sa version initiale, le programme fournit est un simple code qui se lance e 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: +jar près (version changeante), vous pourrez l'exécuter avec : ``` java -jar target/project-2024.1.0.0-SNAPSHOT.jar --info diff --git a/src/main/java/fr/u_paris/gla/project/gui/View.java b/src/main/java/fr/u_paris/gla/project/gui/View.java index 8e46446..402b57c 100644 --- a/src/main/java/fr/u_paris/gla/project/gui/View.java +++ b/src/main/java/fr/u_paris/gla/project/gui/View.java @@ -6,8 +6,6 @@ import java.awt.Dimension; import java.awt.GridLayout; import java.awt.HeadlessException; import java.awt.Point; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; @@ -29,13 +27,9 @@ import javax.swing.table.TableModel; public class View extends JFrame { private final JPanel CardPanel; - private final JMenuItem Home; - private final JMenuItem Network; private final JPanel NetworkPanel; private final JTextField TextLocation; - private final JButton ButtonLocation; private final JPanel HomePanel; - private final JPanel MainPanel; private final DefaultTableModel modelStops; private final JTable tableStops; private final JTable tableItinerary; @@ -43,19 +37,9 @@ public class View extends JFrame { private final JScrollPane paneStops; private final JScrollPane paneItinerary; private final JPanel ItineraryPanel; - private final JMenuItem Itinerary; - private final JPanel stationsPanel; private final JLabel departText; private final JLabel arrText; private final JTextField TextCoord; - private final JButton ButtonCoord; - private final JPanel SearchCoordPanel; - private final JPanel SearchLocationPanel; - private final JLabel NetworkLabel; - private final JMenuBar ButtonBar; - private final ArrayList StopList; - private JMenuItem Favorites; - private JLabel FavLabel; private String departureCur; private String arrivalCur; @@ -64,50 +48,46 @@ public class View extends JFrame { private String searchCoord; - private ArrayList searchRes; - - private int count = 0; - public View(ArrayList s) throws HeadlessException { - MainPanel = new JPanel(); + JPanel mainPanel = new JPanel(); GridLayout MainLayout = new GridLayout(1, 2, 50, 0); - MainPanel.setLayout(MainLayout); + mainPanel.setLayout(MainLayout); CardLayout CardLay = new CardLayout(); CardPanel = new JPanel(CardLay); HomePanel = new JPanel(); CardPanel.add(HomePanel); - SearchCoordPanel = new JPanel(); - SearchLocationPanel = new JPanel(); + JPanel searchCoordPanel = new JPanel(); + JPanel searchLocationPanel = new JPanel(); GridLayout SearchLayout = new GridLayout(1, 2); HomePanel.setLayout(SearchLayout); - HomePanel.add(SearchCoordPanel); - HomePanel.add(SearchLocationPanel); + HomePanel.add(searchCoordPanel); + HomePanel.add(searchLocationPanel); GridLayout SearchCoordLayout = new GridLayout(2, 1); GridLayout SearchLocationLayout = new GridLayout(2, 1); - SearchCoordPanel.setLayout(SearchCoordLayout); - SearchLocationPanel.setLayout(SearchLocationLayout); + searchCoordPanel.setLayout(SearchCoordLayout); + searchLocationPanel.setLayout(SearchLocationLayout); TextCoord = new JTextField(); - ButtonCoord = new JButton("Look for coords"); - SearchCoordPanel.add(TextCoord); - SearchCoordPanel.add(ButtonCoord); + JButton buttonCoord = new JButton("Look for coords"); + searchCoordPanel.add(TextCoord); + searchCoordPanel.add(buttonCoord); TextLocation = new JTextField(); - ButtonLocation = new JButton("Look for string"); - SearchLocationPanel.add(TextLocation); - SearchLocationPanel.add(ButtonLocation); + JButton buttonLocation = new JButton("Look for string"); + searchLocationPanel.add(TextLocation); + searchLocationPanel.add(buttonLocation); NetworkPanel = new JPanel(); CardPanel.add(NetworkPanel); GridLayout NetworkLayout = new GridLayout(3, 1); NetworkPanel.setLayout(NetworkLayout); - NetworkLabel = new JLabel("Network"); - NetworkPanel.add(NetworkLabel); - stationsPanel = new JPanel(); + JLabel networkLabel = new JLabel("Network"); + NetworkPanel.add(networkLabel); + JPanel stationsPanel = new JPanel(); NetworkPanel.add(stationsPanel); GridLayout StationsLayout = new GridLayout(2, 1); departText = new JLabel("Départ: "); - arrText = new JLabel("Arivée: "); + arrText = new JLabel("Arrivée: "); stationsPanel.setLayout(StationsLayout); stationsPanel.add(departText); stationsPanel.add(arrText); @@ -125,20 +105,20 @@ public class View extends JFrame { paneItinerary.add(tableItinerary); ItineraryPanel.add(paneItinerary); - ButtonBar = new JMenuBar(); + JMenuBar buttonBar = new JMenuBar(); GridLayout ButtonLayout = new GridLayout(3, 1); - ButtonBar.setLayout(ButtonLayout); - Home = new JMenuItem("Home"); - ButtonBar.add(Home); - Network = new JMenuItem("Network"); - ButtonBar.add(Network); + buttonBar.setLayout(ButtonLayout); + JMenuItem home = new JMenuItem("Home"); + buttonBar.add(home); + JMenuItem network = new JMenuItem("Network"); + buttonBar.add(network); - Itinerary = new JMenuItem("Itinerary"); - ButtonBar.add(Itinerary); - ButtonBar.setPreferredSize(new Dimension(50, 500)); + JMenuItem itinerary = new JMenuItem("Itinerary"); + buttonBar.add(itinerary); + buttonBar.setPreferredSize(new Dimension(50, 500)); - MainPanel.add(ButtonBar); - MainPanel.add(CardPanel); + mainPanel.add(buttonBar); + mainPanel.add(CardPanel); modelStops = (DefaultTableModel) tableStops.getModel(); modelStops.setColumnCount(2); @@ -147,47 +127,37 @@ public class View extends JFrame { modelItinerary = (DefaultTableModel) tableItinerary.getModel(); modelItinerary.setColumnCount(3); modelItinerary.setColumnIdentifiers(new Object[]{"Line", "Stop", "Time"}); - this.StopList = s; - setContentPane(MainPanel); + setContentPane(mainPanel); setTitle("app"); setExtendedState(JFrame.MAXIMIZED_BOTH); //setUndecorated(true); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - Home.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - CardPanel.removeAll(); - CardPanel.add(HomePanel); - CardPanel.repaint(); - CardPanel.revalidate(); - } + home.addActionListener(e -> { + CardPanel.removeAll(); + CardPanel.add(HomePanel); + CardPanel.repaint(); + CardPanel.revalidate(); }); - Network.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - LoadSearchResult(s, modelStops); - CardPanel.removeAll(); - CardPanel.add(NetworkPanel); + network.addActionListener(e -> { + LoadSearchResult(s, modelStops); + CardPanel.removeAll(); + CardPanel.add(NetworkPanel); - CardPanel.repaint(); - CardPanel.revalidate(); - } + CardPanel.repaint(); + CardPanel.revalidate(); }); - Itinerary.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - LoadSearchResult(s, modelItinerary); - CardPanel.removeAll(); - CardPanel.add(ItineraryPanel); + itinerary.addActionListener(e -> { + LoadSearchResult(s, modelItinerary); + CardPanel.removeAll(); + CardPanel.add(ItineraryPanel); - CardPanel.repaint(); - CardPanel.revalidate(); - } + CardPanel.repaint(); + CardPanel.revalidate(); }); TextLocation.addKeyListener(new KeyAdapter() { @@ -208,32 +178,26 @@ public class View extends JFrame { } }); - ButtonLocation.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - CardPanel.removeAll(); - searchLocation = TextLocation.getText(); - LoadSearchResult(s, modelStops); - System.out.println("search location clicked with text " + searchLocation); - CardPanel.add(NetworkPanel); + buttonLocation.addActionListener(e -> { + CardPanel.removeAll(); + searchLocation = TextLocation.getText(); + LoadSearchResult(s, modelStops); + System.out.println("search location clicked with text " + searchLocation); + CardPanel.add(NetworkPanel); - CardPanel.repaint(); - CardPanel.revalidate(); - } + CardPanel.repaint(); + CardPanel.revalidate(); }); - ButtonCoord.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - CardPanel.removeAll(); - searchCoord = TextCoord.getText(); - LoadSearchResult(s, modelStops); - System.out.println("search coord clicked with text " + searchCoord); - CardPanel.add(NetworkPanel); + buttonCoord.addActionListener(e -> { + CardPanel.removeAll(); + searchCoord = TextCoord.getText(); + LoadSearchResult(s, modelStops); + System.out.println("search coord clicked with text " + searchCoord); + CardPanel.add(NetworkPanel); - CardPanel.repaint(); - CardPanel.revalidate(); - } + CardPanel.repaint(); + CardPanel.revalidate(); }); tableStops.addMouseListener(new MouseAdapter() { @Override @@ -259,7 +223,6 @@ public class View extends JFrame { s.add(new Stop("M14", "Gare de Lyon", 2.4658452681, 3.0265513)); View v = new View(s); - } private void showOptionsDialog(JTable table, int x, int y) { @@ -296,7 +259,7 @@ public class View extends JFrame { model.setColumnCount(cols); // Add new rows based on the search results - count = 0; + int count = 0; for (Stop stop : stops) { // Add a row to the table with Stop's line in the first column and Stop's name in the second column 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 7efa0fa..6f560b0 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 @@ -16,7 +16,7 @@ public class CSVSchedulesProvider { private static final DateTimeFormatter HOUR_MINUTE_FORMATTER = ScheduleFormat.getTimeFormatter(); - private static final HashMap timings = new HashMap() {{ + private static final HashMap timings = new HashMap<>() {{ put("Bus", new int[]{11, 8, 7}); put("Funicular", new int[]{15, 25, 20}); put("Tram", new int[]{6, 7, 8, 9}); @@ -36,7 +36,7 @@ public class CSVSchedulesProvider { private final Iterator currentTransport; private Iterator currentDescription = Collections.emptyIterator(); - private String current_tansport_type = ""; + private String current_transport_type = ""; private LocalDateTime currentHour = null; private LocalDateTime lastHour = null; @@ -49,7 +49,7 @@ public class CSVSchedulesProvider { } /** - * @param transportType the type of a transport + * @param transportType the type of transport * @return a random minute depending on the type of the transport */ public static int pickMinute(String transportType) { @@ -84,17 +84,15 @@ public class CSVSchedulesProvider { } else if (currentHour.isBefore(lastHour)) { // System.out.println("**Skip: Le current hour est plus petit "+currentHour+"|||"+lastHour); addRandomMinutes(); - } else if (!currentHour.isBefore(lastHour)) { + } else { // System.out.println("**Skip: Le current hour est plus grand "+currentHour+"|||"+lastHour); skipToNextDescription(); - } else if (!this.currentDescription.hasNext()) { - skipToNextTransport(); } } /** - * Move to the the nextDescription of a Transport line + * Move to the nextDescription of a Transport line */ private void skipToNextDescription() { if (this.currentDescription.hasNext()) { @@ -123,7 +121,7 @@ public class CSVSchedulesProvider { Transport transport = this.currentTransport.next(); this.line[ScheduleFormat.LINE_INDEX] = transport.name; - current_tansport_type = transport.type; + current_transport_type = transport.type; this.currentDescription = transport.descriptions.iterator(); skipToNextDescription(); } @@ -141,12 +139,12 @@ public class CSVSchedulesProvider { } /** - * Add random minutes for the next passage of a transport. The random minutes depends on the type - * of the transport + * Add random minutes for the next passage of transport. The random minutes depends on the type of + * the transport */ private void addRandomMinutes() { // System.out.println("** addM: AVANT: "+currentHour); - currentHour = currentHour.plusMinutes(pickMinute(current_tansport_type)); + currentHour = currentHour.plusMinutes(pickMinute(current_transport_type)); this.line[ScheduleFormat.TIME_INDEX] = currentHour.format(HOUR_MINUTE_FORMATTER); // System.out.println("** addM: APRES: "+currentHour); // debut ++; 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 ddd7a88..b983402 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 @@ -92,7 +92,7 @@ public final class CSVStreamProvider { */ private Iterator> currentPath = Collections.emptyIterator(); /** - * current iterator for the begin of the line + * current iterator for the beginning of the line */ private Iterator currentSegmentStart = Collections.emptyIterator(); /** @@ -162,7 +162,7 @@ public final class CSVStreamProvider { /** * A tool method to give a delay to go through a certain distance. *

- * This is a model with an linear acceleration and deceleration periods and a constant speed in + * This is a model with a linear acceleration and deceleration periods and a constant speed in * between. * * @param distance the distance (in km) @@ -268,7 +268,7 @@ public final class CSVStreamProvider { // } /** - * Store current trace' data as a String array + * Store current trace's data as a String array * * @return The newly generated line of text */ @@ -302,7 +302,7 @@ public final class CSVStreamProvider { String end_p = this.line[NetworkFormat.STOP_INDEX]; // String bifurcation = this.line[NetworkFormat.VARIANT_INDEX]; - Transport transp = null; + Transport transp; if (!transports.containsKey(traceId)) { transp = new Transport(nameTransport, traceType, url_image); transports.put(traceId, transp); diff --git a/src/main/java/fr/u_paris/gla/project/idfm/IDFMNetworkExtractor.java b/src/main/java/fr/u_paris/gla/project/idfm/IDFMNetworkExtractor.java index 9e47f91..0fb6752 100644 --- a/src/main/java/fr/u_paris/gla/project/idfm/IDFMNetworkExtractor.java +++ b/src/main/java/fr/u_paris/gla/project/idfm/IDFMNetworkExtractor.java @@ -154,7 +154,7 @@ public class IDFMNetworkExtractor { long startTime = System.currentTimeMillis(); for (Transport entry : transports.values()) { - entry.buildBifurcationOptimzed(); + entry.buildBifurcationOptimized(); } long endTime = System.currentTimeMillis(); diff --git a/src/main/java/fr/u_paris/gla/project/idfm/Stop.java b/src/main/java/fr/u_paris/gla/project/idfm/Stop.java index 46f1468..0e0d103 100644 --- a/src/main/java/fr/u_paris/gla/project/idfm/Stop.java +++ b/src/main/java/fr/u_paris/gla/project/idfm/Stop.java @@ -19,7 +19,7 @@ public class Stop { /** * Checks is stopName is connected to this one * - * @param stopName + * @param stopName stop name * @return True if stopName is connected to the current stop */ public boolean isStopConnected(String stopName) { @@ -38,7 +38,7 @@ public class Stop { /** * Return the connected stop with the name : stopName * - * @param stopName + * @param stopName stop name * @return the connected stop with the name : stopName */ public BifStop getConnectedStop(String stopName) { diff --git a/src/main/java/fr/u_paris/gla/project/idfm/StopEntry.java b/src/main/java/fr/u_paris/gla/project/idfm/StopEntry.java index c0dd2ab..8695c3d 100644 --- a/src/main/java/fr/u_paris/gla/project/idfm/StopEntry.java +++ b/src/main/java/fr/u_paris/gla/project/idfm/StopEntry.java @@ -6,20 +6,24 @@ package fr.u_paris.gla.project.idfm; import java.text.MessageFormat; import java.util.Objects; -/** A transport stop data. +/** + * A transport stop data. * - * @author Emmanuel Bigeon */ + * @author Emmanuel Bigeon + */ public class StopEntry implements Comparable { public final String lname; public final double longitude; public final double latitude; - /** Create the stop + /** + * Create the stop * - * @param lname - * @param longitude - * @param latitude */ + * @param lname line name + * @param longitude longitude + * @param latitude latitude + */ public StopEntry(String lname, double longitude, double latitude) { super(); this.lname = lname; @@ -57,15 +61,15 @@ public class StopEntry implements Comparable { @Override public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } StopEntry other = (StopEntry) obj; return Double.doubleToLongBits(latitude) == Double .doubleToLongBits(other.latitude) && Objects.equals(lname, other.lname) diff --git a/src/main/java/fr/u_paris/gla/project/idfm/TraceDescription.java b/src/main/java/fr/u_paris/gla/project/idfm/TraceDescription.java index 202f9cb..5974e25 100644 --- a/src/main/java/fr/u_paris/gla/project/idfm/TraceDescription.java +++ b/src/main/java/fr/u_paris/gla/project/idfm/TraceDescription.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; /** - * A representation of a transport description encompansing its first and last stop in all of its + * A representation of a transport description encompassing its first and last stop in all of its * direction, the first and last schedule and all the bifurcation that direction takes. The * description comes from the fourth column * of the stop csv file. */ diff --git a/src/main/java/fr/u_paris/gla/project/idfm/TraceEntry.java b/src/main/java/fr/u_paris/gla/project/idfm/TraceEntry.java index 8abc6eb..ec43bd7 100644 --- a/src/main/java/fr/u_paris/gla/project/idfm/TraceEntry.java +++ b/src/main/java/fr/u_paris/gla/project/idfm/TraceEntry.java @@ -67,9 +67,9 @@ public final class TraceEntry { /** * Add all the description to the current one * - * @param desctipt + * @param ldescription */ - public void addDescriptions(List desctipt) { - descriptions.addAll(desctipt); + public void addDescriptions(List ldescription) { + descriptions.addAll(ldescription); } } diff --git a/src/main/java/fr/u_paris/gla/project/idfm/Transport.java b/src/main/java/fr/u_paris/gla/project/idfm/Transport.java index 13d9e81..8ff66a3 100644 --- a/src/main/java/fr/u_paris/gla/project/idfm/Transport.java +++ b/src/main/java/fr/u_paris/gla/project/idfm/Transport.java @@ -41,7 +41,7 @@ public class Transport { Stop fin = stopsMap.get(d.to); if (debut != null && fin != null) { SimpleEntry> sol = roadToLast(debut.name, fin.name, - new ArrayList(), new ArrayList()); + new ArrayList<>(), new ArrayList<>()); if (sol.getKey()) { // found++; d.bifurcation = sol.getValue(); @@ -55,7 +55,7 @@ public class Transport { /** * Build the bifurcation for all the descriptions but optimized */ - public void buildBifurcationOptimzed() { + public void buildBifurcationOptimized() { // int found = 0; for (TraceDescription d : descriptions) { Stop debut = stopsMap.get(d.from); @@ -63,7 +63,7 @@ public class Transport { if (debut != null && fin != null) { Set alreadyVisited = new HashSet<>(); SimpleEntry> sol = roadToLastOptimized(debut.name, fin.name, - alreadyVisited, new ArrayList()); + alreadyVisited, new ArrayList<>()); if (sol.getKey()) { // found++; d.bifurcation = sol.getValue(); @@ -82,9 +82,9 @@ public class Transport { */ public boolean isTerminus(String stop) { for (TraceDescription t : descriptions) { - if (stop.equals(t.first) || stop.equals(t.last)) { - return true; - } + if (stop.equals(t.first) || stop.equals(t.last)) { + return true; + } } return false; } @@ -95,8 +95,8 @@ public class Transport { * * @param currentStop the current stop we are visiting * @param last The last stop we are trying to go to - * @param alreadyVisited All the stop we already have visisted - * @param bif All the bifurcation encountered from the first stop to the current one + * @param alreadyVisited All the stop we already have visited + * @param bifurcation All the bifurcation encountered from the first stop to the current one * @return True and the bifurcation if we found our road to the last stop and false if we didn't */ public SimpleEntry> roadToLast(String currentStop, String last, @@ -118,9 +118,9 @@ public class Transport { for (BifStop b : current.connected.values()) { if (!visitedCopy.contains(b.stop.name)) { List bifCopy = new ArrayList<>(bifurcation); - if (b.bifurc != 0) { - bifCopy.add(b.bifurc); - } + if (b.bifurc != 0) { + bifCopy.add(b.bifurc); + } solutions.add(roadToLast(b.stop.name, last, visitedCopy, bifCopy)); } } @@ -142,8 +142,8 @@ public class Transport { * * @param currentStop the current stop we are visiting * @param last The last stop we are trying to go to - * @param alreadyVisited All the stop we already have visisted - * @param bif All the bifurcation encountered from the first stop to the current one + * @param alreadyVisited All the stop we already have visited + * @param bifurcation All the bifurcation encountered from the first stop to the current one * @return True and the bifurcation if we found our road to the last stop and false if we didn't */ public SimpleEntry> roadToLastOptimized(String currentStop, String last, @@ -204,7 +204,7 @@ public class Transport { } /** - * Print every stops of the line and its connections + * Print every stop of the line and its connections */ public void printAllConnectionStops() { System.out.println("Affichage des couples (stop, next du stop):"); @@ -222,11 +222,10 @@ public class Transport { /** * Add all the description to the current one * - * @param desctipt + * @param ldescription */ - public void addDescriptions(List desctipt) { - descriptions.addAll(desctipt); + public void addDescriptions(List ldescription) { + descriptions.addAll(ldescription); } - } diff --git a/src/main/java/fr/u_paris/gla/project/idfm/UnidentifiedStopEntry.java b/src/main/java/fr/u_paris/gla/project/idfm/UnidentifiedStopEntry.java index c23d441..b60d71d 100644 --- a/src/main/java/fr/u_paris/gla/project/idfm/UnidentifiedStopEntry.java +++ b/src/main/java/fr/u_paris/gla/project/idfm/UnidentifiedStopEntry.java @@ -23,8 +23,8 @@ public final class UnidentifiedStopEntry extends StopEntry { /** * Create the stop * - * @param longitude - * @param latitude + * @param longitude longitude + * @param latitude latitude */ public UnidentifiedStopEntry(double longitude, double latitude) { super("Unidentified", longitude, latitude); //$NON-NLS-1$ diff --git a/src/main/java/fr/u_paris/gla/project/itinerary/Connection.java b/src/main/java/fr/u_paris/gla/project/itinerary/Connection.java index 0b015c9..880cf68 100644 --- a/src/main/java/fr/u_paris/gla/project/itinerary/Connection.java +++ b/src/main/java/fr/u_paris/gla/project/itinerary/Connection.java @@ -72,7 +72,7 @@ public class Connection { } public double getNextTime(double currentTime) { - if (this.schedules.size() == 0) { + if (this.schedules.isEmpty()) { return currentTime; } @@ -87,7 +87,7 @@ public class Connection { } public double getCost(double currentTime) { - if (this.schedules.size() == 0) { + if (this.schedules.isEmpty()) { if (this.lineName.equals("WALK")) { return this.time; } diff --git a/src/main/java/fr/u_paris/gla/project/itinerary/Finder.java b/src/main/java/fr/u_paris/gla/project/itinerary/Finder.java index 332b198..69c476c 100644 --- a/src/main/java/fr/u_paris/gla/project/itinerary/Finder.java +++ b/src/main/java/fr/u_paris/gla/project/itinerary/Finder.java @@ -19,8 +19,8 @@ public class Finder { /** * return a path from startNode to goalNode using A* algorithm * - * @param startNode - * @param goalNode + * @param startNode start of algorithm + * @param goalNode end of algorithm */ public List findPath(Stop startNode, Stop goalNode, double startTime) { @@ -31,7 +31,7 @@ public class Finder { HashMap fScore = new HashMap<>(); // Initialize scores for all nodes to infinity - for (Stop node : graph.getNodes()) { + for (Stop node : graph.nodes()) { gScore.put(node, Double.POSITIVE_INFINITY); fScore.put(node, Double.POSITIVE_INFINITY); } @@ -89,8 +89,8 @@ public class Finder { /** * Once we found the destination we reconstruct the path * - * @param cameFrom - * @param current + * @param cameFrom departure + * @param current current stop * @return path */ private List reconstructPath(HashMap cameFrom, Stop current) { @@ -111,9 +111,9 @@ public class Finder { /** * Update the priority queue * - * @param openSet - * @param node - * @param newF + * @param openSet stop queue + * @param node stop + * @param newF new stop */ public void updatePriority(PriorityQueue openSet, Stop node, double newF) { openSet.remove(node); diff --git a/src/main/java/fr/u_paris/gla/project/itinerary/Graph.java b/src/main/java/fr/u_paris/gla/project/itinerary/Graph.java index 9d3301c..70d8c36 100644 --- a/src/main/java/fr/u_paris/gla/project/itinerary/Graph.java +++ b/src/main/java/fr/u_paris/gla/project/itinerary/Graph.java @@ -3,26 +3,9 @@ package fr.u_paris.gla.project.itinerary; import java.util.Map; import java.util.Set; -public class Graph { - - private final Set nodes; - - private final Map> connections; - - public Graph(Set nodes, Map> connections) { - this.nodes = nodes; - this.connections = connections; - } +public record Graph(Set nodes, Map> connections) { public Set getConnections(Stop node) { return connections.get(node); } - - public Set getNodes() { - return nodes; - } - - public Map> getConnections() { - return connections; - } } diff --git a/src/main/java/fr/u_paris/gla/project/itinerary/Parse.java b/src/main/java/fr/u_paris/gla/project/itinerary/Parse.java index e3792b4..7c4376a 100644 --- a/src/main/java/fr/u_paris/gla/project/itinerary/Parse.java +++ b/src/main/java/fr/u_paris/gla/project/itinerary/Parse.java @@ -118,7 +118,7 @@ public class Parse { * @param line the current line we want to parse * @param nodes the graph of stops * @param tmp list of the created stops - * @param connections + * @param connections set of connections */ private static void addLine(String[] line, HashSet nodes, HashMap> tmp, HashMap> connections) { @@ -162,14 +162,14 @@ public class Parse { } } - if (directions.size() == 0) { + if (directions.isEmpty()) { return; } Stop next_stop = null; if (directions.size() > 1) { - int bifurcation = bifurcations.size() == 0 ? 0 : bifurcations.get(0); - if (bifurcations.size() > 0) { + int bifurcation = bifurcations.isEmpty() ? 0 : bifurcations.get(0); + if (!bifurcations.isEmpty()) { bifurcations.remove(0); } for (Connection d : directions) { @@ -184,7 +184,7 @@ public class Parse { } else { next_stop = directions.get(0).getStop(); if (directions.get(0).getBifurcation() != 0) { - if (bifurcations.size() > 0 && directions.get(0).getBifurcation() == bifurcations.get(0)) { + if (!bifurcations.isEmpty() && directions.get(0).getBifurcation() == bifurcations.get(0)) { bifurcations.remove(0); } } diff --git a/src/main/java/fr/u_paris/gla/project/itinerary/Path.java b/src/main/java/fr/u_paris/gla/project/itinerary/Path.java index 7c21cfb..5c2841e 100644 --- a/src/main/java/fr/u_paris/gla/project/itinerary/Path.java +++ b/src/main/java/fr/u_paris/gla/project/itinerary/Path.java @@ -11,7 +11,6 @@ public class Path { private final double travelTime; private final String line; private final Connection connection; - private double distance; public Path(Stop current, Connection connection, double startTime) { this.current = current; 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 82611b6..eb90b2a 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 @@ -92,8 +92,8 @@ 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 + * @param filename the saved file's name and path + * @param contentLinesConsumer our data variable * @throws IOException if we can't write the data into the file */ public static void writeCSVToFile(String filename, diff --git a/src/test/java/fr/u_paris/gla/project/idfm/CSVStreamProviderTest.java b/src/test/java/fr/u_paris/gla/project/idfm/CSVStreamProviderTest.java index 94b237b..2b97cb7 100644 --- a/src/test/java/fr/u_paris/gla/project/idfm/CSVStreamProviderTest.java +++ b/src/test/java/fr/u_paris/gla/project/idfm/CSVStreamProviderTest.java @@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test; public class CSVStreamProviderTest { - //Test de hasNext, pour le cas ou il y'a un trace et cas ou il n'y en a pas + //Test de hasNext, pour le cas où il y a un "trace" et cas ou il n'y en a pas @Test public void testHasNext() { // Scénario sans Trace diff --git a/src/test/java/fr/u_paris/gla/project/idfm/IDFMNetworkExtractorTest.java b/src/test/java/fr/u_paris/gla/project/idfm/IDFMNetworkExtractorTest.java index 7bdc38d..b2f904c 100644 --- a/src/test/java/fr/u_paris/gla/project/idfm/IDFMNetworkExtractorTest.java +++ b/src/test/java/fr/u_paris/gla/project/idfm/IDFMNetworkExtractorTest.java @@ -63,7 +63,7 @@ class IDFMNetworkExtractorTest { method.invoke(null, trace, candidate); - //L'appel c'est derouler correctement + // L'appel s'est déroulé correctement assertTrue(true, "L'appel de addCandidate s'est déroulé sans erreur."); } } \ No newline at end of file diff --git a/src/test/java/fr/u_paris/gla/project/idfm/TraceEntryTest.java b/src/test/java/fr/u_paris/gla/project/idfm/TraceEntryTest.java index 98dab98..dd9f2d8 100644 --- a/src/test/java/fr/u_paris/gla/project/idfm/TraceEntryTest.java +++ b/src/test/java/fr/u_paris/gla/project/idfm/TraceEntryTest.java @@ -16,7 +16,7 @@ public class TraceEntryTest { String terminus1 = "Terminus A"; String terminus2 = "Terminus B"; - //Ajouter des arrêt sur la ligne + //Ajouter des arrêts sur la ligne traceEntry.addTerminus(terminus1); traceEntry.addTerminus(terminus2); List terminusList = traceEntry.getTerminus(); @@ -45,7 +45,7 @@ public class TraceEntryTest { } - //Verfier si le nom de la ligne lname est correctement initialiser + // Verifier si le nom de la ligne lname est correctement initialisé @Test public void testTraceEntryName() { TraceEntry traceEntry = new TraceEntry("Ligne 1", "IDFM:03434", "Bus", "dummy_url"); diff --git a/src/test/java/fr/u_paris/gla/project/utils/CSVToolsTest.java b/src/test/java/fr/u_paris/gla/project/utils/CSVToolsTest.java index 943b6aa..866f3e8 100644 --- a/src/test/java/fr/u_paris/gla/project/utils/CSVToolsTest.java +++ b/src/test/java/fr/u_paris/gla/project/utils/CSVToolsTest.java @@ -77,4 +77,4 @@ class CSVToolsTest { CSVTools.writeCSVToFile(".", test); }); } -} \ No newline at end of file +}