From c42855e8e207280548a09adf74ee88e5f43eb8d1 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 1 May 2024 14:00:35 +0200 Subject: [PATCH] Support the inspect line feature for the new gui --- .../java/fr/u_paris/gla/project/gui/View.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/main/java/fr/u_paris/gla/project/gui/View.java b/src/main/java/fr/u_paris/gla/project/gui/View.java index f3a4c82..671a743 100644 --- a/src/main/java/fr/u_paris/gla/project/gui/View.java +++ b/src/main/java/fr/u_paris/gla/project/gui/View.java @@ -81,6 +81,7 @@ public class View extends JFrame { public View(ArrayList s) throws HeadlessException { + setSize(800, 600); MainPanel = new JPanel(); GridLayout MainLayout = new GridLayout(1, 2, 50, 0); MainPanel.setLayout(MainLayout); @@ -127,8 +128,6 @@ public class View extends JFrame { paneStops.add(tableStops); NetworkPanel.add(paneStops); - - ItineraryPanel = new JPanel(); CardPanel.add(ItineraryPanel); GridLayout ItineraryLayout = new GridLayout(2, 1); @@ -138,23 +137,42 @@ 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); + + 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(Box.createHorizontalStrut(10)); + LinesPanel.add(linesComboBox); + LinesPanel.add(Box.createHorizontalStrut(10)); + LinesPanel.add(showLineButton); + LinesPanel.add(Box.createHorizontalStrut(2)); + LinesPanel.add(Box.createHorizontalGlue()); ButtonBar = new JMenuBar(); - GridLayout ButtonLayout = new GridLayout(3, 1); + GridLayout ButtonLayout = new GridLayout(4, 1); ButtonBar.setLayout(ButtonLayout); Home = new JMenuItem("Home"); ButtonBar.add(Home); Network = new JMenuItem("Network"); ButtonBar.add(Network); - Itinerary = new JMenuItem("Itinerary"); ButtonBar.add(Itinerary); - ButtonBar.setPreferredSize(new Dimension(50, 500)); + Lines = new JMenuItem("Lines"); + ButtonBar.add(Lines); + ButtonBar.setPreferredSize(new Dimension(50, 500)); MainPanel.add(ButtonBar); MainPanel.add(CardPanel); - modelStops = (DefaultTableModel) tableStops.getModel(); modelStops.setColumnCount(2); modelStops.setColumnIdentifiers(new Object[]{"Line", "Stop"}); @@ -165,8 +183,7 @@ public class View extends JFrame { this.StopList = s; setContentPane(MainPanel); - setTitle("app"); - setExtendedState(JFrame.MAXIMIZED_BOTH); + setTitle("Pathfinder"); //setUndecorated(true); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -205,6 +222,7 @@ public class View extends JFrame { } }); + Lines.addActionListener(e -> { CardPanel.removeAll(); CardPanel.add(LinesPanel); @@ -218,8 +236,6 @@ public class View extends JFrame { openWebpage(item.getValue()); }); - - TextLocation.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) {