parent
548ffa99f1
commit
ff79599c9b
@ -0,0 +1,63 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.text.Text;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Core.Airport;
|
||||
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 DistCalcController extends Controller {
|
||||
@FXML
|
||||
ListView<String> airportOne;
|
||||
@FXML
|
||||
ListView<String> airportTwo;
|
||||
@FXML
|
||||
Label answerBox;
|
||||
|
||||
Dataset currentData = null;
|
||||
HashMap<String, Airport> current_Airports;
|
||||
SimpleStringProperty bound = new SimpleStringProperty("Answer");
|
||||
|
||||
private void fill_boxes(){
|
||||
HashMap<String, Airport> current_Airports = currentData.getAirportDictionary();
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
for(String name : current_Airports.keySet()){
|
||||
names.add(name);
|
||||
}
|
||||
ObservableList<String> usablenames = FXCollections.observableArrayList(names);
|
||||
airportOne.setItems(usablenames);
|
||||
airportTwo.setItems(usablenames);
|
||||
}
|
||||
|
||||
public void calculateButton(){
|
||||
Airport airport1 = currentData.getAirports().get((airportOne.getSelectionModel().getSelectedIndices().get(0)));
|
||||
Airport airport2 = currentData.getAirports().get((airportTwo.getSelectionModel().getSelectedIndices().get(0)));
|
||||
double distance = airport1.calculateDistance(airport2);
|
||||
bound.setValue(String.valueOf(Math.round(distance)) + "km");
|
||||
System.out.println(bound);
|
||||
}
|
||||
|
||||
public void load(){
|
||||
currentData = getParent().getCurrentDataset();
|
||||
answerBox.textProperty().bind(bound);
|
||||
fill_boxes();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.45" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.DistCalcController">
|
||||
<children>
|
||||
<ScrollPane hbarPolicy="NEVER" prefHeight="800.0" prefWidth="800.0" vbarPolicy="NEVER">
|
||||
<content>
|
||||
<AnchorPane prefHeight="600.0" prefWidth="800.0">
|
||||
<children>
|
||||
<GridPane prefHeight="600.0" prefWidth="800.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="493.0" minWidth="10.0" prefWidth="484.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="393.0" minWidth="10.0" prefWidth="316.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="261.0" minHeight="0.0" prefHeight="48.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="711.0" minHeight="10.0" prefHeight="542.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<GridPane GridPane.rowIndex="1">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="237.0" minWidth="10.0" prefWidth="168.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="316.0" minWidth="10.0" prefWidth="316.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="172.0" minHeight="0.0" prefHeight="44.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="461.0" minHeight="10.0" prefHeight="454.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Pane prefHeight="461.0" prefWidth="175.0" GridPane.rowIndex="1">
|
||||
<children>
|
||||
<ListView fx:id="airportOne" layoutX="20.0" layoutY="27.0" prefHeight="404.0" prefWidth="125.0" />
|
||||
<Label layoutX="26.0" layoutY="4.0" text="Start Airport">
|
||||
<font>
|
||||
<Font size="15.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</Pane>
|
||||
<Pane prefHeight="60.0" prefWidth="330.0">
|
||||
<children>
|
||||
<Text layoutX="21.0" layoutY="40.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Airport Distance Calculator">
|
||||
<font>
|
||||
<Font size="48.0" />
|
||||
</font>
|
||||
</Text>
|
||||
</children>
|
||||
</Pane>
|
||||
<Pane prefHeight="461.0" prefWidth="175.0" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||
<children>
|
||||
<ListView fx:id="airportTwo" layoutX="20.0" layoutY="27.0" prefHeight="404.0" prefWidth="125.0" />
|
||||
<Label layoutX="26.0" layoutY="4.0" text="End airport">
|
||||
<font>
|
||||
<Font size="15.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="answerBox" layoutX="211.0" layoutY="184.0" prefHeight="19.0" prefWidth="101.0" text="Label" />
|
||||
</children>
|
||||
</Pane>
|
||||
|
||||
</children>
|
||||
</GridPane>
|
||||
<Button mnemonicParsing="false" onAction="#calculateButton" prefHeight="25.0" prefWidth="184.0" text="Calculate" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
</children>
|
||||
</GridPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</children>
|
||||
</VBox>
|
||||
Loading…
Reference in new issue