From bc0033fad9b1c09fef3e4f7d2f2ae8f22eadfc45 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 19 Sep 2016 15:22:24 +1200 Subject: [PATCH] Added javadocs. --- .../java/seng202/group9/Core/Airport.java | 1 - .../group9/GUI/AirlineSummaryController.java | 23 ++++++++++++++++ .../seng202/group9/GUI/AirportAnalyser.java | 27 ++++++++++++++++--- .../group9/GUI/AirportSummaryController.java | 22 ++++++++++++++- .../group9/GUI/DistCalcController.java | 12 +++++++++ .../seng202/group9/GUI/RouteAnalyser.java | 20 +++++++++++++- .../group9/GUI/RouteSummaryController.java | 19 +++++++++++++ 7 files changed, 117 insertions(+), 7 deletions(-) diff --git a/src/main/java/seng202/group9/Core/Airport.java b/src/main/java/seng202/group9/Core/Airport.java index c533460..b4cc7f3 100644 --- a/src/main/java/seng202/group9/Core/Airport.java +++ b/src/main/java/seng202/group9/Core/Airport.java @@ -23,7 +23,6 @@ public class Airport { private Country country; private ArrayList departureRoutes = new ArrayList(); private ArrayList arrivalRoutes = new ArrayList(); - /** * Constructor * @param ID from the database diff --git a/src/main/java/seng202/group9/GUI/AirlineSummaryController.java b/src/main/java/seng202/group9/GUI/AirlineSummaryController.java index f161102..6e62b78 100644 --- a/src/main/java/seng202/group9/GUI/AirlineSummaryController.java +++ b/src/main/java/seng202/group9/GUI/AirlineSummaryController.java @@ -19,9 +19,11 @@ import seng202.group9.Core.RoutePath; import seng202.group9.Map.Map; /** + * Controller for the Airline summary scene. * Created by michael on 14/09/2016. */ public class AirlineSummaryController extends Controller{ + //links the fxml to the controller. @FXML private TableView tableView; @FXML @@ -37,11 +39,16 @@ public class AirlineSummaryController extends Controller{ @FXML private TableColumn columnIATA; + //Holds data used for the table. private Dataset currentData = null; private Map map; + /** + * Loads initial state of the scene. + */ public void load() { + //Fills the table. columnName.setCellValueFactory(new PropertyValueFactory("Name")); columnAlias.setCellValueFactory(new PropertyValueFactory("Alias")); columnCountry.setCellValueFactory(new PropertyValueFactory("CountryName")); @@ -49,6 +56,7 @@ public class AirlineSummaryController extends Controller{ columnActive.setCellValueFactory(new PropertyValueFactory("Active")); currentData = getParent().getCurrentDataset(); tableView.setItems(FXCollections.observableArrayList(currentData.getAirlines())); + //Sets up map. map = new Map(mapView, new RoutePath()); tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { public void changed(ObservableValue observable, Airline oldValue, Airline newValue) { @@ -63,15 +71,30 @@ public class AirlineSummaryController extends Controller{ }); } + /** + * Changes the scene to the Airline raw data scene. + */ public void airlineRawDataButton() { replaceSceneContent(SceneCode.AIRLINE_RAW_DATA); } + + /** + * Changes the scene to the Flight summary scene. + */ public void flightSummaryButton() { replaceSceneContent(SceneCode.FLIGHT_SUMMARY); } + + /** + * Changes the scene to the Airport summary scene. + */ public void airportSummaryButton() { replaceSceneContent(SceneCode.AIRPORT_SUMMARY); } + + /** + * Changes the scene to the Route summary scene. + */ public void routeSummaryButton() { replaceSceneContent(SceneCode.ROUTE_SUMMARY); } diff --git a/src/main/java/seng202/group9/GUI/AirportAnalyser.java b/src/main/java/seng202/group9/GUI/AirportAnalyser.java index 48caef6..47f7116 100644 --- a/src/main/java/seng202/group9/GUI/AirportAnalyser.java +++ b/src/main/java/seng202/group9/GUI/AirportAnalyser.java @@ -14,32 +14,48 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.chart.*; import javafx.scene.Group; +import seng202.group9.Core.Airport; /** + * Gui controller class currently for creating the bar graph of routes arriving and departing from airports. + * Extend the class. {@link Controller} * Created by michael on 17/09/2016. */ public class AirportAnalyser extends Controller { + //links fxml parts to the controller. @FXML PieChart pieGraph; + //Used to store the data needed for making the graph. private Dataset currentdata = null; private HashMap useddata = new HashMap(); + private ArrayList current_routes; - private ArrayList current_routes; + /** + * Takes data from the current dataset and places it into the displayed pie graph. + */ public void build_graph(){ - current_routes = currentdata.getAirlines(); + //Takes Airports from the full dataset. + current_routes = currentdata.getAirports(); datasetup(current_routes); + //Turns the data into a usable list. ObservableList pieChartData = FXCollections.observableArrayList(); System.out.println(useddata.keySet().size()); for (String airport : useddata.keySet()){ Integer temp = useddata.get(airport); pieChartData.add(new PieChart.Data(airport,temp)); } + //Gives the data to the graph. pieGraph.setData(pieChartData); } - private void datasetup(ArrayList current_routes){ - for (Airline entry : current_routes){ + /** + * Takes the raw list of routes and fills the used data dictionary with the appropriate data to be displayed + * @param current_air_ports + */ + private void datasetup(ArrayList current_air_ports){ + //Takes out the specified field then adds to the used data dict. + for (Airport entry : current_air_ports){ String name = entry.getCountryName(); if (useddata.containsKey(name)){ int temp = useddata.get(name); @@ -51,6 +67,9 @@ public class AirportAnalyser extends Controller { } } + /** + * Takes the current dataset then loads the data to the graph using build graph. + */ public void load() { currentdata = getParent().getCurrentDataset(); build_graph(); diff --git a/src/main/java/seng202/group9/GUI/AirportSummaryController.java b/src/main/java/seng202/group9/GUI/AirportSummaryController.java index 7f41148..08ce135 100644 --- a/src/main/java/seng202/group9/GUI/AirportSummaryController.java +++ b/src/main/java/seng202/group9/GUI/AirportSummaryController.java @@ -17,9 +17,11 @@ import seng202.group9.Core.RoutePath; import seng202.group9.Map.Map; /** + * Controller for the Airport summary scene. * Created by michael on 14/09/2016. */ public class AirportSummaryController extends Controller{ + //links controller to fxml. @FXML private TableView tableView; @FXML @@ -35,23 +37,41 @@ public class AirportSummaryController extends Controller{ @FXML private TableColumn columnIATA; + //Stores required data. private Dataset currentData = null; - private Map map; + /** + * Changes the scene to the Airport raw data scene. + */ public void airportRawDataButton() { replaceSceneContent(SceneCode.AIRPORT_RAW_DATA); } + + /** + * Changes the scene to the flight summary scene. + */ public void flightSummaryButton() { replaceSceneContent(SceneCode.FLIGHT_SUMMARY); } + + /** + * Changes the scene to the Route summary scene. + */ public void routeSummaryButton() { replaceSceneContent(SceneCode.ROUTE_SUMMARY); } + + /** + * Changes the scene to the airline summary scene. + */ public void airlineSummaryButton() { replaceSceneContent(SceneCode.AIRLINE_SUMMARY); } + /** + * Loads initial state of the scene. + */ public void load() { currentData = getParent().getCurrentDataset(); columnName.setCellValueFactory(new PropertyValueFactory("Name")); diff --git a/src/main/java/seng202/group9/GUI/DistCalcController.java b/src/main/java/seng202/group9/GUI/DistCalcController.java index 626d7ff..c54f1bc 100644 --- a/src/main/java/seng202/group9/GUI/DistCalcController.java +++ b/src/main/java/seng202/group9/GUI/DistCalcController.java @@ -21,9 +21,11 @@ import javafx.scene.chart.*; import javafx.scene.Group; /** + * Controls the calculate airport distance scene and extends {@link Controller} * Created by michael on 17/09/2016. */ public class DistCalcController extends Controller { + //Connects controller to fxml. @FXML ListView airportOne; @FXML @@ -31,10 +33,14 @@ public class DistCalcController extends Controller { @FXML Label answerBox; + //Stores requsite data for calulating and populating tables. Dataset currentData = null; HashMap current_Airports; SimpleStringProperty bound = new SimpleStringProperty("Answer"); + /** + * Fills the list views with the current airports. + */ private void fill_boxes(){ HashMap current_Airports = currentData.getAirportDictionary(); ArrayList names = new ArrayList(); @@ -46,6 +52,9 @@ public class DistCalcController extends Controller { airportTwo.setItems(usablenames); } + /** + * Takes thetwo selected airports from the list views and calculated the distance between. + */ public void calculateButton(){ Airport airport1 = currentData.getAirports().get((airportOne.getSelectionModel().getSelectedIndices().get(0))); Airport airport2 = currentData.getAirports().get((airportTwo.getSelectionModel().getSelectedIndices().get(0))); @@ -54,6 +63,9 @@ public class DistCalcController extends Controller { System.out.println(bound); } + /** + * Sets the initial state of the scene. + */ public void load(){ currentData = getParent().getCurrentDataset(); answerBox.textProperty().bind(bound); diff --git a/src/main/java/seng202/group9/GUI/RouteAnalyser.java b/src/main/java/seng202/group9/GUI/RouteAnalyser.java index a2e12a2..241768b 100644 --- a/src/main/java/seng202/group9/GUI/RouteAnalyser.java +++ b/src/main/java/seng202/group9/GUI/RouteAnalyser.java @@ -12,20 +12,28 @@ import java.util.HashMap; /** + * Gui controller class currently for creating the bar graph of routes arriving and departing from airports. + * Extend the class. {@link Controller} * Created by michael on 16/09/2016. */ public class RouteAnalyser extends Controller { + //Links fxml to the controller. @FXML private BarChart analyserGraph; + //Used to store the data needed for making the tables. private ArrayList current_routes; - private Dataset currentdata = null; private HashMap useddata = new HashMap(); + /** + * Takes data from the current dataset and places it into the displayed bar graph. + */ public void build_graph(){ + //Takes routes from the full dataset. current_routes = currentdata.getRoutes(); datasetup(current_routes); + //Builds series needed for the graph. XYChart.Series seriesArivals = new XYChart.Series(); XYChart.Series seriesDeparts = new XYChart.Series(); seriesArivals.setName("Arriving routes"); @@ -36,10 +44,17 @@ public class RouteAnalyser extends Controller { seriesArivals.getData().add(new XYChart.Data(airport,temp.get(0))); seriesDeparts.getData().add(new XYChart.Data(airport,temp.get(1))); } + //Gives the formatted data to the graph. analyserGraph.getData().addAll(seriesArivals,seriesDeparts); } + /** + * Takes the raw list of routes and fills the used data dictionary with the appropriate data to be displayed + * @param current_routes + */ + private void datasetup(ArrayList current_routes){ + //Takes out the specified field (Currently departure airport and arrival airport) then adds to the used data dict. for (Route entry : current_routes){ String departs = entry.getDepartureAirport(); String arives = entry.getArrivalAirport(); @@ -66,6 +81,9 @@ public class RouteAnalyser extends Controller { } } + /** + * Takes the current dataset then loads the data to the graph using build graph. + */ public void load() { currentdata = getParent().getCurrentDataset(); build_graph(); diff --git a/src/main/java/seng202/group9/GUI/RouteSummaryController.java b/src/main/java/seng202/group9/GUI/RouteSummaryController.java index 5fcb44a..e84e955 100644 --- a/src/main/java/seng202/group9/GUI/RouteSummaryController.java +++ b/src/main/java/seng202/group9/GUI/RouteSummaryController.java @@ -39,6 +39,9 @@ public class RouteSummaryController extends Controller{ private Dataset currentData = null; + /** + * Loads initial state of the scene. + */ public void load() { columnAirline.setCellValueFactory(new PropertyValueFactory("AirlineName")); columnDepart.setCellValueFactory(new PropertyValueFactory("DepartureAirport")); @@ -69,15 +72,31 @@ public class RouteSummaryController extends Controller{ } }); } + + /** + * Changes the scene to the route raw data scene. + */ public void routeRawDataButton() { replaceSceneContent(SceneCode.ROUTE_RAW_DATA); } + + /** + * Changes the scene to the flight summary scene. + */ public void flightSummaryButton() { replaceSceneContent(SceneCode.FLIGHT_SUMMARY); } + + /** + * Changes the scene to the airport summary scene. + */ public void airportSummaryButton() { replaceSceneContent(SceneCode.AIRPORT_SUMMARY); } + + /** + * Changes the scene to the airline summary scene. + */ public void airlineSummaryButton() { replaceSceneContent(SceneCode.AIRLINE_SUMMARY); }