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 {
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) {