Added Pop Up Map
This commit is contained in:
@@ -34,6 +34,9 @@ public class Session implements Serializable {
|
|||||||
public Session(){
|
public Session(){
|
||||||
//blank constructor
|
//blank constructor
|
||||||
this.sceneDisplayed = SceneCode.INITIAL;
|
this.sceneDisplayed = SceneCode.INITIAL;
|
||||||
|
this.filteredAirlines = new HashMap<>();
|
||||||
|
this.filteredAirports = new HashMap<>();
|
||||||
|
this.filteredRoutes = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -429,6 +429,10 @@ public class Airport {
|
|||||||
public int getTotalRoutes(){
|
public int getTotalRoutes(){
|
||||||
return departureRoutes.size() + arrivalRoutes.size();
|
return departureRoutes.size() + arrivalRoutes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RoutePath getRoutePath(){
|
||||||
|
return new RoutePath(new Position(latitude, longitude));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Information of the airport returned in String format.
|
* Information of the airport returned in String format.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -63,27 +63,25 @@ public class AirportRDController extends Controller{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
theDataSet = getParent().getCurrentDataset();
|
theDataSet = getParent().getCurrentDataset();
|
||||||
if (theDataSet != null) {
|
//Sets up the table columns to be ready for use for Airport data
|
||||||
//Sets up the table columns to be ready for use for Airport data
|
airpIDCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("ID"));
|
||||||
airpIDCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("ID"));
|
airpNameCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Name"));
|
||||||
airpNameCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Name"));
|
airpCityCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("CityName"));
|
||||||
airpCityCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("CityName"));
|
airpCountryCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("CountryName"));
|
||||||
airpCountryCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("CountryName"));
|
airpIATAFFACol.setCellValueFactory(new PropertyValueFactory<Airport, String>("IATA_FFA"));
|
||||||
airpIATAFFACol.setCellValueFactory(new PropertyValueFactory<Airport, String>("IATA_FFA"));
|
airpICAOCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("ICAO"));
|
||||||
airpICAOCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("ICAO"));
|
airpLatitudeCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Latitude"));
|
||||||
airpLatitudeCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Latitude"));
|
airpLongitudeCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Longitude"));
|
||||||
airpLongitudeCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Longitude"));
|
airpAltitudeCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Altitude"));
|
||||||
airpAltitudeCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Altitude"));
|
airpTimezoneCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Timezone"));
|
||||||
airpTimezoneCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Timezone"));
|
airpDSTCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("DST"));
|
||||||
airpDSTCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("DST"));
|
airpTzCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Tz"));
|
||||||
airpTzCol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Tz"));
|
|
||||||
|
|
||||||
//Assigning the Dataset to the current Dataset's airports and displaying it in a table
|
//Assigning the Dataset to the current Dataset's airports and displaying it in a table
|
||||||
currentSession = getParent().getSession();
|
currentSession = getParent().getSession();
|
||||||
|
|
||||||
tableViewAirportRD.setItems(observableArrayList(theDataSet.getAirports()));
|
tableViewAirportRD.setItems(observableArrayList(theDataSet.getAirports()));
|
||||||
tableViewAirportRD.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
tableViewAirportRD.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openAdd() {
|
public void openAdd() {
|
||||||
|
|||||||
@@ -195,11 +195,6 @@ public class FlightSummaryController extends Controller {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (theDataSet.getFlightPaths().size() > 0) {
|
|
||||||
map = new Map(mapView, theDataSet.getFlightPaths().get(0).getRoutePath());
|
|
||||||
} else {
|
|
||||||
map = new Map(mapView, new RoutePath());
|
|
||||||
}
|
|
||||||
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
|
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
|
||||||
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
||||||
int index = flightPathListView.getSelectionModel().getSelectedIndices().get(0);
|
int index = flightPathListView.getSelectionModel().getSelectedIndices().get(0);
|
||||||
@@ -208,6 +203,7 @@ public class FlightSummaryController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
map = new Map(mapView, new RoutePath(), flightPathListView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package seng202.group9.GUI;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
|
import javafx.scene.web.WebView;
|
||||||
|
import seng202.group9.Core.Airport;
|
||||||
|
import seng202.group9.Core.Position;
|
||||||
|
import seng202.group9.Core.Route;
|
||||||
|
import seng202.group9.Core.RoutePath;
|
||||||
|
import seng202.group9.Map.Map;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by fwy13 on 2/10/16.
|
||||||
|
*/
|
||||||
|
public class PopUpMapController extends Controller {
|
||||||
|
@FXML
|
||||||
|
WebView mapView;
|
||||||
|
Map map;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load() {
|
||||||
|
map = new Map(mapView, new RoutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadAirports(ArrayList<Airport> airports){
|
||||||
|
ArrayList<RoutePath> routePaths = new ArrayList<>();
|
||||||
|
for (Airport airport: airports){
|
||||||
|
routePaths.add(airport.getRoutePath());
|
||||||
|
}
|
||||||
|
map.displayAirports(routePaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadRoutes(ArrayList<Route> routes){
|
||||||
|
ArrayList<RoutePath> routePaths = new ArrayList<>();
|
||||||
|
for (Route route: routes){
|
||||||
|
routePaths.add(route.getRoutePath());
|
||||||
|
}
|
||||||
|
map.displayRoutes(routePaths);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import javafx.beans.value.ChangeListener;
|
|||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.concurrent.Worker;
|
import javafx.concurrent.Worker;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.ListView;
|
||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
import javafx.scene.web.WebEngine;
|
import javafx.scene.web.WebEngine;
|
||||||
import javafx.scene.web.WebView;
|
import javafx.scene.web.WebView;
|
||||||
@@ -50,6 +51,21 @@ public class Map {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map(WebView webView, final RoutePath newRoute, ListView table){
|
||||||
|
this.webView = webView;
|
||||||
|
webEngine = webView.getEngine();
|
||||||
|
initMap();
|
||||||
|
webEngine.getLoadWorker().stateProperty().addListener(
|
||||||
|
new ChangeListener<Worker.State>() {
|
||||||
|
public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) {
|
||||||
|
if (newState == Worker.State.SUCCEEDED){
|
||||||
|
displayRoute(newRoute);
|
||||||
|
table.getSelectionModel().selectFirst();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void initMap() {
|
public void initMap() {
|
||||||
webEngine.load(getClass().getClassLoader().getResource("map.html").toExternalForm());
|
webEngine.load(getClass().getClassLoader().getResource("map.html").toExternalForm());
|
||||||
}
|
}
|
||||||
@@ -64,6 +80,24 @@ public class Map {
|
|||||||
webEngine.executeScript(scriptToExecute);
|
webEngine.executeScript(scriptToExecute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void displayAirports(ArrayList<RoutePath> airports) {
|
||||||
|
String airportJSONArray = "[";
|
||||||
|
int counter = 0;
|
||||||
|
for (RoutePath airport: airports){
|
||||||
|
airportJSONArray += airport.toJSONArray() + ", ";
|
||||||
|
if (counter++ > 49){
|
||||||
|
Alert alert = new Alert(Alert.AlertType.WARNING);
|
||||||
|
alert.setTitle("Too Many Routes");
|
||||||
|
alert.setHeaderText("Too Many Routes to display");
|
||||||
|
alert.setContentText("As there are too many routes to display only the first\n50 will be displayed.");
|
||||||
|
alert.showAndWait();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
airportJSONArray += "]";
|
||||||
|
webEngine.executeScript("displayRoutes("+airportJSONArray+");");
|
||||||
|
}
|
||||||
|
|
||||||
public void displayRoutes(ArrayList<RoutePath> routes){
|
public void displayRoutes(ArrayList<RoutePath> routes){
|
||||||
String routeJSONArray = "[";
|
String routeJSONArray = "[";
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|||||||
@@ -49,6 +49,21 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function displayAirports(positions){
|
||||||
|
map = new google.maps.Map(document.getElementById('map'), {
|
||||||
|
center: positions[0],
|
||||||
|
zoom: 5
|
||||||
|
});
|
||||||
|
for (var i = 0; i < positions.length; i ++) {
|
||||||
|
new google.maps.Marker({
|
||||||
|
position: positions[i],
|
||||||
|
map: map,
|
||||||
|
title: '\u0048\u0061\u0072\u0061\u006d\u0062\u0065'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
repositionMap(positions);
|
||||||
|
}
|
||||||
|
|
||||||
function displayRoute(flightPath) {
|
function displayRoute(flightPath) {
|
||||||
map = new google.maps.Map(document.getElementById('map'), {
|
map = new google.maps.Map(document.getElementById('map'), {
|
||||||
center: {lat: 39.144684, lng: -84.510079},
|
center: {lat: 39.144684, lng: -84.510079},
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.web.*?>
|
||||||
|
<?import java.lang.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="seng202.group9.GUI.PopUpMapController">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<WebView fx:id="mapView" prefHeight="200.0" prefWidth="200.0" />
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
Reference in New Issue
Block a user