Implemented the Summary information on the flight data summary page

main
Liam Beckett 9 years ago
parent 79b73f845e
commit eae3c34be2

Binary file not shown.

@ -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.");

@ -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<String> flightPathListView;
final ObservableList<String> flightList = FXCollections.observableArrayList();
@FXML
ListView<String> flightSummaryListView;
final ObservableList<String> 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<FlightPoint> flightPoints = currentPath.getFlightPoints();
FlightPoint firstPoint = flightPoints.get(0);
String firstPointICAO = firstPoint.getName();
FlightPoint lastPoint = flightPoints.get(flightPoints.size()-1);
String lastPointICAO = lastPoint.getName();
ArrayList<Airport> 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<MouseEvent>() {
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<FlightPath> flightPaths = new ArrayList();
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
for(int i = 0; i<flightPaths.size(); i++ ){
int pathID = flightPaths.get(i).getID();
@ -106,6 +187,7 @@ public class FlightSummaryController extends Controller {
flightList.add(flightPathDisplayName);
}
flightPathListView.setItems(flightList);
flightSummaryListView();
} catch (Exception e) {
e.printStackTrace();

@ -17,7 +17,7 @@
<?import javafx.scene.text.Text?>
<?import javafx.scene.web.WebView?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightSummaryController">
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightSummaryController">
<children>
<ScrollPane hbarPolicy="NEVER" prefHeight="800.0" prefWidth="800.0" vbarPolicy="NEVER">
<content>
@ -85,28 +85,28 @@
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="347.0" minHeight="10.0" prefHeight="346.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="356.0" minHeight="10.0" prefHeight="152.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="392.0" minHeight="10.0" prefHeight="392.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="356.0" minHeight="10.0" prefHeight="143.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Pane prefHeight="160.0" prefWidth="295.0" GridPane.rowIndex="1">
<Pane prefHeight="161.0" prefWidth="316.0" GridPane.rowIndex="1">
<children>
<Button layoutX="26.0" layoutY="82.0" mnemonicParsing="false" onAction="#airportSummaryButton" prefHeight="25.0" prefWidth="65.0" text="Airports">
<Button layoutX="26.0" layoutY="47.0" mnemonicParsing="false" onAction="#airportSummaryButton" prefHeight="25.0" prefWidth="65.0" text="Airports">
<font>
<Font size="12.0" />
</font>
</Button>
<Button layoutX="127.0" layoutY="82.0" mnemonicParsing="false" onAction="#airlineSummaryButton" prefHeight="25.0" prefWidth="65.0" text="Airlines">
<Button layoutX="126.0" layoutY="47.0" mnemonicParsing="false" onAction="#airlineSummaryButton" prefHeight="25.0" prefWidth="65.0" text="Airlines">
<font>
<Font size="12.0" />
</font>
</Button>
<Button layoutX="227.0" layoutY="82.0" mnemonicParsing="false" onAction="#routeSummaryButton" prefHeight="25.0" prefWidth="65.0" text="Routes">
<Button layoutX="227.0" layoutY="47.0" mnemonicParsing="false" onAction="#routeSummaryButton" prefHeight="25.0" prefWidth="65.0" text="Routes">
<font>
<Font size="12.0" />
</font>
</Button>
<Button layoutX="26.0" layoutY="132.0" mnemonicParsing="false" onAction="#handleRawDataButton" prefHeight="25.0" prefWidth="266.0" text="Flights Raw Data" />
<Button layoutX="26.0" layoutY="84.0" mnemonicParsing="false" onAction="#handleRawDataButton" prefHeight="25.0" prefWidth="266.0" text="Flights Raw Data" />
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
@ -114,9 +114,9 @@
</Pane>
<Pane prefHeight="200.0" prefWidth="200.0">
<children>
<Pane prefHeight="350.0" prefWidth="316.0">
<Pane prefHeight="393.0" prefWidth="316.0">
<children>
<ListView layoutX="25.0" layoutY="76.0" prefHeight="258.0" prefWidth="266.0" />
<ListView fx:id="flightSummaryListView" layoutX="25.0" layoutY="76.0" prefHeight="317.0" prefWidth="266.0" />
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />

Loading…
Cancel
Save