FInisehd Pop Up Map
This commit is contained in:
@@ -13,7 +13,8 @@ public enum SceneCode {
|
|||||||
AIRPORT_ADD("airport_add_form.fxml"), AIRPORT_FILTER("airport_filter_form.fxml"), ROUTE_ADD("route_add_form.fxml"),
|
AIRPORT_ADD("airport_add_form.fxml"), AIRPORT_FILTER("airport_filter_form.fxml"), ROUTE_ADD("route_add_form.fxml"),
|
||||||
ROUTE_FILTER("route_filter_form.fxml"), AIRLINE_EDIT("airline_edit_form.fxml"), AIRPORT_EDIT("airport_edit_form.fxml"),
|
ROUTE_FILTER("route_filter_form.fxml"), AIRLINE_EDIT("airline_edit_form.fxml"), AIRPORT_EDIT("airport_edit_form.fxml"),
|
||||||
ROUTE_EDIT("route_edit_form.fxml"), FLIGHT_EDITOR("flight_editor_form.fxml"), DATASET_CONTROLLER("dataset_editor.fxml"), HELP("help.fxml"),
|
ROUTE_EDIT("route_edit_form.fxml"), FLIGHT_EDITOR("flight_editor_form.fxml"), DATASET_CONTROLLER("dataset_editor.fxml"), HELP("help.fxml"),
|
||||||
FLIGHT_ADD("flight_add_form.fxml"), ROUTE_BY_AIRPORT("airport_map_routes.fxml"), ROUTE_BY_EQUIP("route_by_equip.fxml");
|
FLIGHT_ADD("flight_add_form.fxml"), ROUTE_BY_AIRPORT("airport_map_routes.fxml"), ROUTE_BY_EQUIP("route_by_equip.fxml"),
|
||||||
|
POP_UP_AIRPORT_MAP("pop_up_airport_map.fxml"), POP_UP_ROUTE_MAP("pop_up_route_map.fxml");
|
||||||
|
|
||||||
|
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import javafx.collections.ObservableList;
|
|||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.cell.PropertyValueFactory;
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
|
import javafx.stage.Stage;
|
||||||
import seng202.group9.Controller.Dataset;
|
import seng202.group9.Controller.Dataset;
|
||||||
import seng202.group9.Controller.SceneCode;
|
import seng202.group9.Controller.SceneCode;
|
||||||
import seng202.group9.Controller.Session;
|
import seng202.group9.Controller.Session;
|
||||||
@@ -142,6 +143,6 @@ public class AirportRDController extends Controller{
|
|||||||
* Opens a map with the data currently being displayed in the table.
|
* Opens a map with the data currently being displayed in the table.
|
||||||
*/
|
*/
|
||||||
public void openMap() {
|
public void openMap() {
|
||||||
|
createPopUpStage(SceneCode.POP_UP_AIRPORT_MAP, 600, 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-6
@@ -3,6 +3,7 @@ package seng202.group9.GUI;
|
|||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
import javafx.scene.web.WebView;
|
import javafx.scene.web.WebView;
|
||||||
|
import seng202.group9.Controller.Dataset;
|
||||||
import seng202.group9.Core.Airport;
|
import seng202.group9.Core.Airport;
|
||||||
import seng202.group9.Core.Position;
|
import seng202.group9.Core.Position;
|
||||||
import seng202.group9.Core.Route;
|
import seng202.group9.Core.Route;
|
||||||
@@ -10,26 +11,30 @@ import seng202.group9.Core.RoutePath;
|
|||||||
import seng202.group9.Map.Map;
|
import seng202.group9.Map.Map;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by fwy13 on 2/10/16.
|
* Created by fwy13 on 2/10/16.
|
||||||
*/
|
*/
|
||||||
public class PopUpMapController extends Controller {
|
public class PopUpAirportMapController extends Controller {
|
||||||
@FXML
|
@FXML
|
||||||
WebView mapView;
|
WebView mapView;
|
||||||
|
Dataset dataset;
|
||||||
Map map;
|
Map map;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
map = new Map(mapView, new RoutePath());
|
dataset = getParent().getCurrentDataset();
|
||||||
|
loadAirports();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadAirports(ArrayList<Airport> airports){
|
public void loadAirports(){
|
||||||
ArrayList<RoutePath> routePaths = new ArrayList<>();
|
ArrayList<RoutePath> routePaths = new ArrayList<>();
|
||||||
for (Airport airport: airports){
|
HashMap airports = getParent().getSession().getFilteredAirports();
|
||||||
routePaths.add(airport.getRoutePath());
|
for (int i = 0; i < airports.size(); i ++){
|
||||||
|
routePaths.add(dataset.getAirportDictionary().get(airports.get(i)).getRoutePath());
|
||||||
}
|
}
|
||||||
map.displayAirports(routePaths);
|
map = new Map(mapView, routePaths, Map.loadAirports);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadRoutes(ArrayList<Route> routes){
|
public void loadRoutes(ArrayList<Route> routes){
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package seng202.group9.GUI;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.web.WebView;
|
||||||
|
import seng202.group9.Controller.Dataset;
|
||||||
|
import seng202.group9.Core.Route;
|
||||||
|
import seng202.group9.Core.RoutePath;
|
||||||
|
import seng202.group9.Map.Map;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by fwy13 on 2/10/16.
|
||||||
|
*/
|
||||||
|
public class PopUpRouteMapController extends Controller{
|
||||||
|
@FXML
|
||||||
|
WebView mapView;
|
||||||
|
Dataset dataset;
|
||||||
|
Map map;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load() {
|
||||||
|
dataset = getParent().getCurrentDataset();
|
||||||
|
loadRoutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadRoutes(){
|
||||||
|
ArrayList<RoutePath> routePaths = new ArrayList<>();
|
||||||
|
HashMap routes = getParent().getSession().getFilteredRoutes();
|
||||||
|
for (int i = 0; i < routes.size(); i ++){
|
||||||
|
routePaths.add(dataset.getRouteDictionary().get(routes.get(i)).getRoutePath());
|
||||||
|
}
|
||||||
|
map = new Map(mapView, routePaths, Map.loadRoutes);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -143,6 +143,6 @@ public class RouteRDController extends Controller {
|
|||||||
* Opens a map with the data currently being displayed in the table.
|
* Opens a map with the data currently being displayed in the table.
|
||||||
*/
|
*/
|
||||||
public void openMap(){
|
public void openMap(){
|
||||||
|
createPopUpStage(SceneCode.POP_UP_ROUTE_MAP, 600, 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public class Map {
|
|||||||
private WebEngine webEngine;
|
private WebEngine webEngine;
|
||||||
private WebView webView;
|
private WebView webView;
|
||||||
private boolean canLoad = false;
|
private boolean canLoad = false;
|
||||||
|
public static int loadAirports = 0;
|
||||||
|
public static int loadRoutes = 1;
|
||||||
|
|
||||||
public Map(WebView webView, final RoutePath newRoute){
|
public Map(WebView webView, final RoutePath newRoute){
|
||||||
this.webView = webView;
|
this.webView = webView;
|
||||||
@@ -36,6 +38,24 @@ public class Map {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map(WebView webView, final ArrayList<RoutePath> newRoute, int type){
|
||||||
|
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){
|
||||||
|
if (loadAirports == type) {
|
||||||
|
displayAirports(newRoute);
|
||||||
|
}else if (loadRoutes == type){
|
||||||
|
displayRoutes(newRoute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public Map(WebView webView, final RoutePath newRoute, TableView table){
|
public Map(WebView webView, final RoutePath newRoute, TableView table){
|
||||||
this.webView = webView;
|
this.webView = webView;
|
||||||
webEngine = webView.getEngine();
|
webEngine = webView.getEngine();
|
||||||
@@ -87,15 +107,15 @@ public class Map {
|
|||||||
airportJSONArray += airport.toJSONArray() + ", ";
|
airportJSONArray += airport.toJSONArray() + ", ";
|
||||||
if (counter++ > 49){
|
if (counter++ > 49){
|
||||||
Alert alert = new Alert(Alert.AlertType.WARNING);
|
Alert alert = new Alert(Alert.AlertType.WARNING);
|
||||||
alert.setTitle("Too Many Routes");
|
alert.setTitle("Too Many Airports");
|
||||||
alert.setHeaderText("Too Many Routes to display");
|
alert.setHeaderText("Too Many Airports to display");
|
||||||
alert.setContentText("As there are too many routes to display only the first\n50 will be displayed.");
|
alert.setContentText("As there are too many Airports to display only the first\n50 will be displayed.");
|
||||||
alert.showAndWait();
|
alert.showAndWait();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
airportJSONArray += "]";
|
airportJSONArray += "]";
|
||||||
webEngine.executeScript("displayRoutes("+airportJSONArray+");");
|
webEngine.executeScript("displayAirports("+airportJSONArray+");");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayRoutes(ArrayList<RoutePath> routes){
|
public void displayRoutes(ArrayList<RoutePath> routes){
|
||||||
|
|||||||
@@ -56,12 +56,12 @@
|
|||||||
});
|
});
|
||||||
for (var i = 0; i < positions.length; i ++) {
|
for (var i = 0; i < positions.length; i ++) {
|
||||||
new google.maps.Marker({
|
new google.maps.Marker({
|
||||||
position: positions[i],
|
position: positions[i][0],
|
||||||
map: map,
|
map: map,
|
||||||
title: '\u0048\u0061\u0072\u0061\u006d\u0062\u0065'
|
title: '\u0048\u0061\u0072\u0061\u006d\u0062\u0065'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
repositionMap(positions);
|
repositionMapToMulti(positions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayRoute(flightPath) {
|
function displayRoute(flightPath) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<?import java.lang.*?>
|
<?import java.lang.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?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">
|
<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.PopUpAirportMapController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
@@ -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="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.PopUpRouteMapController">
|
||||||
|
<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