Support the inspect line feature for the new gui

This commit is contained in:
Lucas 2024-05-01 14:00:35 +02:00
parent 586692fffb
commit c42855e8e2

View file

@ -81,6 +81,7 @@ public class View extends JFrame {
public View(ArrayList<Stop> s) throws HeadlessException { public View(ArrayList<Stop> s) throws HeadlessException {
setSize(800, 600);
MainPanel = new JPanel(); MainPanel = new JPanel();
GridLayout MainLayout = new GridLayout(1, 2, 50, 0); GridLayout MainLayout = new GridLayout(1, 2, 50, 0);
MainPanel.setLayout(MainLayout); MainPanel.setLayout(MainLayout);
@ -127,8 +128,6 @@ public class View extends JFrame {
paneStops.add(tableStops); paneStops.add(tableStops);
NetworkPanel.add(paneStops); NetworkPanel.add(paneStops);
ItineraryPanel = new JPanel(); ItineraryPanel = new JPanel();
CardPanel.add(ItineraryPanel); CardPanel.add(ItineraryPanel);
GridLayout ItineraryLayout = new GridLayout(2, 1); GridLayout ItineraryLayout = new GridLayout(2, 1);
@ -138,23 +137,42 @@ public class View extends JFrame {
paneItinerary.add(tableItinerary); paneItinerary.add(tableItinerary);
ItineraryPanel.add(paneItinerary); 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(); ButtonBar = new JMenuBar();
GridLayout ButtonLayout = new GridLayout(3, 1); GridLayout ButtonLayout = new GridLayout(4, 1);
ButtonBar.setLayout(ButtonLayout); ButtonBar.setLayout(ButtonLayout);
Home = new JMenuItem("Home"); Home = new JMenuItem("Home");
ButtonBar.add(Home); ButtonBar.add(Home);
Network = new JMenuItem("Network"); Network = new JMenuItem("Network");
ButtonBar.add(Network); ButtonBar.add(Network);
Itinerary = new JMenuItem("Itinerary"); Itinerary = new JMenuItem("Itinerary");
ButtonBar.add(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(ButtonBar);
MainPanel.add(CardPanel); MainPanel.add(CardPanel);
modelStops = (DefaultTableModel) tableStops.getModel(); modelStops = (DefaultTableModel) tableStops.getModel();
modelStops.setColumnCount(2); modelStops.setColumnCount(2);
modelStops.setColumnIdentifiers(new Object[]{"Line", "Stop"}); modelStops.setColumnIdentifiers(new Object[]{"Line", "Stop"});
@ -165,8 +183,7 @@ public class View extends JFrame {
this.StopList = s; this.StopList = s;
setContentPane(MainPanel); setContentPane(MainPanel);
setTitle("app"); setTitle("Pathfinder");
setExtendedState(JFrame.MAXIMIZED_BOTH);
//setUndecorated(true); //setUndecorated(true);
setVisible(true); setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@ -205,6 +222,7 @@ public class View extends JFrame {
} }
}); });
Lines.addActionListener(e -> { Lines.addActionListener(e -> {
CardPanel.removeAll(); CardPanel.removeAll();
CardPanel.add(LinesPanel); CardPanel.add(LinesPanel);
@ -218,8 +236,6 @@ public class View extends JFrame {
openWebpage(item.getValue()); openWebpage(item.getValue());
}); });
TextLocation.addKeyListener(new KeyAdapter() { TextLocation.addKeyListener(new KeyAdapter() {
@Override @Override
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {