From eae3c34be2054babe734f01153e603b5b7286765 Mon Sep 17 00:00:00 2001 From: Liam Beckett Date: Fri, 30 Sep 2016 13:05:54 +1300 Subject: [PATCH 1/2] Implemented the Summary information on the flight data summary page --- res/userdb.db | Bin 8387584 -> 8387584 bytes .../group9/GUI/FlightEditorController.java | 1 - .../group9/GUI/FlightSummaryController.java | 90 +++++++++++++++++- src/main/resources/flight_data_summary.fxml | 20 ++-- 4 files changed, 96 insertions(+), 15 deletions(-) diff --git a/res/userdb.db b/res/userdb.db index dd0d554e540363b23075e38bc1d1e7788217859e..e7dff5b906f514d4c65f1df78320c850533a6069 100644 GIT binary patch delta 632 zcmWm3xlBOdo=3dzTSUR)H_li|nyvM3 zP}4cKI%98<#>UD&z)rusH=ozMslWdcQ+U_xR;OEvZuPZHuE{ecOtVb0O${dBlr*JG zb4+th^Gs>ed{f4hH8q-Yro3r^smZj^w8*sBw8XU3)NE=oEi)}QtuU=Ltun1PtueKl z+DvOdDR|%C=yo_6Crr3~%v-mT_!j5FppfhF(y6>dJ)bzm!6^P&4BF%IF!-2t-49Nt zY35D%zUMn}R~Q6wB?`(xo10F}Jeg$D_mj>@xi}n+j&*(=_%hV{eIgrHrt^P3|7fWF zj)GsV=Qwd83c9PM`kQ(wKs(l9JvLw?HlctHbYe5MU@Nv^JG#(~9`s@dc48NHqYwQE z5n&ICC}9A5u@8gTk0BhuFb-k_hcJr6ID(@X!!aDk37o_!lyMqoa2Drq9>N7fut w1y^tt*Ki#-a1*z18+ULQ_i!H%@DPvi7*FsN&+r`Mc!3GL#H(7pG}&7F56aN~;s5{u delta 596 zcmWN=Nq5Up9LM4NPeQd+n??|A3{`GTF(>9G5^c;)4W*QC5%WB&sTRNEoUE|9YhD8< zOH0SXJIKbyYp~<kF}0gIOmj{1 zOr56rrY=*rDQW64rA!MX zpNEoe(sjAKbNTp>cq6JuxzJPexlk?nY$E#NvSDg8oe9%L|26z9`$DLf{6zR(OLruk zbK~JxEuCrpDf!<~vJmTRPr8&##oFM?)i74{gP$s`_pOTOAlGm$*Ks{JFvpGD#Le8o zt=z`#%(K89+{szuCGKaL6&~O)M_A=S9^zph;ZYvragMUaF`nQ_p5kea z^9;{&g6DXilf1x-6sLHJmwAPCUgb4j=MCQEE#BrG-sL^s=L0_EBR=L6KIJn$=L=5r PC13G1-!xm5w*$@pqyG79 diff --git a/src/main/java/seng202/group9/GUI/FlightEditorController.java b/src/main/java/seng202/group9/GUI/FlightEditorController.java index 78f0b77..6282cd5 100644 --- a/src/main/java/seng202/group9/GUI/FlightEditorController.java +++ b/src/main/java/seng202/group9/GUI/FlightEditorController.java @@ -69,7 +69,6 @@ public class FlightEditorController extends Controller{ stage.close(); } catch ( Exception e ) { - e.printStackTrace(); Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Flight Data Error"); alert.setHeaderText("Error editing a flight point."); diff --git a/src/main/java/seng202/group9/GUI/FlightSummaryController.java b/src/main/java/seng202/group9/GUI/FlightSummaryController.java index c15cf63..bb0dee8 100644 --- a/src/main/java/seng202/group9/GUI/FlightSummaryController.java +++ b/src/main/java/seng202/group9/GUI/FlightSummaryController.java @@ -13,8 +13,10 @@ import javafx.scene.control.ListView; import javafx.scene.input.MouseEvent; import javafx.scene.web.WebView; import seng202.group9.Controller.App; +import seng202.group9.Controller.DataException; import seng202.group9.Controller.Dataset; import seng202.group9.Controller.SceneCode; +import seng202.group9.Core.Airport; import seng202.group9.Core.FlightPath; import seng202.group9.Core.RoutePath; import seng202.group9.Map.Map; @@ -22,6 +24,7 @@ import seng202.group9.Core.FlightPoint; import java.net.URL; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.ResourceBundle; /** @@ -31,9 +34,8 @@ import java.util.ResourceBundle; public class FlightSummaryController extends Controller { private Dataset theDataSet = null; - private int currentPathId = 0; - private int currentPathIndex = 0; + private int currentPathIndex = 0; @FXML private Button flightRawData; @@ -43,6 +45,9 @@ public class FlightSummaryController extends Controller { @FXML ListView flightPathListView; final ObservableList flightList = FXCollections.observableArrayList(); + @FXML + ListView flightSummaryListView; + final ObservableList infoList = FXCollections.observableArrayList(); /** * Changes to the Flight Raw Data Scene when the Raw Data Button is clicked. @@ -54,7 +59,9 @@ public class FlightSummaryController extends Controller { /** * Changes to the Airport Summary Scene when the Airport is clicked. */ - public void airportSummaryButton() { replaceSceneContent(SceneCode.AIRPORT_SUMMARY); } + public void airportSummaryButton() { + replaceSceneContent(SceneCode.AIRPORT_SUMMARY); + } /** * Changes to the Route Summary Scene when the Route Button is clicked. @@ -70,6 +77,69 @@ public class FlightSummaryController extends Controller { replaceSceneContent(SceneCode.AIRLINE_SUMMARY); } + public void flightSummaryListView() { + try { + currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path + + FlightPath currentPath = theDataSet.getFlightPathDictionary().get(currentPathId); + ArrayList flightPoints = currentPath.getFlightPoints(); + FlightPoint firstPoint = flightPoints.get(0); + String firstPointICAO = firstPoint.getName(); + FlightPoint lastPoint = flightPoints.get(flightPoints.size()-1); + String lastPointICAO = lastPoint.getName(); + + ArrayList airportList = theDataSet.getAirports(); + Airport sourceAirport = null; + Airport destinationAirport = null; + + System.out.println(firstPointICAO); + System.out.println(lastPointICAO); + + for (int i=0; i < airportList.size(); i++){ + Airport current = airportList.get(i); + System.out.println(current.getICAO()); + if(current.getICAO().equals(firstPointICAO)){ + sourceAirport = current; + } + if(current.getICAO().equals(lastPointICAO)){ + destinationAirport = current; + } + } + + String source = "Not Available"; + String destination = "Not Available"; + double distance = 0.0; + if(sourceAirport != null){ + source = sourceAirport.getName(); + } + if(destinationAirport != null){ + destination = destinationAirport.getName(); + } + if(destination != "Not Available" && source != "Not Available"){ + distance = sourceAirport.calculateDistance(destinationAirport); + } + + infoList.add(" Flight Path Summary Information"); + infoList.add(""); + infoList.add("Total Distance of Flight:"); + infoList.add(Double.toString(distance)); + infoList.add("Source Airport:"); + infoList.add(source); + infoList.add("Destination Airport:"); + infoList.add(destination); + if(sourceAirport == null || destinationAirport == null){ + infoList.add(""); + infoList.add("Missing Data is due to first or last points"); + infoList.add("ICAO codes not being present in the Airline"); + infoList.add("Database!"); + } + + flightSummaryListView.setItems(infoList); + } catch(Exception e) { + e.printStackTrace(); + } + } + /** * 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. @@ -85,6 +155,17 @@ public class FlightSummaryController extends Controller { String flightPathDisplayName = Integer.toString(pathID) + "_" + pathSource + "_" + pathDestin; flightList.add(flightPathDisplayName); } + flightPathListView.setOnMouseClicked(new EventHandler() { + public void handle(MouseEvent event) { + String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem(); + String[] segments = flightPathDisplayNameClicked.split("_"); + String pathIdClicked = segments[0]; + + currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary() + .get(Integer.parseInt(pathIdClicked))); + currentPathId = Integer.parseInt(pathIdClicked); + } + }); flightPathListView.setItems(flightList); } catch (Exception e) { e.printStackTrace(); @@ -96,7 +177,7 @@ public class FlightSummaryController extends Controller { public void load() { try { theDataSet = getParent().getCurrentDataset(); - ArrayList flightPaths = new ArrayList(); + ArrayList flightPaths; flightPaths = theDataSet.getFlightPaths(); for(int i = 0; i - + @@ -85,28 +85,28 @@ - - + + - + - - - -