Cleaned up unnecessary entries for the flight point adder

main
YaFedImYaEatIm 9 years ago
parent 12601287b2
commit df6f2a9c93

Binary file not shown.

@ -1189,22 +1189,14 @@ public class Dataset {
* @param id * @param id
* @param name * @param name
* @param type * @param type
* @param via
* @param altitude * @param altitude
* @param latitude * @param latitude
* @param longitude * @param longitude
* @param heading
* @param legDist
* @param totDist
*/ */
public void addFlightPointToPath(int id, String name, String type, String via, String altitude, String latitude, String longitude, public void addFlightPointToPath(int id, String name, String type, String altitude, String latitude, String longitude, int index) throws DataException{
String heading, String legDist, String totDist , int index) throws DataException{
double altitudeVal = 0.0; double altitudeVal = 0.0;
double latitudeVal = 0.0; double latitudeVal = 0.0;
double longitudeVal = 0.0; double longitudeVal = 0.0;
int headingVal = 0;
double legDistVal = 0.0;
double totalDistVal = 0.0;
try{ try{
altitudeVal = Double.parseDouble(altitude); altitudeVal = Double.parseDouble(altitude);
@ -1221,20 +1213,8 @@ public class Dataset {
}catch (NumberFormatException e){ }catch (NumberFormatException e){
throw new DataException("Longitude must be a double value"); throw new DataException("Longitude must be a double value");
} }
try{ if (index == -1){
headingVal = Integer.parseInt(heading); index = flightPathDictionary.get(id).getFlightPoints().size();
}catch (NumberFormatException e){
throw new DataException("Heading must be a integer value");
}
try{
legDistVal = Double.parseDouble(legDist);
}catch (NumberFormatException e){
throw new DataException("Leg DIstance must be a double value");
}
try{
totalDistVal = Double.parseDouble(totDist);
}catch (NumberFormatException e){
throw new DataException("Total Distance must be a double value");
} }
Connection c = null; Connection c = null;
Statement stmt; Statement stmt;
@ -1252,12 +1232,11 @@ public class Dataset {
stmt = c.createStatement(); stmt = c.createStatement();
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," + String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
" `Altitude`, `Latitude`, `Longitude`, `Heading`, `Tot_Dist`, `Leg_Dist`, `Via`, `Order`) VALUES "; " `Altitude`, `Latitude`, `Longitude`, `Order`) VALUES ";
String flightType = type.replace("\"", "\"\""); String flightType = type.replace("\"", "\"\"");
String flightName = name.replace("\"", "\"\""); String flightName = name.replace("\"", "\"\"");
insertFlightPointQuery += "(" + id +", \""+ flightName +"\", \"" + flightType + "\", "+ altitudeVal + ", " + insertFlightPointQuery += "(" + id +", \""+ flightName +"\", \"" + flightType + "\", "+ altitudeVal + ", " +
"" + latitudeVal + ", " + longitudeVal + ", " + headingVal + ", " + totalDistVal + ", " + legDistVal + "" + latitudeVal + ", " + longitudeVal + ", "+index+")";
", \"" + via + "\", "+index+")";
stmt.execute(insertFlightPointQuery); stmt.execute(insertFlightPointQuery);
stmt.close(); stmt.close();
//move all the points after this forward //move all the points after this forward
@ -1297,11 +1276,10 @@ public class Dataset {
System.exit(0); System.exit(0);
} }
FlightPoint pointToAdd = new FlightPoint(name, pointID+1, id, type, via, headingVal, altitudeVal, legDistVal, FlightPoint pointToAdd = new FlightPoint(type, pointID+1, id, name, altitudeVal, latitudeVal, longitudeVal);
totalDistVal,latitudeVal, longitudeVal);
updateFlightPointInfo(flightPathDictionary.get(Integer.valueOf(id)));
flightPathDictionary.get(Integer.valueOf(id)).addFlightPoint(pointToAdd, index); flightPathDictionary.get(Integer.valueOf(id)).addFlightPoint(pointToAdd, index);
flightPointDictionary.put(pointID + 1, pointToAdd); flightPointDictionary.put(pointID + 1, pointToAdd);
updateFlightPointInfo(flightPathDictionary.get(Integer.valueOf(id)));
} }
/*** /***
@ -1311,9 +1289,8 @@ public class Dataset {
* @throws DataException * @throws DataException
*/ */
public void addFlightPointToPath(FlightPoint point, int index) throws DataException{ public void addFlightPointToPath(FlightPoint point, int index) throws DataException{
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()), addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), String.valueOf(point.getAltitude()),
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()), String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()), index);
String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), index);
} }
/*** /***
* Adds a single flight Point to an Existing FLight Path appended on the end of the list. * Adds a single flight Point to an Existing FLight Path appended on the end of the list.
@ -1321,9 +1298,8 @@ public class Dataset {
* @throws DataException * @throws DataException
*/ */
public void addFlightPointToPath(FlightPoint point) throws DataException{ public void addFlightPointToPath(FlightPoint point) throws DataException{
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()), addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), String.valueOf(point.getAltitude()),
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()), String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()), -1);
String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), -1);
} }
/** /**
@ -1331,19 +1307,14 @@ public class Dataset {
* @param id * @param id
* @param name * @param name
* @param type * @param type
* @param via
* @param altitude * @param altitude
* @param latitude * @param latitude
* @param longitude * @param longitude
* @param heading
* @param legDist
* @param totDist
* @throws DataException * @throws DataException
*/ */
public void addFlightPointToPath(int id, String name, String type, String via, String altitude, String latitude, String longitude, public void addFlightPointToPath(int id, String name, String type, String altitude, String latitude, String longitude) throws DataException{
String heading, String legDist, String totDist) throws DataException{ addFlightPointToPath(id, name, type, altitude, latitude, longitude, -1);
addFlightPointToPath(id, name, type, via, altitude, latitude, longitude, heading, legDist, totDist, -1);
} }
/** /**
* This is called in conjunction to the App deleteDataset DO NOT CALL UNLESS THROUGH APP.DELETEDATASET * This is called in conjunction to the App deleteDataset DO NOT CALL UNLESS THROUGH APP.DELETEDATASET

@ -60,6 +60,24 @@ public class FlightPoint {
this.longitude = longitude; this.longitude = longitude;
} }
public FlightPoint(String type, int id, int index, String name, double altitude, double latitude, double longitude){
//extra calculations will have to be used to find heading, legdistance and total distance. If necessary
//Type 1 file the file the lecturers gave us
//indexID = flight path ID
//ID = unique Auto Increment value
this.name = name;
this.ID = id;
this.indexID = index;
this.type = type;
this.via = "";
this.heading = 0;
this.altitude = altitude;
this.legDistance = 0.0;
this.totalDistance = 0.0;
this.latitude = latitude;
this.longitude = longitude;
}
/** /**
* Constructor when getting points from the database. * Constructor when getting points from the database.
* @param name Name for the point. * @param name Name for the point.

@ -18,20 +18,12 @@ public class FlightAddController extends Controller {
@FXML @FXML
private TextField fTypeAdd; private TextField fTypeAdd;
@FXML @FXML
private TextField fViaAdd;
@FXML
private TextField fAltitudeAdd; private TextField fAltitudeAdd;
@FXML @FXML
private TextField fLatitudeAdd; private TextField fLatitudeAdd;
@FXML @FXML
private TextField fLongitudeAdd; private TextField fLongitudeAdd;
@FXML @FXML
private TextField fHeadingAdd;
@FXML
private TextField fLegDistAdd;
@FXML
private TextField fTotDistAdd;
@FXML
private Button flightAddButton; private Button flightAddButton;
//Set an empty Dataset to be assigned later //Set an empty Dataset to be assigned later
@ -49,13 +41,9 @@ public class FlightAddController extends Controller {
theDataSet.addFlightPointToPath(currentSession.getCurrentFlightPathID(), theDataSet.addFlightPointToPath(currentSession.getCurrentFlightPathID(),
fNameAdd.getText(), fNameAdd.getText(),
fTypeAdd.getText(), fTypeAdd.getText(),
fViaAdd.getText(),
fAltitudeAdd.getText(), fAltitudeAdd.getText(),
fLatitudeAdd.getText(), fLatitudeAdd.getText(),
fLongitudeAdd.getText(), fLongitudeAdd.getText());
fHeadingAdd.getText(),
fLegDistAdd.getText(),
fTotDistAdd.getText());
Alert alert = new Alert(Alert.AlertType.INFORMATION); Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Flight Point Add Successful"); alert.setTitle("Flight Point Add Successful");
alert.setHeaderText("New Flight Point added!"); alert.setHeaderText("New Flight Point added!");

@ -154,7 +154,7 @@ public class FlightRDController extends Controller {
public void openAdd() { public void openAdd() {
Session session = getParent().getSession(); Session session = getParent().getSession();
session.setCurrentFlightPathtID(currentPathId); session.setCurrentFlightPathtID(currentPathId);
createPopUpStage(SceneCode.FLIGHT_ADD, 600, 400); createPopUpStage(SceneCode.FLIGHT_ADD, 600, 280);
//flightTableView.setItems(FXCollections.observableArrayList(theDataSet.getAirports())); //flightTableView.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
updateTable(currentPathIndex); updateTable(currentPathIndex);
} }

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
@ -9,7 +14,7 @@
<?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" vgap="10.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightAddController"> <GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="280.0" prefWidth="600.0" vgap="10.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.FlightAddController">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="280.0" minWidth="10.0" prefWidth="125.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="280.0" minWidth="10.0" prefWidth="125.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="515.0" minWidth="10.0" prefWidth="402.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="515.0" minWidth="10.0" prefWidth="402.0" />
@ -22,10 +27,6 @@
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<padding> <padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
@ -46,50 +47,26 @@
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" /> <Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
</GridPane.margin> </GridPane.margin>
</Label> </Label>
<Label text="Altitude" GridPane.halignment="LEFT" GridPane.rowIndex="4"> <Label text="Altitude" GridPane.halignment="LEFT" GridPane.rowIndex="3">
<GridPane.margin> <GridPane.margin>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" /> <Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
</GridPane.margin> </GridPane.margin>
</Label> </Label>
<Label text="Latitude" GridPane.halignment="LEFT" GridPane.rowIndex="5"> <Label text="Latitude" GridPane.halignment="LEFT" GridPane.rowIndex="4">
<GridPane.margin> <GridPane.margin>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" /> <Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
</GridPane.margin> </GridPane.margin>
</Label> </Label>
<Label text="Longitude" GridPane.halignment="LEFT" GridPane.rowIndex="6"> <Label text="Longitude" GridPane.halignment="LEFT" GridPane.rowIndex="5">
<GridPane.margin> <GridPane.margin>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" /> <Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
</GridPane.margin> </GridPane.margin>
</Label> </Label>
<Button fx:id="flightAddButton" mnemonicParsing="false" onAction="#addFlight" text="Add Flight" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="10" /> <Button fx:id="flightAddButton" mnemonicParsing="false" onAction="#addFlight" text="Add Flight Point" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="6" />
<TextField fx:id="fNameAdd" prefHeight="31.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="1" /> <TextField fx:id="fNameAdd" prefHeight="31.0" prefWidth="432.0" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="1" />
<TextField fx:id="fTypeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="2" /> <TextField fx:id="fTypeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="2" />
<TextField fx:id="fAltitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="4" /> <TextField fx:id="fAltitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="3" />
<TextField fx:id="fLatitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="5" /> <TextField fx:id="fLatitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="4" />
<TextField fx:id="fLongitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="6" /> <TextField fx:id="fLongitudeAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="5" />
<Label text="Via" GridPane.rowIndex="3">
<GridPane.margin>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
</GridPane.margin>
</Label>
<Label text="Heading" GridPane.rowIndex="7">
<GridPane.margin>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
</GridPane.margin>
</Label>
<Label text="Leg Distance" GridPane.rowIndex="8">
<GridPane.margin>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
</GridPane.margin>
</Label>
<Label text="Total Distance" GridPane.rowIndex="9">
<GridPane.margin>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
</GridPane.margin>
</Label>
<TextField fx:id="fViaAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="3" />
<TextField fx:id="fHeadingAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="7" />
<TextField fx:id="fLegDistAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="8" />
<TextField fx:id="fTotDistAdd" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="9" />
</children> </children>
</GridPane> </GridPane>

Loading…
Cancel
Save