Commit f99a7d28 authored by duminil's avatar duminil
Browse files

Cross-Platform JavaFX Region Chooser.

parent f8155886
package eu.simstadt.regionchooser; package eu.simstadt.regionchooser;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import javafx.application.Application; import javafx.application.Application;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
...@@ -36,8 +38,14 @@ public static void main(String[] args) { ...@@ -36,8 +38,14 @@ public static void main(String[] args) {
class Browser extends Region class Browser extends Region
{ {
public class JavaApp public class JavaScriptFXBridge
{ {
private Path repo;
public JavaScriptFXBridge() {
repo = Paths.get("../TestRepository");
}
public void downloadRegion(String wktPolygon) { public void downloadRegion(String wktPolygon) {
System.out.println("FROM JAVA : DO SOMETHING with " + wktPolygon); System.out.println("FROM JAVA : DO SOMETHING with " + wktPolygon);
} }
...@@ -47,8 +55,14 @@ public void downloadRegionFromCityGML(String wktPolygon, String citygmlDescripti ...@@ -47,8 +55,14 @@ public void downloadRegionFromCityGML(String wktPolygon, String citygmlDescripti
} }
public boolean checkIfCityGMLSAreAvailable(String citygmlDescription) { public boolean checkIfCityGMLSAreAvailable(String citygmlDescription) {
//TODO: IMPLEMENT ME boolean available = false;
return true; String[] projectAndCityGML = citygmlDescription.split(">");
if (projectAndCityGML.length == 2) {
String project = projectAndCityGML[0];
String citygml = projectAndCityGML[1];
available = Files.isReadable(repo.resolve(project + ".simstadt").resolve(citygml));
}
return available;
} }
} }
...@@ -59,15 +73,14 @@ public Browser() { ...@@ -59,15 +73,14 @@ public Browser() {
//apply the styles //apply the styles
getStyleClass().add("browser"); getStyleClass().add("browser");
// load the web page // load the web page
String url = "file://" + Paths.get("../RegionChooser/website/index.html").toAbsolutePath().toString(); String url = Paths.get("../RegionChooser/website/index.html").toUri().toString();
webEngine.load(url); webEngine.load(url);
// process page loading // process page loading
webEngine.getLoadWorker().stateProperty().addListener( webEngine.getLoadWorker().stateProperty().addListener(
(ObservableValue<? extends State> ov, State oldState, (ObservableValue<? extends State> ov, State oldState, State newState) -> {
State newState) -> {
if (newState == State.SUCCEEDED) { if (newState == State.SUCCEEDED) {
JSObject win = (JSObject) webEngine.executeScript("window"); JSObject win = (JSObject) webEngine.executeScript("window");
win.setMember("fxapp", new JavaApp()); win.setMember("fxapp", new JavaScriptFXBridge());
} }
}); });
//add the web view to the scene //add the web view to the 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