[feat] itinerary support in API calls maybe
This commit is contained in:
parent
db471f41d1
commit
9c04f4f95c
1 changed files with 44 additions and 14 deletions
|
@ -1,5 +1,6 @@
|
||||||
package fr.u_paris.gla.project.gui;
|
package fr.u_paris.gla.project.gui;
|
||||||
|
|
||||||
|
import fr.u_paris.gla.project.itinerary.Path;
|
||||||
import fr.u_paris.gla.project.itinerary.Stop;
|
import fr.u_paris.gla.project.itinerary.Stop;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -56,6 +57,8 @@ public class View extends JFrame {
|
||||||
|
|
||||||
private ArrayList<Stop> searchRes;
|
private ArrayList<Stop> searchRes;
|
||||||
|
|
||||||
|
private ArrayList<Path> searchResPath;
|
||||||
|
|
||||||
private int count = 0;
|
private int count = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,7 +180,7 @@ public class View extends JFrame {
|
||||||
Itinerary.addActionListener(new ActionListener() {
|
Itinerary.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
LoadSearchResult(s, modelItinerary);
|
LoadSearchResultItinerary(searchResPath, modelItinerary);
|
||||||
CardPanel.removeAll();
|
CardPanel.removeAll();
|
||||||
CardPanel.add(ItineraryPanel);
|
CardPanel.add(ItineraryPanel);
|
||||||
|
|
||||||
|
@ -321,29 +324,56 @@ public class View extends JFrame {
|
||||||
|
|
||||||
tableStops.revalidate();
|
tableStops.revalidate();
|
||||||
tableStops.repaint();
|
tableStops.repaint();
|
||||||
|
|
||||||
tableItinerary.revalidate();
|
|
||||||
tableItinerary.repaint();
|
|
||||||
|
|
||||||
paneStops.setViewportView(tableStops);
|
paneStops.setViewportView(tableStops);
|
||||||
paneStops.revalidate();
|
paneStops.revalidate();
|
||||||
paneStops.repaint();
|
paneStops.repaint();
|
||||||
|
|
||||||
|
|
||||||
paneItinerary.setViewportView(tableItinerary);
|
|
||||||
paneItinerary.revalidate();
|
|
||||||
paneItinerary.repaint();
|
|
||||||
|
|
||||||
|
|
||||||
NetworkPanel.revalidate();
|
NetworkPanel.revalidate();
|
||||||
NetworkPanel.repaint();
|
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.revalidate();
|
||||||
ItineraryPanel.repaint();
|
ItineraryPanel.repaint();
|
||||||
|
|
||||||
|
|
||||||
this.displayTableValues(model);
|
this.displayTableValues(model);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayTableValues(TableModel mod) {
|
public void displayTableValues(TableModel mod) {
|
||||||
|
|
Reference in a new issue