Merge branch 'Update_Path' into 'master'

Update path



See merge request !22
main
Liam Beckett 9 years ago
commit 12c396a263

Binary file not shown.

@ -467,7 +467,6 @@ public class Dataset {
while (IDResult.next()) {
nextID = Integer.parseInt(IDResult.getString("seq")) + 1;//for some reason sqlite3 stores incremental values as a string...
}
System.out.println(nextID);
stmt.close();
stmt = c.createStatement();
String insertAirportQuery = "INSERT INTO `" + this.name + "_Airport` (`Name`, `City`, `Country`, `IATA/FFA`," +
@ -1611,7 +1610,6 @@ public class Dataset {
stmt.close();
int index = flightPath.getFlightPoints().indexOf(flightPoint);
System.out.println(index);
if (index == 0){
try {

@ -28,7 +28,7 @@ public class FlightPath {
}
/**
* COnstructor for FlightPath from dataset add later the ID needs to be set from database.
* Constructor for FlightPath from dataset add later the ID needs to be set from database.
* @param departureAirport
* @param arrivalAirport
*/

@ -37,8 +37,6 @@ public class FlightRDController extends Controller {
@FXML
private TableColumn<FlightPoint, String> flightTypeCol;
@FXML
private TableColumn<FlightPoint, String> flightViaCol;
@FXML
private TableColumn<FlightPoint, String> flightAltitudeCol;
@FXML
private TableColumn<FlightPoint, String> flightLatCol;
@ -92,17 +90,19 @@ public class FlightRDController extends Controller {
flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) {
String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem();
String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0];
if (flightPathDisplayNameClicked!=null) {
String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0];
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
.get(Integer.parseInt(pathIdClicked)));
currentPathId = Integer.parseInt(pathIdClicked);
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
.get(Integer.parseInt(pathIdClicked)));
currentPathId = Integer.parseInt(pathIdClicked);
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
ArrayList<FlightPoint> flightPoints = flightPaths.get(currentPathIndex).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
}
}
});
@ -117,27 +117,28 @@ public class FlightRDController extends Controller {
* Used to load the table for the Flight points initially from the MenuController
*/
public void load() {
theDataSet = getParent().getCurrentDataset();
try {
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path
} catch (DataException e) {
e.printStackTrace();
}
flightIdCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("ID"));
flightNameCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Name"));
flightTypeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Type"));
flightViaCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Via"));
flightAltitudeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Altitude"));
flightLatCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Latitude"));
flightLongCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Longitude"));
flightHeadCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Heading"));
flightLegDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("LegDistance"));
flightTotDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("totalDistance"));
if (theDataSet != null) {
theDataSet = getParent().getCurrentDataset();
try {
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path
} catch (DataException e) {
e.printStackTrace();
}
flightIdCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("ID"));
flightNameCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Name"));
flightTypeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Type"));
flightAltitudeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Altitude"));
flightLatCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Latitude"));
flightLongCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Longitude"));
flightHeadCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Heading"));
flightLegDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("LegDistance"));
flightTotDisCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("totalDistance"));
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
ArrayList<FlightPoint> flightPoints = flightPaths.get(0).getFlight();
flightTableView.setItems(FXCollections.observableArrayList(flightPoints));
}
}
/**
@ -222,27 +223,38 @@ public class FlightRDController extends Controller {
flightPathListView();
}
/**
* Function for the 'Move Up' right click option on the points in the flight table.
*/
public void movePointUp(){
FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem();
int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex();
try{
theDataSet.moveFlightPoint(toMove, toMoveIndex-1);
if (toMoveIndex != 0) {
theDataSet.moveFlightPoint(toMove, toMoveIndex - 1);
}
} catch (DataException e) {
e.printStackTrace();
}
updateTable(currentPathIndex);
updatePaths();
}
/**
* Function for the 'Move Down' right click option on the points in the flight table.
*/
public void movePointDown(){
FlightPoint toMove = flightTableView.getSelectionModel().getSelectedItem();
int toMoveIndex = flightTableView.getSelectionModel().getSelectedIndex();
try{
theDataSet.moveFlightPoint(toMove, toMoveIndex+1);
if (toMoveIndex != flightTableView.getItems().size()-1) {
theDataSet.moveFlightPoint(toMove, toMoveIndex + 1);
}
} catch (DataException e) {
e.printStackTrace();
}
updateTable(currentPathIndex);
updatePaths();
}
/**
@ -257,6 +269,27 @@ public class FlightRDController extends Controller {
flightTableView.refresh();
}
/**
* Updates the flight path list view so that it displays the correct names for the paths
*/
private void updatePaths(){
try {
flightPathListView.getItems().clear();
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
for(int i = 0; i<flightPaths.size(); i++ ) {
int pathID = flightPaths.get(i).getID();
String pathSource = flightPaths.get(i).departsFrom();
String pathDestin = flightPaths.get(i).arrivesAt();
String flightPathDisplayName = Integer.toString(pathID) + "_" + pathSource + "_" + pathDestin;
flightList.add(flightPathDisplayName);
}
flightPathListView.setItems(flightList);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Will link to the flight analyser when implemented.
*/
@ -266,7 +299,9 @@ public class FlightRDController extends Controller {
@Override
public void loadOnce(){
flightPathListView();
if (theDataSet != null) {
flightPathListView();
}
}
public void flightSummaryButton() {

@ -155,12 +155,14 @@ public class FlightSummaryController extends Controller {
flightPathListView.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) {
String flightPathDisplayNameClicked = flightPathListView.getSelectionModel().getSelectedItem();
String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0];
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
.get(Integer.parseInt(pathIdClicked)));
currentPathId = Integer.parseInt(pathIdClicked);
if (flightPathDisplayNameClicked!=null) {
String[] segments = flightPathDisplayNameClicked.split("_");
String pathIdClicked = segments[0];
currentPathIndex = theDataSet.getFlightPaths().indexOf(theDataSet.getFlightPathDictionary()
.get(Integer.parseInt(pathIdClicked)));
currentPathId = Integer.parseInt(pathIdClicked);
}
}
});
flightPathListView.setItems(flightList);
@ -173,36 +175,37 @@ public class FlightSummaryController extends Controller {
* Used to load the page from the MenuController.
*/
public void load() {
try {
theDataSet = getParent().getCurrentDataset();
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
for(int i = 0; i<flightPaths.size(); i++ ){
int pathID = flightPaths.get(i).getID();
String pathSource = flightPaths.get(i).departsFrom();
String pathDestin = flightPaths.get(i).arrivesAt();
String flightPathDisplayName = Integer.toString(pathID) + "_" + pathSource + "_" + pathDestin;
flightList.add(flightPathDisplayName);
}
flightPathListView.setItems(flightList);
flightSummaryListView();
} catch (Exception e) {
e.printStackTrace();
}
if (theDataSet.getFlightPaths().size() > 0){
map = new Map(mapView, theDataSet.getFlightPaths().get(0).getRoutePath());
}else{
map = new Map(mapView, new RoutePath());
}
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
int index = flightPathListView.getSelectionModel().getSelectedIndices().get(0);
if (index != -1) {
map.displayRoute(theDataSet.getFlightPaths().get(index).getRoutePath());
if (theDataSet != null) {
try {
theDataSet = getParent().getCurrentDataset();
ArrayList<FlightPath> flightPaths;
flightPaths = theDataSet.getFlightPaths();
for (int i = 0; i < flightPaths.size(); i++) {
int pathID = flightPaths.get(i).getID();
String pathSource = flightPaths.get(i).departsFrom();
String pathDestin = flightPaths.get(i).arrivesAt();
String flightPathDisplayName = Integer.toString(pathID) + "_" + pathSource + "_" + pathDestin;
flightList.add(flightPathDisplayName);
}
flightPathListView.setItems(flightList);
flightSummaryListView();
} catch (Exception e) {
e.printStackTrace();
}
if (theDataSet.getFlightPaths().size() > 0) {
map = new Map(mapView, theDataSet.getFlightPaths().get(0).getRoutePath());
} else {
map = new Map(mapView, new RoutePath());
}
});
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
int index = flightPathListView.getSelectionModel().getSelectedIndices().get(0);
if (index != -1) {
map.displayRoute(theDataSet.getFlightPaths().get(index).getRoutePath());
}
}
});
}
}
/**

Loading…
Cancel
Save