Merge branch 'ConnectMaps'

main
YaFedImYaEatIm 9 years ago
commit 84e273de1f

Binary file not shown.

@ -50,6 +50,7 @@ public class App extends Application
InputStream in = getClass().getClassLoader().getResourceAsStream("menu.fxml");
mainContainer = (VBox) loader.load(in);
Scene scene = new Scene(mainContainer, 800, 600);
primaryStage.setResizable(false);
primaryStage.setScene(scene);
primaryStage.sizeToScene();
MenuController menuController = (MenuController) loader.getController();
@ -135,6 +136,7 @@ public class App extends Application
System.out.println("Missing Session Class");
System.exit(1);
} catch (Exception e) {
session = new Session();
e.printStackTrace();
}
}

@ -752,6 +752,7 @@ public class Dataset {
airportsByIATA.put(airport.getIATA_FFA(), airport);
airportsByICAO.put(airport.getICAO(), airport);
airport.setCountry(countryDictionary.get(airport.getCountryName()));
//airport.getCountry().setPosition(new Position(airport.getLatitude(), airport.getLongitude()));
//TODO Add City in country (This is extra work).
airport.setCity(cityDictionary.get(airport.getCityName()));
airport.getCity().addAirport(airport);
@ -847,6 +848,7 @@ public class Dataset {
addAirport(airportToAdd);
addCity(cityToAdd);
addCountry(countryToAdd);
createDataLinks();
}catch (NumberFormatException e){
throw new DataException("Latitude, Longitude, Altitude and Timezone must be numbers");
}
@ -859,6 +861,9 @@ public class Dataset {
if (airportToAdd.getICAO() != "" && airportToAdd.getICAO().length() != 4){
throw new DataException("ICAO either empty or 4 letters");
}
if (airportToAdd.getName() == ""){
throw new DataException("An Airport cannot have no name.");
}
for (String key : airportDictionary.keySet()){
airportDictionary.get(key).hasDuplicate(airportToAdd);
}
@ -876,6 +881,7 @@ public class Dataset {
"\""+airportToAdd.getCountryName()+"\", \""+airportToAdd.getIATA_FFA()+"\", \""+airportToAdd.getICAO()+"\", " +
""+airportToAdd.getLatitude()+", "+airportToAdd.getLongitude()+", "+airportToAdd.getAltitude()+");";
stmt.execute(insertAirportQuery);
stmt.close();
//get the airport id
stmt = c.createStatement();
String airportIDQuery = "SELECT * FROM `sqlite_sequence` WHERE `name` = \""+this.name+"_Airport\" LIMIT 1;";
@ -887,6 +893,9 @@ public class Dataset {
airportToAdd.setID(airportID);
airports.add(airportToAdd);
airportDictionary.put(airportToAdd.getName(), airportToAdd);
airportIDRes.close();
stmt.close();
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
@ -912,6 +921,7 @@ public class Dataset {
stmt.close();
cityDictionary.put(city.getName(), city);
cities.add(city);
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
@ -936,6 +946,7 @@ public class Dataset {
stmt.close();
countryDictionary.put(country.getName(), country);
countries.add(country);
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);

@ -7,7 +7,7 @@ public enum SceneCode {
INITIAL(""), AIRLINE_SUMMARY("airline_summary.fxml"), AIRLINE_RAW_DATA("airline_raw_data.fxml"),
AIRPORT_SUMMARY("airport_summary.fxml"), AIRPORT_RAW_DATA("airport_raw_data.fxml"),
ROUTE_SUMMARY("routes_summary.fxml"), ROUTE_RAW_DATA("route_raw_data.fxml"), FLIGHT_SUMMARY("flight_data_summary.fxml"),
FLIGHT_RAW_DATA("flight_raw_data.fxml"), AIRPORT_ANALYSER("airport_analyser.fxml"), ROUTE_ANALYSER("route_analyser.fxml");;
FLIGHT_RAW_DATA("flight_raw_data.fxml"), AIRPORT_ANALYSER("airport_analyser.fxml"), ROUTE_ANALYSER("route_analyser.fxml");
private String filePath;

@ -365,7 +365,7 @@ public class Airport {
return distance;
}
public void hasDuplicate(Airport airport) throws DataException{
if (!airport.getName().equals("") && airport.getName().equals(this.name)){
if (airport.getName().equals("") || airport.getName().equals(this.name)){
throw new DataException("Airport Name already Exists, Please Choose Another.");
}
if (!airport.getIATA_FFA().equals("") && airport.getIATA_FFA().equals(this.name)){

@ -6,6 +6,7 @@ public class Country {
private String DST, name;
private ArrayList<City> cities = new ArrayList<City>();
private ArrayList<Airline> airlines = new ArrayList<Airline>();
private Position position;
public Country(String DST, String name){
this.DST = DST;
@ -81,4 +82,16 @@ public class Country {
public void delCities(int index){
this.cities.remove(index);
}
public ArrayList<City> getCities() {
return cities;
}
public Position getPosition() {
return position;
}
public void setPosition(Position position) {
this.position = position;
}
}

@ -1,15 +1,22 @@
package seng202.group9.GUI;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.web.WebView;
import seng202.group9.Controller.App;
import seng202.group9.Controller.Dataset;
import seng202.group9.Controller.SceneCode;
import seng202.group9.Core.Airline;
import seng202.group9.Core.Airport;
import seng202.group9.Core.Position;
import seng202.group9.Core.RoutePath;
import seng202.group9.Map.Map;
/**
* Created by michael on 14/09/2016.
@ -18,6 +25,8 @@ public class AirlineSummaryController extends Controller{
@FXML
private TableView<Airline> tableView;
@FXML
private WebView mapView;
@FXML
private TableColumn<Airline, String> columnName;
@FXML
private TableColumn<Airline, String> columnAlias;
@ -30,14 +39,28 @@ public class AirlineSummaryController extends Controller{
private Dataset currentData = null;
private Map map;
public void load() {
columnName.setCellValueFactory(new PropertyValueFactory<Airline, String>("Name"));
columnAlias.setCellValueFactory(new PropertyValueFactory<Airline, String>("Alias"));
columnCountry.setCellValueFactory(new PropertyValueFactory<Airline, String>("Country"));
columnCountry.setCellValueFactory(new PropertyValueFactory<Airline, String>("CountryName"));
columnIATA.setCellValueFactory(new PropertyValueFactory<Airline, String>("IATA"));
columnActive.setCellValueFactory(new PropertyValueFactory<Airline, String>("Active"));
currentData = getParent().getCurrentDataset();
tableView.setItems(FXCollections.observableArrayList(currentData.getAirlines()));
map = new Map(mapView, new RoutePath());
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Airline>() {
public void changed(ObservableValue<? extends Airline> observable, Airline oldValue, Airline newValue) {
Airline selectedAirline= currentData.getAirlines().get(tableView.getSelectionModel().getSelectedIndices().get(0));
for (int i = 0 ; i < currentData.getAirports().size(); i ++){
if (currentData.getAirports().get(i).getCountryName().equals(selectedAirline.getCountryName())){
map.displayAirport(new RoutePath(new Position(currentData.getAirports().get(i).getLatitude(), currentData.getAirports().get(i).getLongitude())));
break;
}
}
}
});
}
public void airlineRawDataButton() {

@ -1,14 +1,20 @@
package seng202.group9.GUI;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.web.WebView;
import seng202.group9.Controller.App;
import seng202.group9.Controller.Dataset;
import seng202.group9.Controller.SceneCode;
import seng202.group9.Core.Airport;
import seng202.group9.Core.Position;
import seng202.group9.Core.RoutePath;
import seng202.group9.Map.Map;
/**
* Created by michael on 14/09/2016.
@ -17,6 +23,8 @@ public class AirportSummaryController extends Controller{
@FXML
private TableView<Airport> tableView;
@FXML
private WebView mapView;
@FXML
private TableColumn<Airport, String> columnName;
@FXML
private TableColumn<Airport, String> columnCity;
@ -29,6 +37,8 @@ public class AirportSummaryController extends Controller{
private Dataset currentData = null;
private Map map;
public void airportRawDataButton() {
replaceSceneContent(SceneCode.AIRLINE_RAW_DATA);
}
@ -51,5 +61,13 @@ public class AirportSummaryController extends Controller{
columnAltitude.setCellValueFactory(new PropertyValueFactory<Airport, String>("Altitude"));
currentData = getParent().getCurrentDataset();
tableView.setItems(FXCollections.observableArrayList(currentData.getAirports()));
map = new Map(mapView, new RoutePath());
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Airport>() {
public void changed(ObservableValue<? extends Airport> observable, Airport oldValue, Airport newValue) {
System.out.println("loading");
Airport selectedAirport= currentData.getAirports().get(tableView.getSelectionModel().getSelectedIndices().get(0));
map.displayAirport(new RoutePath( new Position(selectedAirport.getLatitude(), selectedAirport.getLongitude())));
}
});
}
}

@ -116,7 +116,7 @@ public class FlightSummaryController extends Controller {
}
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
map.displayRoute(theDataSet.getFlightPaths().get(flightPathListView.getSelectionModel().getSelectedIndices().get(0)).getRoutePath());
//map.displayRoute(theDataSet.getFlightPaths().get(flightPathListView.getSelectionModel().getSelectedIndices().get(0)).getRoutePath());
}
});
}

@ -1,14 +1,20 @@
package seng202.group9.GUI;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.web.WebView;
import seng202.group9.Controller.App;
import seng202.group9.Controller.Dataset;
import seng202.group9.Controller.SceneCode;
import seng202.group9.Core.Position;
import seng202.group9.Core.Route;
import seng202.group9.Core.RoutePath;
import seng202.group9.Map.Map;
/**
* Created by michael on 14/09/2016.
@ -17,6 +23,8 @@ public class RouteSummaryController extends Controller{
@FXML
private TableView<Route> tableView;
@FXML
private WebView mapView;
@FXML
private TableColumn<Route, String> columnAirline;
@FXML
private TableColumn<Route, String> columnDepart;
@ -27,16 +35,39 @@ public class RouteSummaryController extends Controller{
@FXML
private TableColumn<Route, String> columnEquipment;
private Map map;
private Dataset currentData = null;
public void load() {
columnAirline.setCellValueFactory(new PropertyValueFactory<Route, String>("Airline"));
columnAirline.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineName"));
columnDepart.setCellValueFactory(new PropertyValueFactory<Route, String>("DepartureAirport"));
columnArrive.setCellValueFactory(new PropertyValueFactory<Route, String>("ArrivalAirport"));
columnStops.setCellValueFactory(new PropertyValueFactory<Route, String>("Stops"));
columnEquipment.setCellValueFactory(new PropertyValueFactory<Route, String>("Equipment"));
currentData = getParent().getCurrentDataset();
tableView.setItems(FXCollections.observableArrayList(currentData.getRoutes()));
map = new Map(mapView, new RoutePath());
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Route>() {
public void changed(ObservableValue<? extends Route> observable, Route oldValue, Route newValue) {
System.out.println("loading");
Route selectedRoute= currentData.getRoutes().get(tableView.getSelectionModel().getSelectedIndices().get(0));
if (selectedRoute.getSourceAirport() != null && selectedRoute.getDestinationAirport() != null) {
map.displayRoute(new RoutePath(
new Position(selectedRoute.getSourceAirport().getLatitude(), selectedRoute.getSourceAirport().getLongitude()),
new Position(selectedRoute.getDestinationAirport().getLatitude(), selectedRoute.getDestinationAirport().getLongitude())
));
}else if (selectedRoute.getSourceAirport() == null && selectedRoute.getDestinationAirport() != null){
map.displayAirport(new RoutePath(
new Position(selectedRoute.getDestinationAirport().getLatitude(), selectedRoute.getDestinationAirport().getLongitude())
));
}else if (selectedRoute.getSourceAirport() != null && selectedRoute.getDestinationAirport() == null){
map.displayAirport(new RoutePath(
new Position(selectedRoute.getSourceAirport().getLatitude(), selectedRoute.getSourceAirport().getLongitude())
));
}
}
});
}
public void routeRawDataButton() {
replaceSceneContent(SceneCode.ROUTE_RAW_DATA);

@ -35,6 +35,11 @@ public class Map {
webEngine.load(getClass().getClassLoader().getResource("map.html").toExternalForm());
}
public void displayAirport(RoutePath newRoute) {
String scriptToExecute = "displayAirport(" + newRoute.toJSONArray() + ");";
webEngine.executeScript(scriptToExecute);
}
public void displayRoute(RoutePath newRoute) {
String scriptToExecute = "displayRoute(" + newRoute.toJSONArray() + ");";
webEngine.executeScript(scriptToExecute);

@ -26,7 +26,7 @@
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 39.144684, lng: -84.510079},
zoom: 15
zoom: 5
});
new google.maps.Marker({
@ -39,7 +39,7 @@
function displayAirport(position){
map = new google.maps.Map(document.getElementById('map'), {
center: position[0],
zoom: 15
zoom: 5
});
new google.maps.Marker({
@ -50,6 +50,10 @@
}
function displayRoute(flightPath) {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 39.144684, lng: -84.510079},
zoom: 15
});
// CLEAR EXISTING MARKERS
if (marker1 !== undefined && marker2 !== undefined && path !== undefined) {
marker1.setMap(null);

Loading…
Cancel
Save