Merge branch 'gui-displayres-javadoc' into 'dev'

[docs] javadoc gui

See merge request gla-groupe-3/projet!22
This commit is contained in:
RODRIGUEZ lucas 2024-05-05 14:36:45 +02:00
commit a6ff2a8864

View file

@ -358,6 +358,9 @@ public class View extends JFrame {
});
}
/**
* @param schedules
*/
private void createHourWindow(ArrayList<Integer> schedules) {
JFrame frame = new JFrame("Schedule");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
@ -390,6 +393,11 @@ public class View extends JFrame {
frame.setResizable(false);
}
/** Used to select a departure/arrival stop in the "Network" section, UNUSED
* @param table the table that displays the stops
* @param x x coordinate of mouse click
* @param y y coordinate of mouse click
*/
private void showOptionsDialog(JTable table, int x, int y) {
int selectedRow = table.rowAtPoint(new Point(x, y));
if (selectedRow != -1) { // If a row is selected
@ -415,6 +423,9 @@ public class View extends JFrame {
}
}
/** Load all stops related to coordinates
* @param stops a String in format (x1,y1);(x2,y2)
*/
public void LoadStringCoords(String stops){
stops = stops.replaceAll("[()]", "").replaceAll(";", ",");
String[] stops_array = stops.split(",");
@ -425,6 +436,9 @@ public class View extends JFrame {
searchResPath = (ArrayList<Path>) finder.findPath(coords[0], coords[1], coords[2], coords[3], LocalDateTime.now().toLocalTime().toSecondOfDay());
}
/** Load all stops related to locations
* @param stops a String in format name1;name2
*/
public void LoadStringStops(String stops){
String[] stops_array = stops.split(";");
double[] coords = new double[4];
@ -440,7 +454,10 @@ public class View extends JFrame {
}
/** Load a list of stops to display (used for selecting a departure and arrival stop, W.I.P)
* @param stops the stops list
* @param model the JTable model that will store them
*/
public void LoadSearchResult(ArrayList<Stop> stops, DefaultTableModel model) {
// Clear existing rows from the table
int cols = model.getColumnCount();
@ -464,6 +481,11 @@ public class View extends JFrame {
NetworkPanel.repaint();
}
/**
* Function that takes a list of paths and displays it in a JTabke
* @param paths the list of paths (from one stop to another)
* @param model the TableModel that stores the Table's data
*/
public void LoadSearchResultItinerary(ArrayList<Path> paths, DefaultTableModel model){
// Clear existing rows from the table
int cols = model.getColumnCount();
@ -498,6 +520,22 @@ public class View extends JFrame {
ItineraryPanel.repaint();
}
/** Takes a table's data as argument and displays it
* @param mod the table's data
*/
public void displayTableValues(TableModel mod) {
for (int row = 0; row < mod.getRowCount(); row++) {
for (int column = 0; column < mod.getColumnCount(); column++) {
if (mod.getValueAt(row, column) != null) System.out.print(mod.getValueAt(row, column).toString() + " ");
}
System.out.print(";");
}
System.out.println();
}
/** open a URL in browser
* @param uri
*/
private void openWebpage(URI uri) {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
@ -509,6 +547,9 @@ public class View extends JFrame {
}
}
/** open a URL (taken from a String) in browser
* @param url the url String
*/
private void openWebpage(String url) {
try {
openWebpage(new URL(url).toURI());