From 9c04f4f95c472485f3713a0e8a7615eec35eaec5 Mon Sep 17 00:00:00 2001 From: MAMBILA TETE jean philipp <@mambilat> Date: Mon, 29 Apr 2024 18:11:37 +0200 Subject: [PATCH] [feat] itinerary support in API calls maybe --- .../java/fr/u_paris/gla/project/gui/View.java | 58 ++++++++++++++----- 1 file changed, 44 insertions(+), 14 deletions(-) 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 3db7c01..bd7ec1c 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 @@ -1,5 +1,6 @@ package fr.u_paris.gla.project.gui; +import fr.u_paris.gla.project.itinerary.Path; import fr.u_paris.gla.project.itinerary.Stop; import javax.swing.*; @@ -56,6 +57,8 @@ public class View extends JFrame { private ArrayList searchRes; + private ArrayList searchResPath; + private int count = 0; @@ -177,7 +180,7 @@ public class View extends JFrame { Itinerary.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - LoadSearchResult(s, modelItinerary); + LoadSearchResultItinerary(searchResPath, modelItinerary); CardPanel.removeAll(); CardPanel.add(ItineraryPanel); @@ -321,29 +324,56 @@ public class View extends JFrame { tableStops.revalidate(); tableStops.repaint(); - - tableItinerary.revalidate(); - tableItinerary.repaint(); - paneStops.setViewportView(tableStops); paneStops.revalidate(); paneStops.repaint(); - - - paneItinerary.setViewportView(tableItinerary); - paneItinerary.revalidate(); - paneItinerary.repaint(); - - NetworkPanel.revalidate(); NetworkPanel.repaint(); + + } + + public void LoadSearchResultItinerary(ArrayList paths, DefaultTableModel model){ + // Clear existing rows from the table + int cols = model.getColumnCount(); + model.setRowCount(0); + model.setColumnCount(cols); + + + // Add new rows based on the search results + count = 0; + Path last = null; + for (Path path : paths) { + // Add a row to the table with Stop's line in the first column and Stop's name in the second column + model.addRow(new Object[]{path.getLine(), path.getCurrentStop(), path.getStartTime()}); + + ++count; + last = path; + } + if (last != null) model.addRow(new Object[]{last.getLine(), last.getNextStop()}); + + System.out.println(paths); + for (int i = 0; i < model.getRowCount(); i++) { + for (int j = 0; j < model.getColumnCount(); j++) { + System.out.print("valeur at coord " + i +";" + j +": " + model.getValueAt(i, j) + "\t"); + } + System.out.println(); + } + + System.out.println(count); + + + tableItinerary.revalidate(); + tableItinerary.repaint(); + paneItinerary.setViewportView(tableItinerary); + paneItinerary.revalidate(); + paneItinerary.repaint(); ItineraryPanel.revalidate(); ItineraryPanel.repaint(); - - this.displayTableValues(model); + + } public void displayTableValues(TableModel mod) {