Commit f99a7d28 authored by duminil's avatar duminil
Browse files

Cross-Platform JavaFX Region Chooser.

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