Added Routes By Equipment
This commit is contained in:
@@ -4,6 +4,7 @@ package seng202.group9.Controller;
|
||||
import javafx.scene.chart.PieChart;
|
||||
import javafx.scene.control.Alert;
|
||||
import seng202.group9.Core.*;
|
||||
import sun.awt.image.ImageWatched;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
@@ -31,6 +32,7 @@ public class Dataset {
|
||||
private LinkedHashMap<String, Country> countryDictionary;//key name
|
||||
private LinkedHashMap<String, City> cityDictionary;//key city name
|
||||
private LinkedHashMap<Integer, FlightPoint> flightPointDictionary;//key point id
|
||||
private LinkedHashMap<String, Equipment> equipmentDictionary;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -53,6 +55,7 @@ public class Dataset {
|
||||
this.cityDictionary = new LinkedHashMap<String, City>();;
|
||||
this.flightPathDictionary = new LinkedHashMap<Integer, FlightPath>();
|
||||
this.flightPointDictionary = new LinkedHashMap<Integer, FlightPoint>();
|
||||
this.equipmentDictionary = new LinkedHashMap<>();
|
||||
if (action == getExisting){
|
||||
updateDataset();
|
||||
//after this make connections. ie filling in the country.cities airports.routes etc
|
||||
@@ -783,8 +786,22 @@ public class Dataset {
|
||||
airport.setDepartureRoutes(new ArrayList<Route>());
|
||||
airport.setArrivalRoutes(new ArrayList<Route>());
|
||||
}
|
||||
equipmentDictionary = new LinkedHashMap<>();
|
||||
//set Airport variables for route
|
||||
for (Route route: routes){
|
||||
String[] equipment = route.getEquipment().split(" ");
|
||||
for (String equip: equipment){
|
||||
if (equip != "" && equip != null){
|
||||
Equipment equipment1 = equipmentDictionary.get(equip);
|
||||
if (equipment1 != null){
|
||||
equipment1.addRoute(route);
|
||||
}else{
|
||||
equipment1 = new Equipment(equip);
|
||||
equipment1.addRoute(route);
|
||||
equipmentDictionary.put(equip, equipment1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (route.getDepartureAirport().length() > 3){
|
||||
route.setSourceAirport(airportsByICAO.get(route.getDepartureAirport()));
|
||||
if (airportsByICAO.get(route.getDepartureAirport()) != null) {
|
||||
@@ -1727,6 +1744,10 @@ public class Dataset {
|
||||
return cityDictionary;
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, Equipment> getEquipmentDictionary() {
|
||||
return equipmentDictionary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits Airline and commits them to the database.
|
||||
* @param index
|
||||
|
||||
@@ -13,7 +13,7 @@ public enum SceneCode {
|
||||
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_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");
|
||||
FLIGHT_ADD("flight_add_form.fxml"), ROUTE_BY_AIRPORT("airport_map_routes.fxml"), ROUTE_BY_EQUIP("route_by_equip.fxml");
|
||||
|
||||
|
||||
private String filePath;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package seng202.group9.Core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Created by fwy13 on 2/10/16.
|
||||
*/
|
||||
public class Equipment {
|
||||
private String name;
|
||||
private HashMap<Integer, Route> routesUsed;
|
||||
|
||||
public Equipment(String name){
|
||||
this.name = name;
|
||||
routesUsed = new HashMap<>();
|
||||
}
|
||||
|
||||
public void resetRoutes(){
|
||||
routesUsed = new HashMap<>();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void addRoute(Route route){
|
||||
routesUsed.put(routesUsed.size(), route);
|
||||
}
|
||||
|
||||
public HashMap<Integer, Route> getRoutesUsed() {
|
||||
return routesUsed;
|
||||
}
|
||||
|
||||
public void setRoutesUsed(HashMap<Integer, Route> routesUsed) {
|
||||
this.routesUsed = routesUsed;
|
||||
}
|
||||
|
||||
public int getRouteNum(){
|
||||
return routesUsed.size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
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.Dataset;
|
||||
import seng202.group9.Core.Airport;
|
||||
import seng202.group9.Core.Equipment;
|
||||
import seng202.group9.Core.Route;
|
||||
import seng202.group9.Core.RoutePath;
|
||||
import seng202.group9.Map.Map;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by fwy13 on 2/10/16.
|
||||
*/
|
||||
public class EquipByRouteController extends Controller{
|
||||
@FXML
|
||||
WebView mapView;
|
||||
@FXML
|
||||
TableView<Equipment> equipTable;
|
||||
@FXML
|
||||
TableColumn<Airport, String> equipName;
|
||||
@FXML
|
||||
TableColumn<Airport, Integer> routes;
|
||||
ObservableList<Equipment> equipToDisplay;
|
||||
Dataset currentDataset;
|
||||
Map map;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
currentDataset = getParent().getCurrentDataset();
|
||||
//Sets up map.
|
||||
map = new Map(mapView, new RoutePath(), equipTable);
|
||||
equipName.setCellValueFactory(new PropertyValueFactory<Airport, String>("Name"));
|
||||
routes.setCellValueFactory(new PropertyValueFactory<Airport, Integer>("RouteNum"));
|
||||
equipToDisplay = FXCollections.observableArrayList();
|
||||
ArrayList<String> keys = new ArrayList<>(currentDataset.getEquipmentDictionary().keySet());
|
||||
for (int i = 0; i < currentDataset.getEquipmentDictionary().size(); i ++){
|
||||
if (currentDataset.getEquipmentDictionary().get(keys.get(i)).getRouteNum() > 0){
|
||||
equipToDisplay.add(currentDataset.getEquipmentDictionary().get(keys.get(i)));
|
||||
}
|
||||
}
|
||||
equipTable.setItems(equipToDisplay);
|
||||
equipTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Equipment>() {
|
||||
public void changed(ObservableValue<? extends Equipment> observable, Equipment oldValue, Equipment newValue) {
|
||||
Equipment selectedEquip= (Equipment) equipTable.getSelectionModel().getSelectedItems().get(0);
|
||||
ArrayList<RoutePath> routePaths = new ArrayList<RoutePath>();
|
||||
HashMap<Integer, Route> routes = selectedEquip.getRoutesUsed();
|
||||
for (int i = 0; i < routes.size(); i ++){
|
||||
routePaths.add(routes.get(i).getRoutePath());
|
||||
}
|
||||
map.displayRoutes(routePaths);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,9 @@ public class MenuController extends Controller{
|
||||
replaceSceneContent(SceneCode.ROUTE_SUMMARY);
|
||||
}
|
||||
|
||||
/**
|
||||
* view Routes by the Destination / Arrival Airport
|
||||
*/
|
||||
public void viewRouteByAirport(){
|
||||
replaceSceneContent(SceneCode.ROUTE_BY_AIRPORT);
|
||||
}
|
||||
@@ -76,7 +79,6 @@ public class MenuController extends Controller{
|
||||
public void viewFlightSummary() {
|
||||
replaceSceneContent(SceneCode.FLIGHT_SUMMARY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Flight Raw Data Function.
|
||||
*/
|
||||
@@ -84,6 +86,10 @@ public class MenuController extends Controller{
|
||||
replaceSceneContent(SceneCode.FLIGHT_RAW_DATA);
|
||||
}
|
||||
|
||||
public void viewRouteByEquipment(){
|
||||
replaceSceneContent(SceneCode.ROUTE_BY_EQUIP);
|
||||
}
|
||||
|
||||
public void goToGettingStarted() {
|
||||
replaceSceneContent(SceneCode.INITIAL);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package seng202.group9.Map;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.concurrent.Worker;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.web.WebEngine;
|
||||
import javafx.scene.web.WebView;
|
||||
@@ -68,7 +69,12 @@ public class Map {
|
||||
int counter = 0;
|
||||
for (RoutePath route: routes){
|
||||
routeJSONArray += route.toJSONArray() + ", ";
|
||||
if (counter++ > 99){
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<Menu mnemonicParsing="false" text="Maps">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#viewRouteByAirport" text="Route By Airport" />
|
||||
<MenuItem mnemonicParsing="false" text="Unspecified Action" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#viewRouteByEquipment" text="Route By Equipment" />
|
||||
</items>
|
||||
</Menu>
|
||||
</items></Menu>
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.web.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ContextMenu?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.MenuItem?>
|
||||
<?import javafx.scene.control.TableColumn?>
|
||||
<?import javafx.scene.control.TableView?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<GridPane alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="568.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.EquipByRouteController">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="205.0" minWidth="10.0" prefWidth="197.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="686.0" minWidth="10.0" prefWidth="603.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="50.0" minHeight="0.0" prefHeight="50.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="520.0" minHeight="10.0" prefHeight="500.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Routes By Equip">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
<GridPane.margin>
|
||||
<Insets left="15.0" />
|
||||
</GridPane.margin>
|
||||
</Text>
|
||||
<TableView fx:id="equipTable" prefHeight="471.0" prefWidth="142.0" GridPane.rowIndex="1">
|
||||
<columns>
|
||||
<TableColumn fx:id="equipName" prefWidth="88.0" text="Equipment" />
|
||||
<TableColumn fx:id="routes" prefWidth="62.0" text="Routes" />
|
||||
</columns>
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" />
|
||||
</GridPane.margin>
|
||||
</TableView>
|
||||
<WebView fx:id="mapView" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
</children>
|
||||
</GridPane>
|
||||
Reference in New Issue
Block a user