parent
b31fa6e24b
commit
236b93ed85
@ -0,0 +1,72 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.web.WebView;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Core.*;
|
||||
import seng202.group9.Map.Map;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by fwy13 on 1/10/16.
|
||||
*/
|
||||
public class AirportRouteMapController extends Controller{
|
||||
@FXML
|
||||
WebView mapView;
|
||||
@FXML
|
||||
TableView airportsTable;
|
||||
@FXML
|
||||
TableColumn<Airport, String> airportName;
|
||||
@FXML
|
||||
TableColumn<Airport, Integer> routes;
|
||||
ObservableList<Airport> airportsToDisplay;
|
||||
Dataset currentDataset;
|
||||
Map map;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
currentDataset = getParent().getCurrentDataset();
|
||||
//Sets up map.
|
||||
map = new Map(mapView, new RoutePath(), airportsTable);
|
||||
airportName.setCellValueFactory(new PropertyValueFactory<Airport, String>("Name"));
|
||||
routes.setCellValueFactory(new PropertyValueFactory<Airport, Integer>("TotalRoutes"));
|
||||
airportsToDisplay = FXCollections.observableArrayList();
|
||||
for (Airport airport: currentDataset.getAirports()){
|
||||
if (airport.getTotalRoutes() > 0) {
|
||||
airportsToDisplay.add(airport);
|
||||
}
|
||||
}
|
||||
airportsTable.setItems(airportsToDisplay);
|
||||
airportsTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Airport>() {
|
||||
public void changed(ObservableValue<? extends Airport> observable, Airport oldValue, Airport newValue) {
|
||||
Airport selectedAirport= (Airport) airportsTable.getSelectionModel().getSelectedItems().get(0);
|
||||
for (int i = 0 ; i < currentDataset.getAirports().size(); i ++){
|
||||
if (currentDataset.getAirports().get(i).equals(selectedAirport)){
|
||||
ArrayList<RoutePath> routePaths = new ArrayList<RoutePath>();
|
||||
for (Route route:currentDataset.getAirports().get(i).getArrivalRoutes()){
|
||||
routePaths.add(route.getRoutePath());
|
||||
}
|
||||
for (Route route:currentDataset.getAirports().get(i).getDepartureRoutes()){
|
||||
routePaths.add(route.getRoutePath());
|
||||
}
|
||||
map.displayRoutes(routePaths);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.web.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ContextMenu?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.MenuItem?>
|
||||
<?import javafx.scene.control.TableColumn?>
|
||||
<?import javafx.scene.control.TableView?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<GridPane alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="568.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.AirportRouteMapController">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="205.0" minWidth="10.0" prefWidth="197.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="686.0" minWidth="10.0" prefWidth="603.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="50.0" minHeight="0.0" prefHeight="50.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="520.0" minHeight="10.0" prefHeight="20.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="520.0" minHeight="10.0" prefHeight="500.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Routes By Airport">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
<GridPane.margin>
|
||||
<Insets left="15.0" />
|
||||
</GridPane.margin>
|
||||
</Text>
|
||||
<Label text="Airports" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="TOP">
|
||||
<font>
|
||||
<Font size="15.0" />
|
||||
</font>
|
||||
<GridPane.margin>
|
||||
<Insets left="15.0" />
|
||||
</GridPane.margin>
|
||||
</Label>
|
||||
<WebView fx:id="mapView" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="1" GridPane.rowSpan="2">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" top="20.0" />
|
||||
</GridPane.margin>
|
||||
</WebView>
|
||||
<TableView fx:id="airportsTable" prefHeight="471.0" prefWidth="142.0" GridPane.rowIndex="2">
|
||||
<columns>
|
||||
<TableColumn fx:id="airportName" prefWidth="88.0" text="Airport" />
|
||||
<TableColumn fx:id="routes" prefWidth="62.0" text="Routes" />
|
||||
</columns>
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" left="15.0" right="15.0" />
|
||||
</GridPane.margin>
|
||||
</TableView>
|
||||
</children>
|
||||
</GridPane>
|
||||
Loading…
Reference in new issue