summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/benburwell/planes/gui/Main1090.java19
-rw-r--r--src/main/java/com/benburwell/planes/gui/TCPConnectionOptionDialog.java3
-rw-r--r--src/main/java/com/benburwell/planes/gui/Tabbable.java (renamed from src/main/java/com/benburwell/planes/gui/ViewComponent.java)3
-rw-r--r--src/main/java/com/benburwell/planes/gui/aircraftmap/AircraftMap.java2
-rw-r--r--src/main/java/com/benburwell/planes/gui/aircraftmap/AircraftMapComponent.java8
-rw-r--r--src/main/java/com/benburwell/planes/gui/aircrafttable/AircraftTableComponent.java9
-rw-r--r--src/main/java/com/benburwell/planes/gui/airportstable/AirportsComponent.java34
-rw-r--r--src/main/java/com/benburwell/planes/gui/airportstable/NavigationAidsTableModel.java (renamed from src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidsTableModel.java)2
-rw-r--r--src/main/java/com/benburwell/planes/gui/navigationaids/AirportsTableModel.java56
-rw-r--r--src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidComponent.java10
10 files changed, 126 insertions, 20 deletions
diff --git a/src/main/java/com/benburwell/planes/gui/Main1090.java b/src/main/java/com/benburwell/planes/gui/Main1090.java
index b0847bd..e3624ff 100644
--- a/src/main/java/com/benburwell/planes/gui/Main1090.java
+++ b/src/main/java/com/benburwell/planes/gui/Main1090.java
@@ -5,11 +5,15 @@
package com.benburwell.planes.gui;
import com.benburwell.planes.gui.aircrafttable.AircraftTableComponent;
+import com.benburwell.planes.gui.airportstable.AirportsComponent;
import com.benburwell.planes.gui.navigationaids.NavigationAidComponent;
import com.benburwell.planes.sbs.*;
import com.benburwell.planes.data.*;
import com.benburwell.planes.gui.aircraftmap.*;
+
+import java.util.List;
+import java.util.ArrayList;
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
@@ -53,15 +57,12 @@ public class Main1090 extends JFrame {
}
private void createTabs() {
- AircraftMapComponent aircraftMap = new AircraftMapComponent(this.aircraft, this.navaids, this.airports);
- this.tabbedPane.addTab("Live Map", aircraftMap.getComponent());
-
- AircraftTableComponent aircraftData = new AircraftTableComponent(this.aircraft);
- this.tabbedPane.addTab("Aircraft Data", aircraftData.getComponent());
-
- NavigationAidComponent navaids = new NavigationAidComponent(this.navaids);
- this.tabbedPane.addTab("Navigation Aids", navaids.getComponent());
-
+ List<Tabbable> tabs = new ArrayList<>();
+ tabs.add(new AircraftMapComponent(this.aircraft, this.navaids, this.airports));
+ tabs.add(new AircraftTableComponent(this.aircraft));
+ tabs.add(new NavigationAidComponent(this.navaids));
+ tabs.add(new AirportsComponent(this.airports));
+ tabs.forEach(tab -> this.tabbedPane.addTab(tab.getName(), tab.getComponent()));
this.add(this.tabbedPane);
this.tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
}
diff --git a/src/main/java/com/benburwell/planes/gui/TCPConnectionOptionDialog.java b/src/main/java/com/benburwell/planes/gui/TCPConnectionOptionDialog.java
index 609a70a..a8d7eea 100644
--- a/src/main/java/com/benburwell/planes/gui/TCPConnectionOptionDialog.java
+++ b/src/main/java/com/benburwell/planes/gui/TCPConnectionOptionDialog.java
@@ -5,7 +5,7 @@ import javax.swing.*;
/**
* Created by ben on 11/17/16.
*/
-public class TCPConnectionOptionDialog implements ViewComponent {
+public class TCPConnectionOptionDialog {
public static final String DEFAULT_HOSTNAME = "10.0.0.111";
public static final int DEFAULT_TCP_PORT = 30003;
@@ -14,7 +14,6 @@ public class TCPConnectionOptionDialog implements ViewComponent {
private JTextField portField = new JTextField(5);
private JLabel descriptionLabel = new JLabel("Add a network data source that provides data in the SBS-1 format");
- @Override
public JComponent getComponent() {
// set properties
hostField.setText(DEFAULT_HOSTNAME);
diff --git a/src/main/java/com/benburwell/planes/gui/ViewComponent.java b/src/main/java/com/benburwell/planes/gui/Tabbable.java
index 91c21cd..e7b5f3f 100644
--- a/src/main/java/com/benburwell/planes/gui/ViewComponent.java
+++ b/src/main/java/com/benburwell/planes/gui/Tabbable.java
@@ -5,6 +5,7 @@ import javax.swing.*;
/**
* Created by ben on 11/17/16.
*/
-public interface ViewComponent {
+public interface Tabbable {
+ String getName();
JComponent getComponent();
}
diff --git a/src/main/java/com/benburwell/planes/gui/aircraftmap/AircraftMap.java b/src/main/java/com/benburwell/planes/gui/aircraftmap/AircraftMap.java
index 64d86e9..09663fe 100644
--- a/src/main/java/com/benburwell/planes/gui/aircraftmap/AircraftMap.java
+++ b/src/main/java/com/benburwell/planes/gui/aircraftmap/AircraftMap.java
@@ -92,7 +92,7 @@ public class AircraftMap extends JPanel {
}
/**
- * Paint the ViewComponent on a Graphics instance
+ * Paint the Tabbable on a Graphics instance
*
* @param g the graphics context to paint on
*/
diff --git a/src/main/java/com/benburwell/planes/gui/aircraftmap/AircraftMapComponent.java b/src/main/java/com/benburwell/planes/gui/aircraftmap/AircraftMapComponent.java
index b4bb7e2..305df99 100644
--- a/src/main/java/com/benburwell/planes/gui/aircraftmap/AircraftMapComponent.java
+++ b/src/main/java/com/benburwell/planes/gui/aircraftmap/AircraftMapComponent.java
@@ -1,7 +1,7 @@
package com.benburwell.planes.gui.aircraftmap;
import com.benburwell.planes.data.*;
-import com.benburwell.planes.gui.ViewComponent;
+import com.benburwell.planes.gui.Tabbable;
import com.benburwell.planes.gui.aircraftmap.symbols.PlaneSymbol;
import javax.swing.*;
@@ -13,7 +13,7 @@ import java.util.ArrayList;
/**
* Created by ben on 11/18/16.
*/
-public class AircraftMapComponent implements ViewComponent {
+public class AircraftMapComponent implements Tabbable {
private AircraftStore store;
private CSVObjectStore<NavigationAid> navaids;
private CSVObjectStore<Airport> airportStore;
@@ -112,4 +112,8 @@ public class AircraftMapComponent implements ViewComponent {
return this.mapPanel;
}
+ @Override
+ public String getName() {
+ return "Map";
+ }
}
diff --git a/src/main/java/com/benburwell/planes/gui/aircrafttable/AircraftTableComponent.java b/src/main/java/com/benburwell/planes/gui/aircrafttable/AircraftTableComponent.java
index 8f1e71d..2bd6586 100644
--- a/src/main/java/com/benburwell/planes/gui/aircrafttable/AircraftTableComponent.java
+++ b/src/main/java/com/benburwell/planes/gui/aircrafttable/AircraftTableComponent.java
@@ -1,14 +1,14 @@
package com.benburwell.planes.gui.aircrafttable;
import com.benburwell.planes.data.AircraftStore;
-import com.benburwell.planes.gui.ViewComponent;
+import com.benburwell.planes.gui.Tabbable;
import javax.swing.*;
/**
* Created by ben on 11/17/16.
*/
-public class AircraftTableComponent implements ViewComponent {
+public class AircraftTableComponent implements Tabbable {
private JTable table;
private AircraftTableModel tableModel;
private JScrollPane scrollPane;
@@ -24,4 +24,9 @@ public class AircraftTableComponent implements ViewComponent {
public JComponent getComponent() {
return this.scrollPane;
}
+
+ @Override
+ public String getName() {
+ return "Aircraft";
+ }
}
diff --git a/src/main/java/com/benburwell/planes/gui/airportstable/AirportsComponent.java b/src/main/java/com/benburwell/planes/gui/airportstable/AirportsComponent.java
new file mode 100644
index 0000000..8739de7
--- /dev/null
+++ b/src/main/java/com/benburwell/planes/gui/airportstable/AirportsComponent.java
@@ -0,0 +1,34 @@
+package com.benburwell.planes.gui.airportstable;
+
+import com.benburwell.planes.data.Airport;
+import com.benburwell.planes.data.CSVObjectStore;
+import com.benburwell.planes.gui.Tabbable;
+import com.benburwell.planes.gui.navigationaids.AirportsTableModel;
+
+import javax.swing.*;
+
+/**
+ * Created by ben on 11/19/16.
+ */
+public class AirportsComponent implements Tabbable {
+ private JScrollPane scrollPane = new JScrollPane();
+ private JTable table = new JTable();
+ private AirportsTableModel tableModel;
+
+ public AirportsComponent(CSVObjectStore<Airport> airportStore) {
+ this.tableModel = new AirportsTableModel(airportStore.getObjects());
+ this.table = new JTable(this.tableModel);
+ this.table.setFillsViewportHeight(true);
+ this.scrollPane = new JScrollPane(table);
+ }
+
+ @Override
+ public JComponent getComponent() {
+ return this.scrollPane;
+ }
+
+ @Override
+ public String getName() {
+ return "Airports";
+ }
+}
diff --git a/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidsTableModel.java b/src/main/java/com/benburwell/planes/gui/airportstable/NavigationAidsTableModel.java
index 90b05eb..3ce098f 100644
--- a/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidsTableModel.java
+++ b/src/main/java/com/benburwell/planes/gui/airportstable/NavigationAidsTableModel.java
@@ -1,4 +1,4 @@
-package com.benburwell.planes.gui.navigationaids;
+package com.benburwell.planes.gui.airportstable;
import com.benburwell.planes.data.CSVObjectStore;
import com.benburwell.planes.data.NavigationAid;
diff --git a/src/main/java/com/benburwell/planes/gui/navigationaids/AirportsTableModel.java b/src/main/java/com/benburwell/planes/gui/navigationaids/AirportsTableModel.java
new file mode 100644
index 0000000..2850196
--- /dev/null
+++ b/src/main/java/com/benburwell/planes/gui/navigationaids/AirportsTableModel.java
@@ -0,0 +1,56 @@
+package com.benburwell.planes.gui.navigationaids;
+
+import com.benburwell.planes.data.Airport;
+
+import javax.swing.table.AbstractTableModel;
+import java.util.List;
+
+/**
+ * Created by ben on 11/19/16.
+ */
+public class AirportsTableModel extends AbstractTableModel {
+ public final String[] COLUMN_HEADERS = {"Identifier", "Name", "Country", "Municipality", "Scheduled Service", "IATA Code", "Local Code"};
+
+ public List<Airport> airports;
+
+ public AirportsTableModel(List<Airport> airports) {
+ this.airports = airports;
+ }
+
+ @Override
+ public String getColumnName(int columnIndex) {
+ return COLUMN_HEADERS[columnIndex];
+ }
+
+ @Override
+ public int getRowCount() {
+ return airports.size();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return COLUMN_HEADERS.length;
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ Airport airport = this.airports.get(rowIndex);
+ switch (columnIndex) {
+ case 0:
+ return airport.getIdent();
+ case 1:
+ return airport.getName();
+ case 2:
+ return airport.getIsoCountry();
+ case 3:
+ return airport.getMunicipality();
+ case 4:
+ return airport.isScheduledService();
+ case 5:
+ return airport.getIataCode();
+ case 6:
+ return airport.getLocalCode();
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidComponent.java b/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidComponent.java
index 1ad7e3e..1238873 100644
--- a/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidComponent.java
+++ b/src/main/java/com/benburwell/planes/gui/navigationaids/NavigationAidComponent.java
@@ -2,14 +2,15 @@ package com.benburwell.planes.gui.navigationaids;
import com.benburwell.planes.data.CSVObjectStore;
import com.benburwell.planes.data.NavigationAid;
-import com.benburwell.planes.gui.ViewComponent;
+import com.benburwell.planes.gui.Tabbable;
+import com.benburwell.planes.gui.airportstable.NavigationAidsTableModel;
import javax.swing.*;
/**
* Created by ben on 11/19/16.
*/
-public class NavigationAidComponent implements ViewComponent {
+public class NavigationAidComponent implements Tabbable {
private JTable table;
private NavigationAidsTableModel tableModel;
private JScrollPane scrollPane;
@@ -25,4 +26,9 @@ public class NavigationAidComponent implements ViewComponent {
public JComponent getComponent() {
return this.scrollPane;
}
+
+ @Override
+ public String getName() {
+ return "Navigation Aids";
+ }
}