parent
f930f7664e
commit
3f26aff3d2
@ -0,0 +1,45 @@
|
||||
package seng202.group9.Core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Created by fwy13 on 2/10/16.
|
||||
*/
|
||||
public class Equipment {
|
||||
private String name;
|
||||
private HashMap<Integer, Route> routesUsed;
|
||||
|
||||
public Equipment(String name){
|
||||
this.name = name;
|
||||
routesUsed = new HashMap<>();
|
||||
}
|
||||
|
||||
public void resetRoutes(){
|
||||
routesUsed = new HashMap<>();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void addRoute(Route route){
|
||||
routesUsed.put(routesUsed.size(), route);
|
||||
}
|
||||
|
||||
public HashMap<Integer, Route> getRoutesUsed() {
|
||||
return routesUsed;
|
||||
}
|
||||
|
||||
public void setRoutesUsed(HashMap<Integer, Route> routesUsed) {
|
||||
this.routesUsed = routesUsed;
|
||||
}
|
||||
|
||||
public int getRouteNum(){
|
||||
return routesUsed.size();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
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.Airport;
|
||||
import seng202.group9.Core.Equipment;
|
||||
import seng202.group9.Core.Route;
|
||||
import seng202.group9.Core.RoutePath;
|
||||
import seng202.group9.Map.Map;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by fwy13 on 2/10/16.
|
||||
*/
|
||||
public class EquipByRouteController extends Controller{
|
||||
@FXML
|
||||
WebView mapView;
|
||||
@FXML
|
||||
TableView<Equipment> equipTable;
|
||||
@FXML
|
||||
TableColumn<Airport, String> equipName;
|
||||
@FXML
|
||||
TableColumn<Airport, Integer> routes;
|
||||
ObservableList<Equipment> equipToDisplay;
|
||||
Dataset currentDataset;
|
||||
Map map;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if (!checkDataset()){
|
||||
return;
|
||||
}
|
||||
currentDataset = getParent().getCurrentDataset();
|
||||
//Sets up map.
|
||||
map = new Map(mapView, new RoutePath(), equipTable);
|
||||
equipName.setCellValueFactory(new PropertyValueFactory<Airport, String>("Name"));
|
||||
routes.setCellValueFactory(new PropertyValueFactory<Airport, Integer>("RouteNum"));
|
||||
equipToDisplay = FXCollections.observableArrayList();
|
||||
ArrayList<String> keys = new ArrayList<>(currentDataset.getEquipmentDictionary().keySet());
|
||||
for (int i = 0; i < currentDataset.getEquipmentDictionary().size(); i ++){
|
||||
if (currentDataset.getEquipmentDictionary().get(keys.get(i)).getRouteNum() > 0){
|
||||
equipToDisplay.add(currentDataset.getEquipmentDictionary().get(keys.get(i)));
|
||||
}
|
||||
}
|
||||
equipTable.setItems(equipToDisplay);
|
||||
equipTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Equipment>() {
|
||||
public void changed(ObservableValue<? extends Equipment> observable, Equipment oldValue, Equipment newValue) {
|
||||
Equipment selectedEquip= (Equipment) equipTable.getSelectionModel().getSelectedItems().get(0);
|
||||
ArrayList<RoutePath> routePaths = new ArrayList<RoutePath>();
|
||||
HashMap<Integer, Route> routes = selectedEquip.getRoutesUsed();
|
||||
for (int i = 0; i < routes.size(); i ++){
|
||||
routePaths.add(routes.get(i).getRoutePath());
|
||||
}
|
||||
map.displayRoutes(routePaths);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
<?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.EquipByRouteController">
|
||||
<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="500.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Routes By Equip">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
<GridPane.margin>
|
||||
<Insets left="15.0" />
|
||||
</GridPane.margin>
|
||||
</Text>
|
||||
<TableView fx:id="equipTable" prefHeight="471.0" prefWidth="142.0" GridPane.rowIndex="1">
|
||||
<columns>
|
||||
<TableColumn fx:id="equipName" prefWidth="88.0" text="Equipment" />
|
||||
<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>
|
||||
<WebView fx:id="mapView" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
</children>
|
||||
</GridPane>
|
||||
Loading…
Reference in new issue