commit
afc7d1472f
@ -0,0 +1,59 @@
|
|||||||
|
package seng202.group9.GUI;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.chart.BarChart;
|
||||||
|
import javafx.scene.chart.PieChart;
|
||||||
|
import javafx.scene.chart.XYChart;
|
||||||
|
import seng202.group9.Controller.App;
|
||||||
|
import seng202.group9.Controller.Dataset;
|
||||||
|
import seng202.group9.Core.Airline;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.scene.chart.*;
|
||||||
|
import javafx.scene.Group;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by michael on 17/09/2016.
|
||||||
|
*/
|
||||||
|
public class AirportAnalyser extends Controller {
|
||||||
|
@FXML
|
||||||
|
PieChart pieGraph;
|
||||||
|
|
||||||
|
private Dataset currentdata = null;
|
||||||
|
private HashMap<String, Integer> useddata = new HashMap<String, Integer>();
|
||||||
|
|
||||||
|
private ArrayList<Airline> current_routes;
|
||||||
|
public void build_graph(){
|
||||||
|
current_routes = currentdata.getAirlines();
|
||||||
|
datasetup(current_routes);
|
||||||
|
ObservableList<PieChart.Data> 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));
|
||||||
|
}
|
||||||
|
pieGraph.setData(pieChartData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void datasetup(ArrayList<Airline> current_routes){
|
||||||
|
for (Airline entry : current_routes){
|
||||||
|
String name = entry.getCountryName();
|
||||||
|
if (useddata.containsKey(name)){
|
||||||
|
int temp = useddata.get(name);
|
||||||
|
useddata.replace(name,temp+1);
|
||||||
|
}else {
|
||||||
|
Integer temp = 1;
|
||||||
|
useddata.put(name,temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
currentdata = getParent().getCurrentDataset();
|
||||||
|
build_graph();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.chart.PieChart?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<?import javafx.scene.layout.Pane?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
|
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="568.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.45" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.AirportAnalyser">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints maxHeight="457.0" minHeight="10.0" prefHeight="403.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="129.0" minHeight="10.0" prefHeight="111.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Pane prefHeight="600.0" prefWidth="800.0" GridPane.columnSpan="2" GridPane.rowSpan="2">
|
||||||
|
<children>
|
||||||
|
<Label layoutX="14.0" layoutY="14.0" text="Airport Analyser">
|
||||||
|
<font>
|
||||||
|
<Font size="29.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Pane layoutX="15.0" layoutY="60.0" prefHeight="403.0" prefWidth="772.0">
|
||||||
|
<children>
|
||||||
|
<PieChart fx:id="pieGraph" prefHeight="400.0" prefWidth="772.0" title="Airports per country" />
|
||||||
|
</children></Pane>
|
||||||
|
</children>
|
||||||
|
</Pane>
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
Loading…
Reference in new issue