[feat] itinerary support in API calls maybe

This commit is contained in:
MAMBILA TETE jean philipp 2024-04-29 18:11:37 +02:00
parent db471f41d1
commit 9c04f4f95c

View file

@ -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<Stop> searchRes;
private ArrayList<Path> 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<Path> 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) {