diff options
Diffstat (limited to 'src/com/benburwell/planes/gui/Main1090.java')
-rw-r--r-- | src/com/benburwell/planes/gui/Main1090.java | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/src/com/benburwell/planes/gui/Main1090.java b/src/com/benburwell/planes/gui/Main1090.java deleted file mode 100644 index d7fc830..0000000 --- a/src/com/benburwell/planes/gui/Main1090.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Created by ben on 11/15/16. - */ - -package com.benburwell.planes.gui; - -import com.benburwell.planes.sbs.*; -import com.benburwell.planes.data.*; -import com.benburwell.planes.gui.aircraftmap.*; - -import java.awt.*; -import javax.swing.*; -import java.awt.event.ActionEvent; - -public class Main1090 extends JFrame { - private AggregateDataSource sbsDataSource = new AggregateDataSource(); - private AircraftStore aircraft = new AircraftStore(); - private int currentTcpConnection = 0; - private JTabbedPane tabbedPane = new JTabbedPane(); - - public Main1090() { - this.initUI(); - } - - private void initUI() { - this.createMenuBar(); - - this.setTitle("1090"); - this.setSize(600, 400); - this.setLocationRelativeTo(null); - this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - - this.openDataSource(); - - this.createTabs(); - } - - private void createTabs() { - AircraftTableComponent aircraftData = new AircraftTableComponent(this.aircraft); - this.tabbedPane.addTab("Aircraft Data", aircraftData.getComponent()); - - AircraftMapComponent aircraftMap = new AircraftMapComponent(this.aircraft); - this.tabbedPane.addTab("Live Map", aircraftMap.getComponent()); - - this.add(this.tabbedPane); - this.tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); - - this.tabbedPane.setSelectedIndex(1); - } - - private void createMenuBar() { - MenuBarProvider provider = new MenuBarProvider(); - this.setJMenuBar(provider.getMenuBar()); - - provider.getDataConnectItem().addActionListener((ActionEvent event) -> { - if (this.currentTcpConnection == 0) { - TCPConnectionOptionDialog dialog = new TCPConnectionOptionDialog(); - JOptionPane.showMessageDialog(this, dialog.getComponent(), "New Network Data Source", JOptionPane.PLAIN_MESSAGE); - this.currentTcpConnection = this.addTcpSource(dialog.getHost(), dialog.getPort()); - provider.getDataConnectItem().setEnabled(false); - provider.getDataDisconnectItem().setEnabled(true); - } - }); - provider.getDataDisconnectItem().addActionListener((ActionEvent event) -> { - if (this.currentTcpConnection != 0) { - this.sbsDataSource.closeSource(this.currentTcpConnection); - provider.getDataConnectItem().setEnabled(true); - provider.getDataDisconnectItem().setEnabled(false); - this.currentTcpConnection = 0; - } - }); - } - - private void openDataSource() { - this.sbsDataSource.subscribe((SBSPacket packet) -> { - this.aircraft.addPacket(packet); - }); - this.sbsDataSource.open(); - } - - private int addTcpSource(String host, int port) { - TCPDataSource source = new TCPDataSource(host, port); - source.open(); - return this.sbsDataSource.addSource(source); - } - - public static void main(String[] args) { - EventQueue.invokeLater(() -> { - Main1090 app = new Main1090(); - app.setVisible(true); - }); - } -} |