Added Airlines Flown most in Route
This commit is contained in:
@@ -184,7 +184,6 @@ public class AirportGraphController extends Controller{
|
|||||||
if (airlines.containsKey(route.getAirline().getName())) {
|
if (airlines.containsKey(route.getAirline().getName())) {
|
||||||
airlines.put(route.getAirline().getName(), airlines.get(route.getAirline().getName()) + 1);
|
airlines.put(route.getAirline().getName(), airlines.get(route.getAirline().getName()) + 1);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
airlines.put(route.getAirline().getName(), 1);
|
airlines.put(route.getAirline().getName(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -194,7 +193,6 @@ public class AirportGraphController extends Controller{
|
|||||||
if (airlines.containsKey(route.getAirline().getName())) {
|
if (airlines.containsKey(route.getAirline().getName())) {
|
||||||
airlines.put(route.getAirline().getName(), airlines.get(route.getAirline().getName()) + 1);
|
airlines.put(route.getAirline().getName(), airlines.get(route.getAirline().getName()) + 1);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
airlines.put(route.getAirline().getName(), 1);
|
airlines.put(route.getAirline().getName(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,22 @@
|
|||||||
package seng202.group9.GUI;
|
package seng202.group9.GUI;
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.chart.BarChart;
|
||||||
|
import javafx.scene.chart.CategoryAxis;
|
||||||
|
import javafx.scene.chart.PieChart;
|
||||||
|
import javafx.scene.chart.XYChart;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import seng202.group9.Controller.Dataset;
|
import seng202.group9.Controller.Dataset;
|
||||||
import seng202.group9.Controller.SceneCode;
|
import seng202.group9.Controller.SceneCode;
|
||||||
import seng202.group9.Controller.Session;
|
import seng202.group9.Controller.Session;
|
||||||
|
import seng202.group9.Core.Airport;
|
||||||
|
import seng202.group9.Core.Route;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gondr on 2/10/2016.
|
* Created by Gondr on 2/10/2016.
|
||||||
@@ -13,8 +24,43 @@ import seng202.group9.Controller.Session;
|
|||||||
public class RouteGraphController extends Controller{
|
public class RouteGraphController extends Controller{
|
||||||
private Dataset dataset;
|
private Dataset dataset;
|
||||||
private Session session;
|
private Session session;
|
||||||
|
private LinkedHashMap<String, Route> routeDict;
|
||||||
|
private HashMap<Integer, String> sessionDict;
|
||||||
|
Route[] routesFiltered;
|
||||||
@FXML
|
@FXML
|
||||||
private VBox chartContainer;
|
private BarChart airlineGraph;
|
||||||
|
@FXML
|
||||||
|
private CategoryAxis airlineXAxis;
|
||||||
|
@FXML
|
||||||
|
private BarChart destGraph;
|
||||||
|
@FXML
|
||||||
|
private CategoryAxis destXAxis;
|
||||||
|
@FXML
|
||||||
|
private BarChart sourceGraph;
|
||||||
|
@FXML
|
||||||
|
private CategoryAxis sourceXAxis;
|
||||||
|
@FXML
|
||||||
|
private BarChart inCountryGraph;
|
||||||
|
@FXML
|
||||||
|
private CategoryAxis inCountryXAxis;
|
||||||
|
@FXML
|
||||||
|
private BarChart outCountryGraph;
|
||||||
|
@FXML
|
||||||
|
private CategoryAxis outCountryXAxis;
|
||||||
|
@FXML
|
||||||
|
private BarChart equipGraph;
|
||||||
|
@FXML
|
||||||
|
private CategoryAxis equipXAxis;
|
||||||
|
@FXML
|
||||||
|
private BarChart similarGraph;
|
||||||
|
@FXML
|
||||||
|
private CategoryAxis similarXAxis;
|
||||||
|
@FXML
|
||||||
|
private PieChart stopsGraph;
|
||||||
|
@FXML
|
||||||
|
private BarChart contienentGraph;
|
||||||
|
@FXML
|
||||||
|
private CategoryAxis contienentXAxis;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
@@ -22,9 +68,65 @@ public class RouteGraphController extends Controller{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dataset = getParent().getCurrentDataset();
|
dataset = getParent().getCurrentDataset();
|
||||||
|
routeDict = dataset.getRouteDictionary();
|
||||||
session = getParent().getSession();
|
session = getParent().getSession();
|
||||||
|
sessionDict = session.getFilteredRoutes();
|
||||||
|
if (sessionDict.size() == 0){
|
||||||
|
Alert alert = new Alert(Alert.AlertType.WARNING);
|
||||||
|
alert.setTitle("No Data");
|
||||||
|
alert.setHeaderText("No Filtered Data");
|
||||||
|
alert.setContentText("There is no set Filtered Data Please go to the Route Raw Data and Filter a Dataset to Analyse.");
|
||||||
|
alert.showAndWait();
|
||||||
|
}
|
||||||
|
ArrayList<Route> routeArrayList = new ArrayList<>();
|
||||||
|
for (int key : sessionDict.keySet()) {
|
||||||
|
routeArrayList.add(routeDict.get(sessionDict.get(key)));
|
||||||
|
|
||||||
|
}
|
||||||
|
routesFiltered = routeArrayList.toArray(new Route[routeArrayList.size()]);
|
||||||
|
System.out.println(routesFiltered.length);
|
||||||
|
//load graphs
|
||||||
|
loadAirlineGraph();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadAirlineGraph(){
|
||||||
|
airlineGraph.setTitle("Top 10 Most Flown Airline in Routes");
|
||||||
|
airlineXAxis.setLabel("Airline");
|
||||||
|
XYChart.Series<String,Integer> series = new XYChart.Series<>();
|
||||||
|
series.setName("Number of Time Flown");
|
||||||
|
|
||||||
|
HashMap<String, Integer> airlines = new HashMap<>();
|
||||||
|
for (Route route: routesFiltered){
|
||||||
|
if (route.getAirline() != null) {
|
||||||
|
if (airlines.containsKey(route.getAirline().getName())) {
|
||||||
|
airlines.put(route.getAirline().getName(), airlines.get(route.getAirline().getName()) + 1);
|
||||||
|
} else {
|
||||||
|
airlines.put(route.getAirline().getName(), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int length = 10;
|
||||||
|
if (airlines.size() < 10){
|
||||||
|
length = airlines.size();
|
||||||
|
}
|
||||||
|
for (int i = 0 ; i < length; i ++) {
|
||||||
|
int max = 0;
|
||||||
|
String maxAirline = "";
|
||||||
|
for (String airline: airlines.keySet()){
|
||||||
|
if (airlines.get(airline) > max){
|
||||||
|
max = airlines.get(airline);
|
||||||
|
maxAirline = airline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
series.getData().add(new XYChart.Data<String, Integer>(maxAirline, max));
|
||||||
|
airlines.remove(maxAirline);
|
||||||
|
}
|
||||||
|
|
||||||
|
airlineGraph.getData().add(series);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void goToRawData(){
|
public void goToRawData(){
|
||||||
replaceSceneContent(SceneCode.ROUTE_RAW_DATA);
|
replaceSceneContent(SceneCode.ROUTE_RAW_DATA);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.chart.*?>
|
||||||
<?import java.lang.*?>
|
<?import java.lang.*?>
|
||||||
<?import javafx.geometry.*?>
|
<?import javafx.geometry.*?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
@@ -40,10 +41,146 @@
|
|||||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</Button>
|
</Button>
|
||||||
<ScrollPane prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1">
|
<TabPane prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" GridPane.rowIndex="1">
|
||||||
<content>
|
<tabs>
|
||||||
<VBox fx:id="chartContainer" prefHeight="463.0" prefWidth="798.0" />
|
<Tab text="Airlines Graph">
|
||||||
</content>
|
<content>
|
||||||
</ScrollPane>
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<BarChart fx:id="airlineGraph" layoutX="115.0" layoutY="14.0" prefHeight="436.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<xAxis>
|
||||||
|
<CategoryAxis fx:id="airlineXAxis" side="BOTTOM" />
|
||||||
|
</xAxis>
|
||||||
|
<yAxis>
|
||||||
|
<NumberAxis side="LEFT" />
|
||||||
|
</yAxis>
|
||||||
|
</BarChart>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
|
<Tab text="Destination Graph">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<BarChart fx:id="destGraph" layoutX="207.0" layoutY="51.0" prefHeight="436.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<xAxis>
|
||||||
|
<CategoryAxis fx:id="destXAxis" side="BOTTOM" />
|
||||||
|
</xAxis>
|
||||||
|
<yAxis>
|
||||||
|
<NumberAxis side="LEFT" />
|
||||||
|
</yAxis>
|
||||||
|
</BarChart>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
|
<Tab text="Source Airport Graph">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<BarChart fx:id="sourceGraph" layoutX="14.0" layoutY="-32.0" prefHeight="436.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<xAxis>
|
||||||
|
<CategoryAxis fx:id="sourceXAxis" side="BOTTOM" />
|
||||||
|
</xAxis>
|
||||||
|
<yAxis>
|
||||||
|
<NumberAxis side="LEFT" />
|
||||||
|
</yAxis>
|
||||||
|
</BarChart>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
|
<Tab text="Country Entry Graph">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<BarChart fx:id="inCountryGraph" layoutX="233.0" layoutY="22.0" prefHeight="436.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<xAxis>
|
||||||
|
<CategoryAxis fx:id="inCountryXAxis" side="BOTTOM" />
|
||||||
|
</xAxis>
|
||||||
|
<yAxis>
|
||||||
|
<NumberAxis side="LEFT" />
|
||||||
|
</yAxis>
|
||||||
|
</BarChart>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
|
<Tab text="Country Exit Graph">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<BarChart fx:id="outCountryGraph" layoutX="122.0" layoutY="14.0" prefHeight="436.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<xAxis>
|
||||||
|
<CategoryAxis fx:id="outCountryXAxis" side="BOTTOM" />
|
||||||
|
</xAxis>
|
||||||
|
<yAxis>
|
||||||
|
<NumberAxis side="LEFT" />
|
||||||
|
</yAxis>
|
||||||
|
</BarChart>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
|
<Tab text="Equipment Graph">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<BarChart fx:id="equipGraph" layoutX="209.0" layoutY="22.0" prefHeight="436.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<xAxis>
|
||||||
|
<CategoryAxis fx:id="equipXAxis" side="BOTTOM" />
|
||||||
|
</xAxis>
|
||||||
|
<yAxis>
|
||||||
|
<NumberAxis side="LEFT" />
|
||||||
|
</yAxis>
|
||||||
|
</BarChart>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
|
<Tab text="Most Similar Routes">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<BarChart fx:id="similarGraph" layoutX="224.0" layoutY="46.0" prefHeight="436.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<xAxis>
|
||||||
|
<CategoryAxis fx:id="similarXAxis" side="BOTTOM" />
|
||||||
|
</xAxis>
|
||||||
|
<yAxis>
|
||||||
|
<NumberAxis side="LEFT" />
|
||||||
|
</yAxis>
|
||||||
|
</BarChart>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
|
<Tab text="Amount of Stops">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<PieChart fx:id="stopsGraph" layoutX="150.0" layoutY="-7.0" prefHeight="436.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
|
<Tab text="Routes to Continent">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<BarChart fx:id="contienentGraph" layoutX="224.0" layoutY="18.0" prefHeight="436.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<xAxis>
|
||||||
|
<CategoryAxis fx:id="contienentXAxis" side="BOTTOM" />
|
||||||
|
</xAxis>
|
||||||
|
<yAxis>
|
||||||
|
<NumberAxis side="LEFT" />
|
||||||
|
</yAxis>
|
||||||
|
</BarChart>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
|
</tabs>
|
||||||
|
</TabPane>
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
|||||||
Reference in New Issue
Block a user