Commit 359e7d6d authored by kai's avatar kai
Browse files

Added button and text area for creating and displaying an export job. This job...

Added button and text area for creating and displaying an export job. This job is now executed in a background thread.
parent 2a3922b8
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.VBox?> <?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import com.lynden.gmapsfx.GoogleMapView?> <?import com.lynden.gmapsfx.GoogleMapView?>
<AnchorPane id="AnchorPane" fx:controller="eu.simstadt.regionchooser.RegionChooserController" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<GoogleMapView fx:id="mapView" prefHeight="750.0" prefWidth="750.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
<VBox alignment="TOP_CENTER" fillWidth="false" layoutX="26.0" layoutY="29.0" prefHeight="478.0" prefWidth="221.0" spacing="10.0" styleClass="panel-background" stylesheets="@../styles/Styles.css"
AnchorPane.bottomAnchor="50.0" AnchorPane.leftAnchor="26.0" AnchorPane.topAnchor="88.0"> <BorderPane fx:controller="eu.simstadt.regionchooser.RegionChooserController" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
</VBox> <center>
</children> <GoogleMapView fx:id="mapView" prefHeight="750.0" prefWidth="750.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</AnchorPane> </center>
<bottom>
<HBox BorderPane.alignment="CENTER">
<children>
<Button mnemonicParsing="false" onAction="#generateExportJob" text="Generate Export Job" />
<TextArea fx:id="outputTA" wrapText="true" />
</children>
</HBox>
</bottom>
</BorderPane>
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Button; import javafx.scene.control.TextArea;
import com.lynden.gmapsfx.GoogleMapView; import com.lynden.gmapsfx.GoogleMapView;
import com.lynden.gmapsfx.MapComponentInitializedListener; import com.lynden.gmapsfx.MapComponentInitializedListener;
import com.lynden.gmapsfx.javascript.object.GoogleMap; import com.lynden.gmapsfx.javascript.object.GoogleMap;
...@@ -16,14 +17,16 @@ ...@@ -16,14 +17,16 @@
import com.lynden.gmapsfx.javascript.object.MapTypeIdEnum; import com.lynden.gmapsfx.javascript.object.MapTypeIdEnum;
import com.lynden.gmapsfx.javascript.object.Marker; import com.lynden.gmapsfx.javascript.object.Marker;
import com.lynden.gmapsfx.javascript.object.MarkerOptions; import com.lynden.gmapsfx.javascript.object.MarkerOptions;
import eu.simstadt.nf.Coord; import eu.simstadt.nf.Coord;
import eu.simstadt.nf.NFJobBuilder; import eu.simstadt.nf.NFJobBuilder;
public class RegionChooserController implements MapComponentInitializedListener {
public class RegionChooserController implements MapComponentInitializedListener
{
List<Coord> regionPolygon;
@FXML @FXML
private Button button; private TextArea outputTA;
@FXML @FXML
private GoogleMapView mapView; private GoogleMapView mapView;
...@@ -42,18 +45,17 @@ public void mapInitialized() { ...@@ -42,18 +45,17 @@ public void mapInitialized() {
LatLong stuttgartLoc = new LatLong(48.878323, 9.216613); LatLong stuttgartLoc = new LatLong(48.878323, 9.216613);
LatLong dresdenLoc = new LatLong(48.879402, 9.216532); LatLong dresdenLoc = new LatLong(48.879402, 9.216532);
//Set the initial properties of the map. //Set the initial properties of the map.
MapOptions mapOptions = new MapOptions(); MapOptions mapOptions = new MapOptions();
mapOptions.center(new LatLong(51.3, 11.0)) mapOptions.center(new LatLong(51.3, 11.0))
.mapType(MapTypeIdEnum.ROADMAP) .mapType(MapTypeIdEnum.ROADMAP)
.overviewMapControl(false) .overviewMapControl(true)
.panControl(false) .panControl(false)
.rotateControl(false) .rotateControl(false)
.scaleControl(false) .scaleControl(false)
.streetViewControl(false) .streetViewControl(false)
.zoomControl(false) .zoomControl(true)
.zoom(7); .zoom(7);
map = mapView.createMap(mapOptions); map = mapView.createMap(mapOptions);
...@@ -86,15 +88,32 @@ public void mapInitialized() { ...@@ -86,15 +88,32 @@ public void mapInitialized() {
InfoWindow bochumInfoWindow = new InfoWindow(infoWindowOptions); InfoWindow bochumInfoWindow = new InfoWindow(infoWindowOptions);
bochumInfoWindow.open(map, bochumMarker); bochumInfoWindow.open(map, bochumMarker);
// Build the nF export job description from a region polygon regionPolygon = Arrays.asList(
List<Coord> regionPolygon = Arrays.asList(
new Coord(bochumLoc.getLatitude(), bochumLoc.getLongitude()), new Coord(bochumLoc.getLatitude(), bochumLoc.getLongitude()),
new Coord(hamburgLoc.getLatitude(), bochumLoc.getLongitude()), new Coord(hamburgLoc.getLatitude(), bochumLoc.getLongitude()),
new Coord(stuttgartLoc.getLatitude(), bochumLoc.getLongitude()), new Coord(stuttgartLoc.getLatitude(), bochumLoc.getLongitude()),
new Coord(dresdenLoc.getLatitude(), bochumLoc.getLongitude()) new Coord(dresdenLoc.getLatitude(), bochumLoc.getLongitude())
); );
String exportJobDescription = NFJobBuilder.buildExportJob(regionPolygon); }
System.out.println(exportJobDescription);
// Build the nF export job description from a region polygon
@FXML
void generateExportJob(ActionEvent event) {
Service<String> exportRunner = new Service<String>() {
@Override
protected Task<String> createTask() {
return new Task<String>() {
@Override
protected String call() throws Exception {
return NFJobBuilder.buildExportJob(regionPolygon);
}
};
}
};
exportRunner.setOnSucceeded(state -> {
outputTA.setText(exportRunner.getValue());
});
exportRunner.start();
} }
} }
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.BorderPane;
import javafx.stage.Stage; import javafx.stage.Stage;
...@@ -12,7 +12,7 @@ public class RegionChooserMain extends Application ...@@ -12,7 +12,7 @@ public class RegionChooserMain extends Application
@Override @Override
public void start(Stage primaryStage) { public void start(Stage primaryStage) {
try { try {
AnchorPane root = (AnchorPane) FXMLLoader.load(getClass().getResource("RegionChooser.fxml")); BorderPane root = (BorderPane) FXMLLoader.load(getClass().getResource("RegionChooser.fxml"));
Scene scene = new Scene(root, 750, 750); Scene scene = new Scene(root, 750, 750);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene); primaryStage.setScene(scene);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment