Merge remote-tracking branch 'origin/master'

Conflicts:
	src/main/java/seng202/group9/Controller/SceneCode.java
This commit is contained in:
Michael Wilson
2016-09-18 13:14:00 +12:00
29 changed files with 1452 additions and 219 deletions
@@ -83,7 +83,7 @@ public class AirportFilter extends Filter{
}
public void filterLatitude(String latitude){
String regexCode = "(?i).*"+latitude+".*";
String regexCode = ".*"+latitude+".*";
int index = 0;
while(index < filteredList.size()){
if (!String.valueOf(filteredList.get(index).getLatitude()).matches(regexCode)){
@@ -95,7 +95,7 @@ public class AirportFilter extends Filter{
}
public void filterLongitude(String longitude){
String regexCode = "(?i).*"+longitude+".*";
String regexCode = ".*"+longitude+".*";
int index = 0;
while(index < filteredList.size()){
if (!String.valueOf(filteredList.get(index).getLongitude()).matches(regexCode)){
@@ -107,7 +107,7 @@ public class AirportFilter extends Filter{
}
public void filterAltitude(String altitude){
String regexCode = "(?i).*"+altitude+".*";
String regexCode = ".*"+altitude+".*";
int index = 0;
while(index < filteredList.size()){
if (!String.valueOf(filteredList.get(index).getAltitude()).matches(regexCode)){
@@ -146,7 +146,7 @@ public class AirportFilter extends Filter{
String regexCode = "(?i).*"+DST+".*";
int index = 0;
while(index < filteredList.size()){
if (!filteredList.get(index).getCountry().getDST().matches(regexCode)){
if (!filteredList.get(index).getDST().matches(regexCode)){
filteredList.remove(index);
}else{
index++;
@@ -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();
}
}
@@ -1,6 +1,7 @@
package seng202.group9.Controller;
import javafx.scene.chart.PieChart;
import seng202.group9.Core.*;
import java.sql.Connection;
@@ -326,8 +327,8 @@ public class Dataset {
"`Heading` TEXT, " +
"`Altitude` INTEGER, " +
"`Tot_Dist` INTEGER, " +
"`Longitude` REAL, " +
"`Latitude` REAL, " +
"`Longitude` REAL, " +
"`Leg_Dist` INTEGER, " +
"`Order` INTEGER)";
stmt.execute(createFlightPointTable);
@@ -689,7 +690,7 @@ public class Dataset {
flightPathToAdd.setID(flightPathId);
//ADDED
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
" `Altitude`, `Longitude`, `Latitude`) VALUES ";
" `Altitude`, `Latitude`, `Longitude`) VALUES ";
int numOfFlights = 0;
for (int i = 0; i < flightPointsToImport.size(); i ++){
String flightPointIdentifier = flightPointsToImport.get(i).getType() + flightPointsToImport.get(i).getName() +
@@ -740,7 +741,7 @@ public class Dataset {
HashMap<String, Airline> airlineByIATA= new HashMap<String, Airline>();
//create Airline country link
for (Airline airline: airlines){
airlineByIATA.put(airline.getAlias(), airline);
airlineByIATA.put(airline.getIATA(), airline);
//System.out.println(airline.getAlias());
airline.setCountry(countryDictionary.get(airline.getCountryName()));
}
@@ -752,6 +753,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);
@@ -786,6 +788,15 @@ public class Dataset {
*/
public void addAirline(String name, String alias, String IATA, String ICAO, String callsign, String country, String active) throws DataException{
Airline airlineToAdd = new Airline(name, alias, IATA, ICAO, callsign, country, active);
if (name.equals("")) {
throw new DataException("You cannot have a blank airline name.");
}
if (alias.length() <= 0) {
throw new DataException("Please insert '\\N' if the airline has no alias.");
}
if (country.equals("")) {
throw new DataException("You cannot have a blank country of origin field.");
}
addAirline(airlineToAdd);
}
@@ -827,37 +838,51 @@ public class Dataset {
airlineToAdd.setID(airlineID);
airlines.add(airlineToAdd);
airlineDictionary.put(airlineToAdd.getName(), airlineToAdd);
stmt.close();
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
createDataLinks();
}
public void addAirport(String name, String city, String country, String IATA_FFA, String ICAO, String latitude, String longitude,
String altitude, String timezone, String DST, String olsonTz) throws DataException{
try{
//System.out.print(name + city + country + IATA_FFA + ICAO + latitude + longitude + altitude + timezone + DST + olsonTz);
double latitudeVal = Double.parseDouble(latitude);
double longitudeVal = Double.parseDouble(longitude);
double altitudeVal = Double.parseDouble(altitude);
double timezoneVal = Double.parseDouble(timezone);
if (city.equals("")) {
throw new DataException("You cannot have a blank city name.");
}
if (country.equals("")) {
throw new DataException("You cannot have a blank country name.");
}
Airport airportToAdd = new Airport(name, city, country, IATA_FFA, ICAO, latitudeVal, longitudeVal, altitudeVal);
City cityToAdd = new City(city, country, timezoneVal, olsonTz);
Country countryToAdd = new Country(DST, country);
addAirport(airportToAdd);
addCity(cityToAdd);
addCountry(countryToAdd);
createDataLinks();
}catch (NumberFormatException e){
throw new DataException("Latitude, Longitude, Altitude and Timezone must be numbers");
}
}
public void addAirport(Airport airportToAdd) throws DataException{
if (airportToAdd.getIATA_FFA() != "" && airportToAdd.getIATA_FFA().length() != 3){
if (airportToAdd.getIATA_FFA().length() != 0 && airportToAdd.getIATA_FFA().length() != 3){
throw new DataException("IATA/FFA either empty or 3 letters");
}
if (airportToAdd.getICAO() != "" && airportToAdd.getICAO().length() != 4){
if (airportToAdd.getICAO().length() != 0 && airportToAdd.getICAO().length() != 4){
throw new DataException("ICAO either empty or 4 letters");
}
if (airportToAdd.getName().equals("")) {
throw new DataException("You cannot have an airport without a name.");
}
for (String key : airportDictionary.keySet()){
airportDictionary.get(key).hasDuplicate(airportToAdd);
}
@@ -875,6 +900,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;";
@@ -886,6 +912,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);
@@ -910,6 +939,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);
@@ -934,6 +964,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);
@@ -1011,10 +1042,13 @@ public class Dataset {
//routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
String routeKey = routeToAdd.getAirline() + routeToAdd.getDepartureAirport() + routeToAdd.getArrivalAirport() + routeToAdd.getCode() + routeToAdd.getStops() + routeToAdd.getEquipment();
routeDictionary.put(routeKey, routeToAdd);
stmt.close();
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
createDataLinks();
}
/**
@@ -1120,7 +1154,7 @@ public class Dataset {
stmt = c.createStatement();
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
" `Altitude`, `Longitude`, `Latitude`, `Heading`, `Tot_Dist`, `Leg_Dist`, `Via`) VALUES ";
" `Altitude`, `Latitude`, `Longitude`, `Heading`, `Tot_Dist`, `Leg_Dist`, `Via`) VALUES ";
String flightType = type.replace("\"", "\"\"");
String flightName = name.replace("\"", "\"\"");
insertFlightPointQuery += "(" + id +", \""+ flightName +"\", \"" + flightType + "\", "+ altitudeVal + ", " +
@@ -1180,26 +1214,31 @@ public class Dataset {
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
//System.out.println(airline.getID());
String deleteQuery = "DELETE FROM `"+this.name+"_Airline` WHERE `Airline_ID` = " + airline.getID() + ";";
stmt = c.createStatement();
//System.out.println("Airline deleted");
stmt.execute(deleteQuery);
//System.out.println("Airline deleted");
stmt.close();
//System.out.println("Airline deleted");
stmt = c.createStatement();
//check if number of countries that contain airlines > 0 else delete the country
String countCountry = "SELECT COUNT(*) FROM `"+this.name+"_Airline` JOIN `"+this.name+"_Country` ON" +
" `"+this.name+"_Country`.`Country_Name` = `"+this.name+"_Airline`.`Country`" +
" WHERE `"+this.name+"_Airline`.`Country` = \""+airline.getCountry().getName().replace("\"", "\"\"")+"\"";
" WHERE `"+this.name+"_Airline`.`Country` = \""+airline.getCountryName().replace("\"", "\"\"")+"\"";
ResultSet countCountryRes = stmt.executeQuery(countCountry);
int countryCount = 0;
while (countCountryRes.next()){
countryCount += countCountryRes.getInt("COUNT(*)");
while (countCountryRes.next()) {
countryCount += countCountryRes.getInt("COUNT(*)");
}
countCountryRes.close();
stmt.close();
stmt = c.createStatement();
//check if number of counties that contain airports > 0 else delete the country
String countCountryA = "SELECT COUNT(*) FROM `"+this.name+"_Airport` JOIN `"+this.name+"_Country` ON" +
" `"+this.name+"_Country`.`Country_Name` = `"+this.name+"_Airport`.`Country`" +
" WHERE `"+this.name+"_Airport`.`Country` = \""+airline.getCountry().getName().replace("\"", "\"\"")+"\"";
" WHERE `"+this.name+"_Airport`.`Country` = \""+airline.getCountryName().replace("\"", "\"\"")+"\"";
countCountryRes = stmt.executeQuery(countCountryA);
while (countCountryRes.next()){
countryCount += countCountryRes.getInt("COUNT(*)");
@@ -1209,14 +1248,15 @@ public class Dataset {
//delete country if there are no matches
if (countryCount == 0){
stmt = c.createStatement();
String deleteCountry = "DELETE FROM `"+this.name+"_Country` WHERE `Country_Name` = \""+airline.getCountry().getName()+"\"";
String deleteCountry = "DELETE FROM `"+this.name+"_Country` WHERE `Country_Name` = \""+airline.getCountryName()+"\"";
stmt.execute(deleteCountry);
stmt.close();
}
c.close();
} catch ( Exception e ) {
e.printStackTrace();
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
//System.exit(0);
}
airlines.remove(airline);
}
@@ -73,7 +73,7 @@ public class RouteFilter extends Filter{
String regexCode = "(?i).*"+stops+".*";
int index = 0;
while(index < filteredList.size()){
if (!filteredList.get(index).getArrivalAirport().matches(regexCode)){
if (!String.valueOf(filteredList.get(index).getStops()).matches(regexCode)){
filteredList.remove(index);
}else{
index++;
+15 -3
View File
@@ -22,7 +22,7 @@ public class Airline{
private Country country = null;
/**
* Constructor
* Constructor for Airline when pulled from the database.
*
* @param ID
* @param name
@@ -45,7 +45,16 @@ public class Airline{
this.routes = new ArrayList<Route>();
}
/**
* Constructor for Airline without ID this will be set later by the dataset from the dataset.
* @param name
* @param alias
* @param IATA
* @param ICAO
* @param callSign
* @param countryName
* @param active
*/
public Airline(String name, String alias, String IATA, String ICAO, String callSign, String countryName, String active){
this.ID = -1;
this.IATA = IATA;
@@ -255,6 +264,9 @@ public class Airline{
if (this.name.equals(airline.getName())){
throw new DataException("This Airline Name already Exists, Please Choose Another.");
}
if (this.name.equals("")){
throw new DataException("This Airline Name cannot be Empty");
}
if (!this.IATA.equals("") && this.IATA.equals(airline.getIATA())){
throw new DataException("This IATA Code already Exists, Please Choose Another.");
}
@@ -273,7 +285,7 @@ public class Airline{
*/
@Override
public String toString(){
return name;
return name + ", IATA:" + IATA + ", ICAO: " + ICAO;
}
}
+34 -12
View File
@@ -89,6 +89,11 @@ public class Airport {
public void setID(int iD) {
this.ID = iD;
}
/**
* Sets the Name of the Airport.
* @param name
*/
public void setName(String name){
this.name = name;
}
@@ -148,10 +153,18 @@ public class Airport {
}
}
/**
* gets the country name
* @return
*/
public String getCountryName() {
return countryName;
}
/**
* sets the country name
* @param countryName
*/
public void setCountryName(String countryName) {
this.countryName = countryName;
}
@@ -194,13 +207,6 @@ public class Airport {
public String getICAO(){
return ICAO;
}
/**
* gets the IATA/FFA of the airport
* @return IATA/FFA Code
*/
// public String IATA_FFA(){
// return IATA_FFA;
// }
/**
* gets the altitude of the airport
* @return Altitude of Airport
@@ -254,7 +260,10 @@ public class Airport {
return country;
}
//JavaDoc needed
/**
* gets the timezone of the Airport
* @return
*/
public Double getTimezone() {
if (this.city != null) {
return this.city.getTimezone();
@@ -262,7 +271,11 @@ public class Airport {
return 0.0;
}
}
//JavaDoc needed
/**
* gets the DST of the Country the Airport is in.
* @return
*/
public String getDST() {
if (this.country != null) {
return this.country.getDST();
@@ -270,7 +283,11 @@ public class Airport {
return "";
}
}
//JavaDoc needed
/**
* gets the timezone in Olson format of the country the airport is in
* @return
*/
public String getTz() {
if (this.city != null) {
return this.city.getTimeOlson();
@@ -364,8 +381,14 @@ public class Airport {
distance = 6371 * c;
return distance;
}
/**
* Checks if the airport is a semi duplicate of this class. Used to see if it passes to enter into the Database.
* @param airport
* @throws DataException
*/
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)){
@@ -378,7 +401,6 @@ public class Airport {
/**
* Information of the airport returned in String format.
*/
@Override
public String toString(){
return this.cityName +" Airport has ICAO: "+this.ICAO+", IATA/FFA: "+this.IATA_FFA+" and is located at ("+this.latitude+", "+this.longitude
+69 -7
View File
@@ -8,7 +8,14 @@ public class City {
private double timezone;
private String timeOlson;
private ArrayList<Airport> airports;
/**
* City Constructor
* @param name
* @param country
* @param timezone
* @param timeOlson
*/
public City(String name, String country, double timezone, String timeOlson){
this.name = name;
this.country = country;
@@ -16,23 +23,43 @@ public class City {
this.timeOlson = timeOlson;
this.airports = new ArrayList<Airport>();
}
/**
* Sets Name of the City
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets Country that the city is in.
* @param country
*/
public void setCountry(String country){
this.country = country;
}
/**
* Set Timezone that the City is in.
* @param timezone
*/
public void setTimezone(double timezone) {
this.timezone = timezone;
}
/**
* Sets the time olson the city is in.
* @param timeOlson
*/
public void setTimeOlson(String timeOlson) {
this.timeOlson = timeOlson;
}
/**
* Sets the airports the are in the city
* @param airports
*/
public void setAirports(ArrayList<Airport> airports) {
this.airports = new ArrayList<Airport>();
for (int i = 0; i < airports.size(); i ++) {
@@ -40,46 +67,81 @@ public class City {
}
}
/**
* Gets the name of the city.
* @return
*/
public String getName(){
return name;
}
/**
* Gets the Country that the city is in.
* @return
*/
public String getCountry(){
return country;
}
/**
* gets the Timezone that the City is in.
* @return
*/
public double getTimezone(){
return timezone;
}
/**
* Gets the Timezone in Olson format the City is in.
* @return
*/
public String getTimeOlson(){
return timeOlson;
}
/**
* gets the Airports that are in this city.
* @return
*/
public ArrayList<Airport> getAirports(){
return airports;
}
/**
* adds an airport that is in this city.
* @param airport
*/
public void addAirport(Airport airport){
airports.add(airport);
}
/**
* adds multiple airports to this city.
* @param airports
*/
public void addAirport(ArrayList<Airport> airports){
for (int i = 0; i < airports.size(); i++){
addAirport(airports.get(i));
}
}
/**
* Deletes an Airport from this City.
* @param airport
*/
public void delAirport(Airport airport){
airports.remove(airport);
}
/**
* Deletes an Airport by Index from this City.
* @param index
*/
public void delAirport(int index) {
airports.remove(index);
}
@Override
public String toString(){
return this.name;
return this.name + " has " + airports.size() + " Airports and is in "+timeOlson;
}
}
+95 -5
View File
@@ -6,20 +6,38 @@ public class Country {
private String DST, name;
private ArrayList<City> cities = new ArrayList<City>();
private ArrayList<Airline> airlines = new ArrayList<Airline>();
private Position position;
/**
* Contructor for Country.
* @param DST
* @param name
*/
public Country(String DST, String name){
this.DST = DST;
this.name = name;
}
/**
* Sets the DST of the country.
* @param dST
*/
public void setDST(String dST) {
DST = dST;
}
/**
* Sets the name of the country.
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* Set Airlines that are based in this country.
* @param airlines
*/
public void setAirlines(ArrayList<Airline> airlines) {
this.airlines = new ArrayList<Airline>();
for (int i = 0; i < airlines.size(); i ++) {
@@ -27,36 +45,68 @@ public class Country {
}
}
/**
* Gets the DST of the Country.
* @return
*/
public String getDST(){
return this.DST;
}
/**
* Gets the Name of the Country.
* @return
*/
public String getName(){
return this.name;
}
/**
* gets the Airlines that belong in this Country.
* @return
*/
public ArrayList<Airline> getAirlines(){
return airlines;
}
/**
* Adds an Airline that is based in this country.
* @param airline
*/
public void addAirline(Airline airline){
this.airlines.add(airline);
}
/**
* Adds multiple Airlines to this Country.
* @param airlines
*/
public void addAirline(ArrayList<Airline> airlines){
for (int i = 0; i < airlines.size(); i++){
addAirline(airlines.get(i));
}
}
/**
* deletes an Airline based in this country.
* @param airline
*/
public void delAirline(Airline airline){
airlines.remove(airline);
}
/**
* deletes an Airline in this country.
* @param index
*/
public void delAirline(int index){
airlines.remove(index);
}
/**
* sets the cities of this country
* @param cities
*/
public void setCities(ArrayList<City> cities){
this.cities = new ArrayList<City>();
for (int i = 0; i < cities.size(); i++){
@@ -64,21 +114,61 @@ public class Country {
}
}
/**
* adds a City to this country.
* @param city
*/
public void addCities(City city){
this.cities.add(city);
}
/**
* Add multiple Cities to this Country.
* @param cities
*/
public void addCities(ArrayList<City> cities){
for (int i = 0; i < cities.size(); i++){
this.cities.add(cities.get(i));
}
}
/**
* Deletes a city for this country.
* @param city
*/
public void delCities(City city){
this.cities.remove(city);
}
/**
* Deletes Cities in this Country
* @param index
*/
public void delCities(int index){
this.cities.remove(index);
}
/**
* Gets the CIties in this Country.
* @return
*/
public ArrayList<City> getCities() {
return cities;
}
/**
* gets the {@link Position}(double Latitude, double Longitude) of this Country.
* @return
*/
public Position getPosition() {
return position;
}
/**
* sets the {@link Position} of the Country.
* @param position
*/
public void setPosition(Position position) {
this.position = position;
}
}
@@ -7,9 +7,10 @@ public class FlightPath {
private ArrayList<FlightPoint> flightPoints;
private String departureAirport;
private String arrivalAirport;
final private RoutePath routePath = new RoutePath();
/**
*
* Constructor for this FLight Path from database
* @param ID id of the the flight path in the database
* @param departureAirport Iata/FFA of the airport
* @param arrivalAirport IATA/FFA of the airport
@@ -21,17 +22,30 @@ public class FlightPath {
this.flightPoints = new ArrayList<FlightPoint>();
}
/**
* COnstructor for FlightPath from dataset add later the ID needs to be set from database.
* @param departureAirport
* @param arrivalAirport
*/
public FlightPath(String departureAirport, String arrivalAirport){
this.ID = -1;
this.departureAirport = departureAirport;
this.arrivalAirport = arrivalAirport;
this.flightPoints = new ArrayList<FlightPoint>();
}
/**
* Gets the {@link FlightPoint} of this flight Path.
* @return
*/
public ArrayList<FlightPoint> getFlightPoints() {
return flightPoints;
}
/**
* Sets the {@link FlightPoint} of this Flight Path.
* @param flightPoints
*/
public void setFlightPoints(ArrayList<FlightPoint> flightPoints) {
this.flightPoints = new ArrayList<FlightPoint>();
for (int i = 0; i < flightPoints.size(); i ++) {
@@ -39,53 +53,118 @@ public class FlightPath {
}
}
/**
* Sets the {@link Airport} that the Flight Path leaves from.
* @param departureAirport
*/
public void setDepartureAirport(String departureAirport) {
this.departureAirport = departureAirport;
}
/**
* Sets the {@link Airport} that the Flight Path arrives at.
* @param arrivalAirport
*/
public void setArrivalAirport(String arrivalAirport) {
this.arrivalAirport = arrivalAirport;
}
/**
* Sets the ID that corresponds to the database for this flight path.
* Also the ID that corresponds to {@see FlightPoint} IndexID
* @param iD
*/
public void setID(int iD) {
ID = iD;
}
/**
* gets the ID of the Flight Path.
* @return
*/
public int getID(){
return ID;
}
/**
* gets the {@link Airport} that the FLight Departs from.
* @return
*/
public String departsFrom(){
return departureAirport;
}
/**
* gets the {@link Airport} that the flight arrives at.
* @return
*/
public String arrivesAt(){
return arrivalAirport;
}
/**
* Gets all the Points that the FLight passes
* {@link FlightPoint}
* @return
*/
public ArrayList<FlightPoint> getFlight(){
return flightPoints;
}
/**
* Adds a {@link FlightPoint} to the Flight Path.
* @param flightPoint
*/
public void addFlightPoint(FlightPoint flightPoint){
flightPoints.add(flightPoint);
}
/**
* Adds a {@link FlightPoint} to the Flight Path at a specific point of the flight.
* @param flightPoint
* @param index
*/
public void addFlightPoint(FlightPoint flightPoint, int index){
flightPoints.add(index, flightPoint);
}
/**
* deletes a point from the flight.
* @param flightPoint
*/
public void delFlightPoint(FlightPoint flightPoint){
flightPoints.remove(flightPoint);
}
/**
* delets a point from the flight at a specific index.
* @param index
*/
public void delFlightPoint(int index){
flightPoints.remove(index);
}
/**
* Adds multiple {@link FlightPoint} to the FlightPath.
* @param flightPoints
*/
public void addFlightPoint(ArrayList<FlightPoint> flightPoints){
for (int i = 0; i < flightPoints.size(); i ++){
this.flightPoints.add(flightPoints.get(i));
}
}
/**
* Gets the {@link RoutePath} that the FlightPath traverses.
* Also see {@see seng202.group9.Map.Map}
* @return
*/
public RoutePath getRoutePath(){
if (routePath.getRoute().size() == 0){
for (FlightPoint point: flightPoints){
routePath.addPosition(new Position(point.getLatitude(), point.getLongitude()));
}
}
return routePath;
}
}
@@ -15,6 +15,14 @@ public class FlightPoint {
private double latitude;
private double longitude;
/**
* Constructor for FLight POint before set by the database.
* @param type
* @param name
* @param altitude
* @param latitude
* @param longitude
*/
public FlightPoint(String type, String name, double altitude, double latitude, double longitude){
//extra calculations will have to be used to find heading, legdistance and total distance. If necessary
//Type 1 file the file the lecturers gave us
@@ -33,6 +41,20 @@ public class FlightPoint {
this.longitude = longitude;
}
/**
* Constructor when getting points from the database.
* @param name Name for the point.
* @param ID Unique ID from Database.
* @param indexID FOreighn key for {@link FlightPath}.
* @param type
* @param via
* @param heading
* @param altitude
* @param legDistance
* @param totalDistance
* @param latitude
* @param longitude
*/
public FlightPoint(String name, int ID, int indexID, String type, String via,
int heading, double altitude, double legDistance, double totalDistance,
double latitude, double longitude){
@@ -49,6 +71,11 @@ public class FlightPoint {
this.longitude = longitude;
}
/**
* get the Path ID
* @return
* @throws DataException
*/
public int getIndexID() throws DataException {
if (this.ID == -1){
throw new DataException("ID not set.");
@@ -57,54 +84,107 @@ public class FlightPoint {
}
}
/**
* sets the Path ID
* @param indexID
*/
public void setIndexID(int indexID) {
this.indexID = indexID;
}
/**
* sets the name of the path.
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* sets the Unique Database ID of the Path
* @param iD
*/
public void setID(int iD) {
ID = iD;
}
/**
* Sets the type of the Point.
* @param type
*/
public void setType(String type) {
this.type = type;
}
/**
* set the VIA of the Point.
* @param via
*/
public void setVia(String via) {
this.via = via;
}
/**
* Sets bearing the flight is heading.
* @param heading
*/
public void setHeading(int heading) {
this.heading = heading;
}
/**
* sets the altitude of the flight at this point.
* @param altitude
*/
public void setAltitude(double altitude) {
this.altitude = altitude;
}
/**
* sets the distance this flight takes before the next point.
* @param legDistance
*/
public void setLegDistance(double legDistance) {
this.legDistance = legDistance;
}
/**
* sets total distance travelled at this point.
* @param totalDistance
*/
public void setTotalDistance(double totalDistance) {
this.totalDistance = totalDistance;
}
/**
* sets the latitude at this point.
* @param latitude
*/
public void setLatitude(double latitude) {
this.latitude = latitude;
}
/**
* Sets the Longitude at this point.
* @param longitude
*/
public void setLongitude(double longitude) {
this.longitude = longitude;
}
/**
* gets the name of this point.
* @return
*/
public String getName(){
return name;
}
/**
* gets the UNIQUE ID at this point.
* @return
* @throws DataException
*/
public int getID() throws DataException {
if (this.ID == -1){
throw new DataException("ID not set.");
@@ -112,39 +192,75 @@ public class FlightPoint {
return ID;
}
}
/**
* gets the Path Index ID at this point.
* @return
*/
public int getIndex(){
return indexID;
}
/**
* gets the type of this point.
* @return
*/
public String getType(){
return type;
}
/**
* gets where the plane is via at this point.
* @return
*/
public String getVia(){
return via;
}
/**
* gets the Heading bearing at this point
* @return
*/
public int getHeading(){
return heading;
}
/**
* gets the altitude at this poitn.
* @return
*/
public double getAltitude(){
return altitude;
}
/**
* gets the leg distance at this point.
* @return
*/
public double getLegDistance(){
return legDistance;
}
/**
* gets total distance travelled by this flight so far.
* @return
*/
public double getTotalDistance(){
return totalDistance;
}
/**
* gets longitude of this point.
* @return
*/
public double getLongitude(){
return longitude;
}
/**
* gets the latitude of this point.
* @return
*/
public double getLatitude(){
return latitude;
}
@@ -0,0 +1,14 @@
package seng202.group9.Core;
/**
* Created by fwy13 on 17/09/16.
*/
public class Position {
public double lat;
public double lng;
public Position(double lat, double lng) {
this.lat = lat;
this.lng = lng;
}
}
+38 -3
View File
@@ -18,6 +18,7 @@ public class Route {
private Airport sourceAirport;
private Airport destinationAirport;
private Airline airline = null;
private RoutePath routePath = null;
/**
* Constructor for pulling from database
@@ -120,15 +121,25 @@ public class Route {
return ID;
}
}
//JavaDoc needed
/**
* Gets this ID of the Airline.
* @return
* @throws DataException
*/
public int getAirlineID() throws DataException {
if (this.airline != null) {
if (this.getAirline() != null) {
return this.getAirline().getID();
}else {
return 0;
}
}
/**
* Gets the ID of the Airport that the Route leaves from.
* @return
* @throws DataException
*/
public int getSourceID() throws DataException {
if (this.getSourceAirport() != null) {
return this.getSourceAirport().getID();
@@ -137,6 +148,11 @@ public class Route {
}
}
/**
* gets the destination ID of the Airport the Route is arriving at.
* @return
* @throws DataException
*/
public int getDestID() throws DataException {
if (this.getDestinationAirport() != null) {
return this.getDestinationAirport().getID();
@@ -240,12 +256,31 @@ public class Route {
*/
public void hasDuplicate(Route route) throws DataException{
//routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
if (route.getAirline().equals(this.airline) && route.getDepartureAirport().equals(this.departureAirport)
if (route.getAirlineName().equals(this.airlineName) && route.getDepartureAirport().equals(this.departureAirport)
&& route.getArrivalAirport().equals(this.arrivalAirport) && route.getCode().equals(this.codeShare)
&& route.getStops() == this.stops && route.getEquipment().equals(this.equipment)){
throw new DataException("This Route already exists.");
}
}
/**
* gets the RoutePath to be passed into {@link seng202.group9.Map.Map}.
* @return
*/
public RoutePath getRoutePath(){
if (routePath == null) {
routePath = new RoutePath(
new Position(getSourceAirport().getLatitude(), getSourceAirport().getLongitude()),
new Position(getDestinationAirport().getLatitude(), getDestinationAirport().getLongitude())
);
}
return routePath;
}
/**
* What to print if printed as a string.
* @return
*/
@Override
public String toString(){
@@ -0,0 +1,59 @@
package seng202.group9.Core;
import java.util.ArrayList;
import java.util.Collections;
/**
* Created by brad on 9/09/16.
* Edited by fwy13
*/
public class RoutePath {
private ArrayList<Position> route = new ArrayList<Position>();
/**
* Route Path constructor when the user knows the points.
* @param points
*/
public RoutePath(Position ...points) {
Collections.addAll(route, points);
}
/**
* Route Path constructor when the user doesn't know the points.
*/
public RoutePath(){
}
/**
* adds a {@link Position} to the RoutePath.
* @param position
*/
public void addPosition(Position position){
route.add(position);
}
/**
* Gets the RoutePath positions.
* @return
*/
public ArrayList<Position> getRoute() {
return route;
}
/**
* Converts the RoutePath to an Array in JSON which can then be passed to the Map to display.
* @return
*/
public String toJSONArray() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("[");
for (Position pos : route){
stringBuilder.append(
String.format("{lat: %f, lng: %f}, ", pos.lat, pos.lng));
}
stringBuilder.append("]");
return stringBuilder.toString();
}
}
@@ -1,25 +1,22 @@
package seng202.group9.GUI;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import seng202.group9.Controller.App;
import seng202.group9.Controller.AirlineFilter;
import seng202.group9.Controller.Dataset;
import seng202.group9.Core.Airline;
import java.net.URL;
import java.util.ResourceBundle;
/**
* The GUI controller class for airline_raw_data.fxml.
* Extends from the abstract class {@link Controller}.
* Created by Sunguin on 2016/09/13.
*/
public class AirlineRDController extends Controller {
@FXML
private TableView<Airline> tableView;
private TableView<Airline> tableViewAirlineRD;
@FXML
private TableColumn<Airline, String> airlIDcol;
@FXML
@@ -36,6 +33,7 @@ public class AirlineRDController extends Controller {
private TableColumn<Airline, String> airlCountrycol;
@FXML
private TableColumn<Airline, String> airlActivecol;
@FXML
private TextField airlNameBox;
@FXML
@@ -49,13 +47,51 @@ public class AirlineRDController extends Controller {
@FXML
private TextField airlCountryBox;
@FXML
//private TextField airlActiveBox;
private ComboBox<String> airlActiveCBox;
@FXML
private TextField airlNameFilter;
@FXML
private TextField airlAliasFilter;
@FXML
private TextField airlIATAFilter;
@FXML
private TextField airlICAOFilter;
@FXML
private TextField airlCallsignFilter;
@FXML
private TextField airlCountryFilter;
@FXML
private TextField airlActiveFilter;
private Dataset theDataSet = null;
//Dummy function to test the add button.
//Will edit when ID is added automatically.
/**
* Loads the initial airline data to the GUI table.
* Also sets up the dropdown menu options.
*/
public void load() {
airlIDcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ID"));
airlNamecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Name"));
airlAliascol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Alias"));
airlIATAcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("IATA"));
airlICAOcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ICAO"));
airlCallsigncol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CallSign"));
airlCountrycol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CountryName"));
airlActivecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Active"));
theDataSet = getParent().getCurrentDataset();
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
airlActiveCBox.setValue("Y");
airlActiveCBox.getItems().addAll("Y", "N");
}
/**
* Adds a single airline entry to the database.
* Takes in values from the GUI the user has typed in.
* @see Dataset
*/
public void addAirlineSingle() {
try {
theDataSet.addAirline(
@@ -73,7 +109,8 @@ public class AirlineRDController extends Controller {
airlCallsignBox.clear();
airlCountryBox.clear();
airlActiveCBox.getSelectionModel().clearSelection();
tableView.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
airlActiveCBox.setValue("Y");
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
} catch ( Exception e ) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Airline Data Error");
@@ -83,21 +120,46 @@ public class AirlineRDController extends Controller {
}
}
public void load() {
airlIDcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ID"));
airlNamecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Name"));
airlAliascol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Alias"));
//Need to check IATA and ICAO
airlIATAcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("IATA"));
airlICAOcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ICAO"));
airlCallsigncol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CallSign"));
airlCountrycol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CountryName"));
airlActivecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Active"));
theDataSet = getParent().getCurrentDataset();
tableView.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
//ObservableList<String> activeOptions= FXCollections.observableArrayList("Y", "N");
airlActiveCBox.getItems().addAll("Y", "N");
/**
* Deletes a single selected airline entry from the database.
* Updates the GUI accordingly.
* @see Dataset
*/
public void deleteAirline() {
Airline toDelete = tableViewAirlineRD.getSelectionModel().getSelectedItem();
theDataSet.deleteAirline(toDelete);
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
}
/**
* Filters airlines by any field.
* These are specified by what the user has typed in the filter boxes.
* Updates the GUI accordingly.
* @see AirlineFilter
*/
public void filterAirlines() {
AirlineFilter filter = new AirlineFilter(theDataSet.getAirlines());
if (airlNameFilter.getText() != null) {
filter.filterName(airlNameFilter.getText());
}
if (airlAliasFilter.getText() != null) {
filter.filterAlias(airlAliasFilter.getText());
}
if (airlIATAFilter.getText() != null) {
filter.filterIATA(airlIATAFilter.getText());
}
if (airlICAOFilter.getText() != null) {
filter.filterICAO(airlICAOFilter.getText());
}
if (airlCallsignFilter.getText() != null) {
filter.filterCallsign(airlCallsignFilter.getText());
}
if (airlCountryFilter.getText() != null) {
filter.filterCountry(airlCountryFilter.getText());
}
if (airlActiveFilter.getText() != null) {
filter.filterActive(airlActiveFilter.getText());
}
tableViewAirlineRD.setItems(FXCollections.<Airline>observableArrayList(filter.getFilteredData()));
}
}
@@ -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,26 +1,19 @@
package seng202.group9.GUI;
import com.sun.javafx.collections.ObservableListWrapper;
import javafx.beans.InvalidationListener;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableStringValue;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.util.Callback;
import seng202.group9.Controller.App;
import seng202.group9.Controller.AirportFilter;
import seng202.group9.Controller.Dataset;
import seng202.group9.Controller.SceneCode;
import seng202.group9.Core.Airport;
import seng202.group9.Core.City;
import seng202.group9.Core.Country;
import static javafx.collections.FXCollections.observableArrayList;
/**
* The GUI controller class for airport_raw_data.fxml.
* Extends from the abstract class {@link Controller}.
* Created by Sunguin on 2016/09/13.
*/
public class AirportRDController extends Controller{
@@ -75,8 +68,35 @@ public class AirportRDController extends Controller{
@FXML
private TextField airpTzBox;
@FXML
private TextField airpNameFilter;
@FXML
private TextField airpCityFilter;
@FXML
private TextField airpCountryFilter;
@FXML
private TextField airpIATAFFAFilter;
@FXML
private TextField airpICAOFilter;
@FXML
private TextField airpLatitudeFilter;
@FXML
private TextField airpLongitudeFilter;
@FXML
private TextField airpAltitudeFilter;
@FXML
private TextField airpTimezoneFilter;
@FXML
private TextField airpDSTFilter;
@FXML
private TextField airpTzFilter;
private Dataset theDataSet = null;
/**
* Loads the initial airport data to the GUI table.
* Also sets up the dropdown menu options.
*/
public void load() {
airpIDcol.setCellValueFactory(new PropertyValueFactory<Airport, String>("ID"));
airpNamecol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Name"));
@@ -91,29 +111,18 @@ public class AirportRDController extends Controller{
airpDSTcol.setCellValueFactory(new PropertyValueFactory<Airport, String>("DST"));
airpTzcol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Tz"));
// airpTimezonecol.setCellFactory(new Callback<TableColumn<Airport, String>, TableCell<Airport, String>>() {
//
// @Override
// public TableCell<Airport, City> call(TableColumn<Airport, City> param) {
// TableCell<Airport, City> timeZoneCell = new TableCell<Airport, City>() {
// @Override
// protected void updateItem(City timezone, boolean empty) {
// if (timezone != null) {
// Label timeZoneLabel = new Label(timezone.getTimeOlson());
// setGraphic(timeZoneLabel);
// }
// }
// };
//
// return timeZoneCell;
// }
// });
theDataSet = getParent().getCurrentDataset();
tableViewAirportRD.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
tableViewAirportRD.setItems(observableArrayList(theDataSet.getAirports()));
airpDSTCBox.setValue("E");
airpDSTCBox.getItems().addAll("E", "A", "S", "O", "Z", "N", "U");
}
/**
* Adds a single airport entry in the database.
* Takes in values from the GUI the user has typed in.
* @see Dataset
*/
public void addAirportSingle() {
try {
theDataSet.addAirport(
@@ -137,6 +146,7 @@ public class AirportRDController extends Controller{
airpAltitudeBox.clear();
airpTimezoneBox.clear();
airpDSTCBox.getSelectionModel().clearSelection();
airpDSTCBox.setValue("E");
airpTzBox.clear();
tableViewAirportRD.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
} catch ( Exception e ) {
@@ -147,7 +157,63 @@ public class AirportRDController extends Controller{
alert.showAndWait();
}
}
public void airportAnalyserButton(){
public void airportAnalyserButton() {
replaceSceneContent(SceneCode.AIRPORT_ANALYSER);
}
/**
* Deletes a single selected airport entry from the database.
* Updates the GUI accordingly.
* @see Dataset
*/
public void deleteAirport(){
Airport toDelete = tableViewAirportRD.getSelectionModel().getSelectedItem();
theDataSet.deleteAirport(toDelete);
tableViewAirportRD.setItems(observableArrayList(theDataSet.getAirports()));
}
/**
* Filters the airports table by any field.
* These are specified by what the user has typed in the filter boxes.
* Updates the GUI accordingly.
* @see AirportFilter
*/
public void filterAirports() {
AirportFilter filter = new AirportFilter(theDataSet.getAirports());
if (airpNameFilter.getText() != null) {
filter.filterName(airpNameFilter.getText());
}
if (airpCityFilter.getText() != null) {
filter.filterCity(airpCityFilter.getText());
}
if (airpCountryFilter.getText() != null) {
filter.filterCountry(airpCountryFilter.getText());
}
if (airpIATAFFAFilter.getText() != null) {
filter.filterIATA_FFA(airpIATAFFAFilter.getText());
}
if (airpICAOFilter.getText() != null) {
filter.filterICAO(airpICAOFilter.getText());
}
if (airpLatitudeFilter.getText() != null) {
filter.filterLatitude(airpLatitudeFilter.getText());
}
if (airpLongitudeFilter.getText() != null) {
filter.filterLongitude(airpLongitudeFilter.getText());
}
if (airpAltitudeFilter.getText() != null) {
filter.filterAltitude(airpAltitudeFilter.getText());
}
if (airpTimezoneFilter.getText() != null) {
filter.filterTimezone(airpTimezoneFilter.getText());
}
if (airpDSTFilter.getText() != null) {
filter.filterDST(airpDSTFilter.getText());
}
if (airpTzFilter.getText() != null) {
filter.filterOlson(airpTzFilter.getText());
}
tableViewAirportRD.setItems(FXCollections.<Airport>observableArrayList(filter.getFilteredData()));
}
}
@@ -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())));
}
});
}
}
@@ -17,6 +17,7 @@ import javax.swing.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.ResourceBundle;
/**
@@ -179,7 +180,7 @@ public class FlightRDController extends Controller {
}
/**
* Creates a pop up dialog which prompts the user for two ICAO airport codes which will use when creating a new path
* Creates a pop up dialog which prompts the user for two ICAO airport codes which will use when creating a new path.
*/
public void newPath() {
NewPathPopUp dialogBox = new NewPathPopUp();
@@ -193,7 +194,43 @@ public class FlightRDController extends Controller {
flightPathListView();
}
}
/**
* Removes the selected point from the table and database.
*/
public void deletePoint() {
FlightPoint toDelete = flightTableView.getSelectionModel().getSelectedItem();
int pathID = toDelete.getIndex();
LinkedHashMap<Integer, FlightPath> flightPathDict = theDataSet.getFlightPathDictionary();
FlightPath toDeletesPath = flightPathDict.get(pathID);
theDataSet.deleteFlightPoint(toDelete, toDeletesPath);
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary().get(pathID));
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
}
/**
* Removes the selected path from the list view of paths and from the database.
*/
public void deletePath() {
String toDeleteStr = flightPathListView.getSelectionModel().getSelectedItem();
String[] segments = toDeleteStr.split("_");
String pathIdClicked = segments[0];
int toDeleteIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
.get(Integer.parseInt(pathIdClicked)));
theDataSet.deleteFlightPath(toDeleteIndex);
flightPathListView.getItems().clear();
flightPathListView();
}
/**
* Will link to the flight analyser when implemented.
*/
public void flightAnalyser(){
JOptionPane.showMessageDialog(null, "This is not Implemented yet");
}
@@ -1,15 +1,23 @@
package seng202.group9.GUI;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.input.MouseEvent;
import javafx.scene.web.WebView;
import seng202.group9.Controller.App;
import seng202.group9.Controller.Dataset;
import seng202.group9.Controller.SceneCode;
import seng202.group9.Core.FlightPath;
import seng202.group9.Core.RoutePath;
import seng202.group9.Map.Map;
import seng202.group9.Core.FlightPoint;
import java.net.URL;
import java.util.ArrayList;
@@ -23,30 +31,67 @@ public class FlightSummaryController extends Controller {
private Dataset theDataSet = null;
private int currentPathId = 0;
private int currentPathIndex = 0;
@FXML
private Button flightRawData;
private Map map;
@FXML
private WebView mapView;
@FXML
ListView<String> flightPathListView;
final ObservableList<String> flightList = FXCollections.observableArrayList();
/**
* Changes to the Flight Raw Data Scene when the Raw Data Button is clicked
* Changes to the Flight Raw Data Scene when the Raw Data Button is clicked.
*/
public void handleRawDataButton() {
replaceSceneContent(SceneCode.FLIGHT_RAW_DATA);
}
public void airportSummaryButton() {
replaceSceneContent(SceneCode.AIRPORT_SUMMARY);
}
/**
* Changes to the Airport Summary Scene when the Airport is clicked.
*/
public void airportSummaryButton() { replaceSceneContent(SceneCode.AIRPORT_SUMMARY); }
/**
* Changes to the Route Summary Scene when the Route Button is clicked.
*/
public void routeSummaryButton() {
replaceSceneContent(SceneCode.ROUTE_SUMMARY);
}
/**
* Changes to the Airline Summary Scene when the Airline Button is clicked.
*/
public void airlineSummaryButton() {
replaceSceneContent(SceneCode.AIRLINE_SUMMARY);
}
/**
* Loads the Flight paths into the List View and waits for a mouse clicked event for which it will update the table
* to display the selected Flight paths points. Called from the MenuController.
*/
public void flightPathListView() {
try {
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
for(int i = 0; i<flightPaths.size(); i++ ) {
int pathID = flightPaths.get(i).getID();
String pathSource = flightPaths.get(i).departsFrom();
String pathDestin = flightPaths.get(i).arrivesAt();
String flightPathDisplayName = Integer.toString(pathID) + "_" + pathSource + "_" + pathDestin;
flightList.add(flightPathDisplayName);
}
flightPathListView.setItems(flightList);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Used to load the page from the MenuController.
*/
public void load() {
try {
theDataSet = getParent().getCurrentDataset();
@@ -64,6 +109,32 @@ public class FlightSummaryController extends Controller {
} catch (Exception e) {
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>() {
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
//map.displayRoute(theDataSet.getFlightPaths().get(flightPathListView.getSelectionModel().getSelectedIndices().get(0)).getRoutePath());
}
});
}
/**
* Removes the selected path from the list view of paths and from the database.
*/
public void deletePath() {
String toDeleteStr = flightPathListView.getSelectionModel().getSelectedItem();
String[] segments = toDeleteStr.split("_");
String pathIdClicked = segments[0];
int toDeleteIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
.get(Integer.parseInt(pathIdClicked)));
theDataSet.deleteFlightPath(toDeleteIndex);
flightPathListView.getItems().clear();
flightPathListView();
}
}
@@ -4,12 +4,14 @@ import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import seng202.group9.Controller.App;
import seng202.group9.Controller.Dataset;
import seng202.group9.Controller.SceneCode;
import seng202.group9.Controller.RouteFilter;
import seng202.group9.Core.Route;
/**
* The GUI controller class for route_raw_data.fxml.
* Extends from the abstract class {@link Controller}.
* Created by Sunguin on 2016/09/14.
*/
public class RouteRDController extends Controller {
@@ -48,34 +50,25 @@ public class RouteRDController extends Controller {
@FXML
private TextField rEquipmentBox;
@FXML
private TextField rAirlineFilter;
@FXML
private TextField rSourceFilter;
@FXML
private TextField rDestFilter;
@FXML
private TextField rCodeshareFilter;
@FXML
private TextField rStopsFilter;
@FXML
private TextField rEquipmentFilter;
private Dataset theDataSet = null;
public void addRouteSingle() {
try {
theDataSet.addRoute(
rAirlineBox.getText(),
rSourceBox.getText(),
rDestBox.getText(),
rCodeshareCBox.getSelectionModel().getSelectedItem().toString(),
rStopsBox.getText(),
rEquipmentBox.getText()
);
rAirlineBox.clear();
rSourceBox.clear();
rDestBox.clear();
rCodeshareCBox.getSelectionModel().clearSelection();
rStopsBox.clear();
rEquipmentBox.clear();
tableViewRouteRD.setItems(FXCollections.observableArrayList(theDataSet.getRoutes()));
} catch ( Exception e ) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Route Data Error");
alert.setHeaderText("Error adding a custom route entry.");
alert.setContentText(e.getMessage());
alert.showAndWait();
}
}
/**
* Loads the initial route data to the GUI table.
* Also sets up the dropdown menu options.
*/
public void load() {
rAirlineCol.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineName"));
rAirlineIDCol.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineID"));
@@ -90,9 +83,82 @@ public class RouteRDController extends Controller {
theDataSet = getParent().getCurrentDataset();
tableViewRouteRD.setItems(FXCollections.observableArrayList(theDataSet.getRoutes()));
rCodeshareCBox.setValue("");
rCodeshareCBox.getItems().addAll("Y", "");
}
/**
* Adds a single route entry in the database.
* Takes in values from the GUI the user has typed in.
* @see Dataset
*/
public void addRouteSingle() {
try {
theDataSet.addRoute(
rAirlineBox.getText(),
rSourceBox.getText(),
rDestBox.getText(),
rCodeshareCBox.getSelectionModel().getSelectedItem().toString(),
rStopsBox.getText(),
rEquipmentBox.getText()
);
rAirlineBox.clear();
rSourceBox.clear();
rDestBox.clear();
rCodeshareCBox.getSelectionModel().clearSelection();
rCodeshareCBox.setValue("");
rStopsBox.clear();
rEquipmentBox.clear();
tableViewRouteRD.setItems(FXCollections.observableArrayList(theDataSet.getRoutes()));
} catch ( Exception e ) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Route Data Error");
alert.setHeaderText("Error adding a custom route entry.");
alert.setContentText(e.getMessage());
alert.showAndWait();
}
}
/**
* Deletes a single selected route entry from the database.
* Updates the GUI accordingly.
* @see Dataset
*/
public void deleteRoute(){
Route toDelete = tableViewRouteRD.getSelectionModel().getSelectedItem();
theDataSet.deleteRoute(toDelete);
tableViewRouteRD.setItems(FXCollections.observableArrayList(theDataSet.getRoutes()));
}
/**
* Filters the routes table by any field.
* These are specified by what the user has typed in the filter boxes.
* Updates the GUI accordingly.
* @see RouteFilter
*/
public void filterRoutes(){
RouteFilter filter = new RouteFilter(theDataSet.getRoutes());
if (rAirlineFilter.getText() != null) {
filter.filterAirline(rAirlineFilter.getText());
}
if (rSourceFilter.getText() != null) {
filter.filterSourceAirport(rSourceFilter.getText());
}
if (rDestFilter.getText() != null) {
filter.filterDestinationAirport(rDestFilter.getText());
}
if (rCodeshareFilter.getText() != null) {
filter.filterCodeshare(rCodeshareFilter.getText());
}
if (rStopsFilter.getText() != null) {
filter.filterDestinationStops(rStopsFilter.getText());
}
if (rEquipmentFilter.getText() != null) {
filter.filterEquipment(rEquipmentFilter.getText());
}
tableViewRouteRD.setItems(FXCollections.<Route>observableArrayList(filter.getFilteredData()));
}
public void analyse_Button() {
replaceSceneContent(SceneCode.ROUTE_ANALYSER);
}
@@ -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);
+48
View File
@@ -0,0 +1,48 @@
package seng202.group9.Map;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import seng202.group9.Core.Position;
import seng202.group9.Core.RoutePath;
/**
* Created by fwy13 on 17/09/16.
*/
public class Map {
private WebEngine webEngine;
private WebView webView;
private boolean canLoad = false;
public Map(WebView webView, final RoutePath newRoute){
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);
}
}
});
}
public void initMap() {
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);
}
}