Add the detail of the line number in the Gui

This commit is contained in:
Lucas 2024-05-01 15:45:01 +02:00
parent c42855e8e2
commit e154358d30
12 changed files with 63 additions and 3971 deletions

1948
image.csv

File diff suppressed because it is too large Load diff

View file

@ -66,7 +66,8 @@ public class App {
showLogo();
}
}
}else{
}
else{
testRelease();
}
}

View file

@ -51,9 +51,9 @@ public class View extends JFrame {
private JMenuItem Lines;
private JPanel LinesPanel;
private JLabel lineLabel;
private JComboBox linesComboBox;
private JButton showLineButton;
private JLabel LineLabel;
private JComboBox LinesComboBox;
private JButton ShowLineButton;
private JTextField TextCoord;
private JButton ButtonCoord;
@ -137,23 +137,23 @@ public class View extends JFrame {
paneItinerary.add(tableItinerary);
ItineraryPanel.add(paneItinerary);
linesComboBox = new JComboBox();
linesComboBox.setMaximumSize(new Dimension(100, linesComboBox.getPreferredSize().height));
linesComboBox.setPreferredSize(linesComboBox.getPreferredSize());
lineLabel = new JLabel("Show line");
lineLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
showLineButton = new JButton("Open");
showLineButton.setAlignmentX(Component.CENTER_ALIGNMENT);
LinesComboBox = new JComboBox();
LinesComboBox.setMaximumSize(new Dimension(100, LinesComboBox.getPreferredSize().height));
LinesComboBox.setPreferredSize(LinesComboBox.getPreferredSize());
LineLabel = new JLabel("Show line");
LineLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
ShowLineButton = new JButton("Open");
ShowLineButton.setAlignmentX(Component.CENTER_ALIGNMENT);
LinesPanel = new JPanel();
LinesPanel.setLayout(new BoxLayout(LinesPanel, BoxLayout.Y_AXIS));
LinesPanel.add(Box.createHorizontalGlue());
LinesPanel.add(Box.createHorizontalStrut(2));
LinesPanel.add(lineLabel);
LinesPanel.add(LineLabel);
LinesPanel.add(Box.createHorizontalStrut(10));
LinesPanel.add(linesComboBox);
LinesPanel.add(LinesComboBox);
LinesPanel.add(Box.createHorizontalStrut(10));
LinesPanel.add(showLineButton);
LinesPanel.add(ShowLineButton);
LinesPanel.add(Box.createHorizontalStrut(2));
LinesPanel.add(Box.createHorizontalGlue());
@ -188,41 +188,31 @@ public class View extends JFrame {
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Home.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
CardPanel.removeAll();
CardPanel.add(HomePanel);
CardPanel.repaint();
CardPanel.revalidate();
}
Home.addActionListener(e -> {
CardPanel.removeAll();
CardPanel.add(HomePanel);
CardPanel.repaint();
CardPanel.revalidate();
});
Network.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
LoadSearchResult(s, modelStops);
CardPanel.removeAll();
CardPanel.add(NetworkPanel);
Network.addActionListener(e -> {
LoadSearchResult(s, modelStops);
CardPanel.removeAll();
CardPanel.add(NetworkPanel);
CardPanel.repaint();
CardPanel.revalidate();
}
CardPanel.repaint();
CardPanel.revalidate();
});
Itinerary.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
LoadSearchResultItinerary(searchResPath, modelItinerary);
CardPanel.removeAll();
CardPanel.add(ItineraryPanel);
Itinerary.addActionListener(e -> {
LoadSearchResultItinerary(searchResPath, modelItinerary);
CardPanel.removeAll();
CardPanel.add(ItineraryPanel);
CardPanel.repaint();
CardPanel.revalidate();
}
CardPanel.repaint();
CardPanel.revalidate();
});
Lines.addActionListener(e -> {
CardPanel.removeAll();
CardPanel.add(LinesPanel);
@ -230,9 +220,9 @@ public class View extends JFrame {
CardPanel.revalidate();
});
CSVImageProvider.getLineImageMap().forEach(p -> linesComboBox.addItem(p));
showLineButton.addActionListener(f -> {
ImagePair item = (ImagePair) linesComboBox.getSelectedItem();
CSVImageProvider.getLineImageMap().forEach(p -> LinesComboBox.addItem(p));
ShowLineButton.addActionListener(f -> {
ImagePair item = (ImagePair) LinesComboBox.getSelectedItem();
openWebpage(item.getValue());
});
@ -281,6 +271,7 @@ public class View extends JFrame {
CardPanel.revalidate();
}
});
tableStops.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@ -291,8 +282,6 @@ public class View extends JFrame {
}
});
paneStops.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@ -326,15 +315,6 @@ public class View extends JFrame {
}
}
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));
View v = new View(s);
}
public void LoadSearchResult(ArrayList<Stop> stops, DefaultTableModel model) {
// Clear existing rows from the table
int cols = model.getColumnCount();
@ -435,4 +415,11 @@ public class View extends JFrame {
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(s));
}
}

View file

@ -22,6 +22,7 @@ public final class CSVImageProvider {
private static final NumberFormat MINUTES_SECOND_FORMATTER = NumberFormat
.getInstance(Locale.ENGLISH);
static {
MINUTES_SECOND_FORMATTER.setMinimumIntegerDigits(2);
}
@ -32,7 +33,7 @@ public final class CSVImageProvider {
private static ArrayList<ImagePair> lineImageMap;
public static final String FILE_NAME = "image.csv";
public static final String FILE_NAME = IDFMNetworkExtractor.IMAGES_FILE_NAME;
/** Create the stream provider */
@ -53,6 +54,7 @@ public final class CSVImageProvider {
Transport element = this.current.next();
this.line[ImageFormat.LINE_INDEX] = element.name;
this.line[ImageFormat.LINE_DETAIL_INDEX] = element.type;
this.line[ImageFormat.IMAGE_URL_INDEX] = element.image_url;
return Arrays.copyOf(this.line, this.line.length);
@ -62,12 +64,11 @@ public final class CSVImageProvider {
if (lineImageMap != null)
return lineImageMap;
lineImageMap = new ArrayList<>();
InputStream is = CSVImageProvider.class.getResourceAsStream(FILE_NAME);
System.out.println(is.toString());
try {
CSVTools.readCSVFromInputStream(is,
CSVTools.readCSVFromFile(FILE_NAME,
(String[] line) -> lineImageMap.add(new ImagePair(
line[ImageFormat.LINE_INDEX],
line[ImageFormat.LINE_DETAIL_INDEX],
line[ImageFormat.IMAGE_URL_INDEX]
)));
} catch(IOException e){

View file

@ -283,7 +283,7 @@ public final class CSVStreamProvider {
Transport transp = null;
if(!transports.containsKey(traceId)){
transp = new Transport(nameTransport,traceType, url_image);
transp = new Transport(nameTransport, traceType, url_image);
transports.put(traceId, transp);
}else{
transp = transports.get(traceId);

View file

@ -85,7 +85,7 @@ public class IDFMNetworkExtractor {
private static final String HOURS_FILE_NAME = "hours.csv";
private static final String IMAGES_FILE_NAME = "./images.csv";
public static final String IMAGES_FILE_NAME = "images.csv";
// Magically chosen values
/**
@ -112,7 +112,7 @@ public class IDFMNetworkExtractor {
public static void buildFiles() {
if (checkFileExistence("./"+HOURS_FILE_NAME) && checkFileExistence("./"+TRACE_FILE_NAME)) {
if (checkFileExistence("./"+HOURS_FILE_NAME) && checkFileExistence("./"+TRACE_FILE_NAME) && checkFileExistence(("./"+IMAGES_FILE_NAME))) {
LOGGER.severe("Files already exists.");
return;
}
@ -151,7 +151,7 @@ public class IDFMNetworkExtractor {
long startTime = System.currentTimeMillis();
for (Transport entry : transports.values()) {
entry.buildBifurcationOptimzed();
entry.buildBifurcationOptimized();
}
long endTime = System.currentTimeMillis();
@ -161,7 +161,7 @@ public class IDFMNetworkExtractor {
long seconds = (tempsPasse / 1000) % 60;
long milliseconds = tempsPasse % 1000;
System.out.println("Temps écoulé : " + minutes + " minutess, " + seconds + " secndes et " + milliseconds + " millis");
System.out.println("Temps écoulé : " + minutes + " minutes, " + seconds + " secndes et " + milliseconds + " millis");
System.out.println("******************Fin Building bifurcations ************************");

View file

@ -8,8 +8,8 @@ public class ImagePair {
private final String label;
private final String value;
public ImagePair(String label, String value){
this.label = label;
public ImagePair(String label, String label_detail, String value){
this.label = label + " - " + label_detail;
this.value = value;
}

View file

@ -55,7 +55,7 @@ public class Transport {
/**
* Build the bifurcation for all the descriptions but optimized
*/
public void buildBifurcationOptimzed() {
public void buildBifurcationOptimized() {
// int found = 0;
for (TraceDescription d : descriptions) {
Stop debut = stopsMap.get(d.from);
@ -92,7 +92,7 @@ public class Transport {
* @param currentStop the current stop we are visiting
* @param last The last stop we are trying to go to
* @param alreadyVisited All the stop we already have visisted
* @param bif All the bifurcation encountered from the first stop to the current
* @param bifurcation All the bifurcation encountered from the first stop to the current
* one
* @return True and the bifurcation if we found our road to the last stop and
* false if we didn't
@ -138,7 +138,7 @@ public class Transport {
* @param currentStop the current stop we are visiting
* @param last The last stop we are trying to go to
* @param alreadyVisited All the stop we already have visisted
* @param bif All the bifurcation encountered from the first stop to the current
* @param bifurcation All the bifurcation encountered from the first stop to the current
* one
* @return True and the bifurcation if we found our road to the last stop and
* false if we didn't

View file

@ -12,10 +12,11 @@ import java.util.List;
* A tool class for the Image format.
*/
public final class ImageFormat {
public static final int NUMBER_COLUMNS = 2;
public static final int NUMBER_COLUMNS = 3;
public static final int LINE_INDEX = 0;
public static final int IMAGE_URL_INDEX = 1;
public static final int LINE_DETAIL_INDEX = 1;
public static final int IMAGE_URL_INDEX = 2;
/** Hidden constructor for tool class */
private ImageFormat() {

View file

@ -239,6 +239,5 @@ public class Parse {
Graph graph = new Graph(nodes, connections);
Finder finder = new Finder(graph);
return finder.findPath(src, dst, startTime);
}
}

View file

@ -6,7 +6,6 @@ package fr.u_paris.gla.project.utils;
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.function.Consumer;
import java.util.stream.Stream;
@ -75,8 +74,8 @@ public final class CSVTools {
}
/** Save our current CSV variable's data into an actual file
* @param filename the saved file's name and path
* @param contentLineConsumer our data variable
* @param filename saved file's name and path
* @param contentLinesConsumer our data variable
* @throws IOException if we can't write the data into the file
*/
public static void writeCSVToFile(String filename,

File diff suppressed because it is too large Load diff