[fix] Fix crash with empty string, remove some prints
This commit is contained in:
parent
f764a80882
commit
0c20cd6840
1 changed files with 14 additions and 65 deletions
|
@ -290,6 +290,7 @@ public class View extends JFrame {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
SeeStopButton.addActionListener(f -> {
|
SeeStopButton.addActionListener(f -> {
|
||||||
Connection c;
|
Connection c;
|
||||||
if ((c = (Connection) StopsLinesComboBox.getSelectedItem()) != null) {
|
if ((c = (Connection) StopsLinesComboBox.getSelectedItem()) != null) {
|
||||||
|
@ -316,35 +317,28 @@ public class View extends JFrame {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ButtonLocation.addActionListener(new ActionListener() {
|
ButtonLocation.addActionListener(e -> {
|
||||||
@Override
|
String cur = TextLocation.getText();
|
||||||
public void actionPerformed(ActionEvent e) {
|
if (!cur.isEmpty()) {
|
||||||
CardPanel.removeAll();
|
CardPanel.removeAll();
|
||||||
String cur = TextLocation.getText();
|
|
||||||
LoadStringStops(cur);
|
LoadStringStops(cur);
|
||||||
LoadSearchResultItinerary(searchResPath, modelItinerary);
|
LoadSearchResultItinerary(searchResPath, modelItinerary);
|
||||||
System.out.println("search location clicked with text " + cur);
|
|
||||||
CardPanel.add(ItineraryPanel);
|
CardPanel.add(ItineraryPanel);
|
||||||
|
|
||||||
CardPanel.repaint();
|
|
||||||
CardPanel.revalidate();
|
|
||||||
}
|
}
|
||||||
|
CardPanel.repaint();
|
||||||
|
CardPanel.revalidate();
|
||||||
});
|
});
|
||||||
|
|
||||||
ButtonCoord.addActionListener(new ActionListener() {
|
ButtonCoord.addActionListener(e -> {
|
||||||
@Override
|
String cur = TextCoord.getText();
|
||||||
public void actionPerformed(ActionEvent e) {
|
if (!cur.isEmpty()) {
|
||||||
CardPanel.removeAll();
|
CardPanel.removeAll();
|
||||||
String cur = TextCoord.getText();
|
|
||||||
System.out.println(cur);
|
|
||||||
LoadStringCoords(cur);
|
LoadStringCoords(cur);
|
||||||
LoadSearchResultItinerary(searchResPath, modelItinerary);
|
LoadSearchResultItinerary(searchResPath, modelItinerary);
|
||||||
System.out.println("search coord clicked with text " + cur);
|
|
||||||
CardPanel.add(ItineraryPanel);
|
CardPanel.add(ItineraryPanel);
|
||||||
|
|
||||||
CardPanel.repaint();
|
|
||||||
CardPanel.revalidate();
|
|
||||||
}
|
}
|
||||||
|
CardPanel.repaint();
|
||||||
|
CardPanel.revalidate();
|
||||||
});
|
});
|
||||||
|
|
||||||
tableStops.addMouseListener(new MouseAdapter() {
|
tableStops.addMouseListener(new MouseAdapter() {
|
||||||
|
@ -422,16 +416,13 @@ public class View extends JFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadStringCoords(String stops){
|
public void LoadStringCoords(String stops){
|
||||||
System.out.println(stops);
|
|
||||||
stops = stops.replaceAll("[()]", "").replaceAll(";", ",");
|
stops = stops.replaceAll("[()]", "").replaceAll(";", ",");
|
||||||
String[] stops_array = stops.split(",");
|
String[] stops_array = stops.split(",");
|
||||||
double[] coords = new double[4];
|
double[] coords = new double[4];
|
||||||
System.out.println(Arrays.toString(stops_array));
|
|
||||||
for (int i = 0; i < 4; i++){
|
for (int i = 0; i < 4; i++){
|
||||||
coords[i] = Double.parseDouble(stops_array[i]);
|
coords[i] = Double.parseDouble(stops_array[i]);
|
||||||
}
|
}
|
||||||
searchResPath = (ArrayList<Path>) finder.findPath(coords[0], coords[1], coords[2], coords[3], LocalDateTime.now().toLocalTime().toSecondOfDay());
|
searchResPath = (ArrayList<Path>) finder.findPath(coords[0], coords[1], coords[2], coords[3], LocalDateTime.now().toLocalTime().toSecondOfDay());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadStringStops(String stops){
|
public void LoadStringStops(String stops){
|
||||||
|
@ -443,7 +434,7 @@ public class View extends JFrame {
|
||||||
for (int i = 0; i < 2;i++){
|
for (int i = 0; i < 2;i++){
|
||||||
coords[j] = cur[i];
|
coords[j] = cur[i];
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
searchResPath = (ArrayList<Path>) finder.findPath(coords[0], coords[1], coords[2], coords[3], LocalDateTime.now().toLocalTime().toSecondOfDay());
|
searchResPath = (ArrayList<Path>) finder.findPath(coords[0], coords[1], coords[2], coords[3], LocalDateTime.now().toLocalTime().toSecondOfDay());
|
||||||
}
|
}
|
||||||
|
@ -460,21 +451,10 @@ public class View extends JFrame {
|
||||||
count = 0;
|
count = 0;
|
||||||
for (Stop stop : stops) {
|
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
|
// 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[]{String.join(",", stop.getLines()), stop.getName()});
|
model.addRow(new Object[]{String.join(",", stop.getLines()), stop.getName()});
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(stops.toString());
|
|
||||||
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);
|
|
||||||
|
|
||||||
tableStops.revalidate();
|
tableStops.revalidate();
|
||||||
tableStops.repaint();
|
tableStops.repaint();
|
||||||
paneStops.setViewportView(tableStops);
|
paneStops.setViewportView(tableStops);
|
||||||
|
@ -490,7 +470,6 @@ public class View extends JFrame {
|
||||||
model.setRowCount(0);
|
model.setRowCount(0);
|
||||||
model.setColumnCount(cols);
|
model.setColumnCount(cols);
|
||||||
|
|
||||||
|
|
||||||
// Add new rows based on the search results
|
// Add new rows based on the search results
|
||||||
count = 0;
|
count = 0;
|
||||||
Path last = null;
|
Path last = null;
|
||||||
|
@ -501,24 +480,14 @@ public class View extends JFrame {
|
||||||
int hours = (int) (time / 3600);
|
int hours = (int) (time / 3600);
|
||||||
int minutes = (int) ((time % 3600) / 60);
|
int minutes = (int) ((time % 3600) / 60);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
model.addRow(new Object[]{path.getLine(), path.getCurrentStop(), String.format("%02d:%02d", hours, minutes)});
|
model.addRow(new Object[]{path.getLine(), path.getCurrentStop(), String.format("%02d:%02d", hours, minutes)});
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
last = path;
|
last = path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (last != null) model.addRow(new Object[]{last.getLine(), last.getNextStop()});
|
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.revalidate();
|
||||||
tableItinerary.repaint();
|
tableItinerary.repaint();
|
||||||
|
@ -527,17 +496,6 @@ public class View extends JFrame {
|
||||||
paneItinerary.repaint();
|
paneItinerary.repaint();
|
||||||
ItineraryPanel.revalidate();
|
ItineraryPanel.revalidate();
|
||||||
ItineraryPanel.repaint();
|
ItineraryPanel.repaint();
|
||||||
this.displayTableValues(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openWebpage(URI uri) {
|
private void openWebpage(URI uri) {
|
||||||
|
@ -558,13 +516,4 @@ public class View extends JFrame {
|
||||||
LOGGER.severe("Default desktop browser not set");
|
LOGGER.severe("Default desktop browser not set");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public static void main(String[] args) {
|
|
||||||
ArrayList<Stop> s = new ArrayList<>();
|
|
||||||
s.add(new Stop("M8", "Balard", 1.0315897, 3.0265513));
|
|
||||||
s.add(new Stop("M14", "Gare de Lyon", 2.4658452681, 3.0265513));
|
|
||||||
SwingUtilities.invokeLater(() -> new View(graph, finder, s));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue