Hello, i’m trying to use processing 4 because it’s needed for Unfolding 0.9.6 library for javafx. Can you provide me with simple example how to make working processing 4 with javafx? I’m doing an application and I cannot make it working with simple hello world. Please help me.
Can we see your entire code please
I used unfolding once but not javafx version
You must import the JavaFX library (only rendering supported) with Processing 4:
import processing.javafx.*;
void setup()
{
size(200, 200, FX2D);
}
void draw()
{
}
See related issues with JavaFX and Processing 4:
- Implement ability to include module jars for preproc, completion, et al · Issue #522 · benfry/processing4 · GitHub
- Error trying to import JavaFX classes in Processing 4 · Issue #15 · processing/processing4-javafx · GitHub
Some work arounds:
Are you referring to this? This is a fork and I do not use this version.
You must clearly communicate what library you are using and provide a link if unclear.
In this case the Unfolding FX fork above (10 years old) may not be supported.
I do not use the Unfolding FX fork and can’t comment on it or support it.
This is the current Unfolding library 0.9.6 listed in Processing 4 and it states not compatible:
The latest Unfolding 0.9.92 link is available here and I am using it with success in Processing 4.3:
If I try to use the FX2D renderer with the 0.9.92 version in Processing 4.3 IDE there are issues with scrolling with mouse wheel.
I was able to scroll with the numpad + and - keys. :)
Scrolling issue with FX2D that seems to have carried over to Processing 4:
Have fun with this!
:)
The thing is I’m not using your sketchbook, but rather VS Code. I’m talking about this library: http://unfoldingmaps.org/. I’m importing all the libraries successfully but cannot make it work. I understand how to use setup() draw() and setting () but when it comes to start processing with PApplet i don’t know how to make display in a window with javafx or not. I saw that main method is inside the same file as sketch but i was trying with something like PApplet.main() to start this sketch.
String mainSketch = concat(new String { getSketchClassName() }, args);
PApplet.main(mainSketch);
I’m asking if you can provide simple java implementation of this library when used from main in different folder like:
src.my.package
┗ main
┗ Main.java
┗ visualizations.sketch
┗sketch.java
In Main.java I have my code and I reference object from Sketch.java. Please let me know if you need any further information.
Hello @Ciosiek ,
This example uses Processing 4.3 library and Unfolding 0.9.92 library and worked in Visual Studio Code 1.88.1:
import processing.core.*;
import java.util.List;
import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.data.Feature;
//import de.fhpotsdam.unfolding.geo.Location;
import de.fhpotsdam.unfolding.marker.Marker;
import de.fhpotsdam.unfolding.utils.MapUtils;
import de.fhpotsdam.unfolding.data.GPXReader; //GPX Reader
public class App extends PApplet {
UnfoldingMap map;
public void setup() {
map = new UnfoldingMap(this, 0, 0, width, height);
MapUtils.createDefaultEventDispatcher(this, map);
// Load location
String url1 = "https://raw.githubusercontent.com/gps-touring/sample-gpx/master/RoscoffCoastal/Trebeurden_Lannion_parcours13.2RE.gpx";
List<Feature> features = GPXReader.loadData(this, url1);
List<Marker> markers = MapUtils.createSimpleMarkers(features);
map.addMarkers(markers);
map.zoomAndPanToFitAllMarkers();
}
public void draw() {
background(240);
// Draw map tiles and country markers
map.draw();
}
public void settings() {
size(800, 600, P2D);
}
static public void main(String[] passedArgs) {
String[] appletArgs = new String[] { "App" };
if (passedArgs != null) {
PApplet.main(concat(appletArgs, passedArgs));
} else {
PApplet.main(appletArgs);
}
}
}
This is a link to the Unfolding 0.9.92 library I used:
- Template with examples not working · Issue #167 · tillnagel/unfolding · GitHub < See link in second post!
I did initially have this issue in Virtual Studio Code:
java.lang.UnsatisfiedLinkError: Can't load library: D:\Users\GLV\Documents\VS Code\P4.3\test_java 1 0 0\Test\natives\windows-amd64\gluegen_rt.dll
Adding the line with vmArgs (for my system) to the launch.json resolved the issue:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "App",
"request": "launch",
"mainClass": "App",
"projectName": "Test_8db5bd73",
"vmArgs": "-Djava.library.path=D:\\Program_Portable\\processing-4.3\\core\\library\\windows-amd64"
}
]
}
I did not use these in my exploration since I am working with the latest Unfolding 0.9.92 version:
This was my first effort using Visual Studio Code and was able to make this work with some effort. Some experience with Eclipse helped.
I may keep using Visual Code Studio!
Keep at it!
:)
About
Integration of unfolding with JavaFX. A library to create interactive maps and geovisualizations in Processing and Java
The reference above to Tillnagel’s work is several years old and unless I missed it, there is no JavaFX code; the title “Unfolding 0.9.6 library for JavaFX” is a bit deceiving in my opinion.
There is an updated link to Unfolding 0.9.92 here:
These worked for me in Processing 4.3 and in Java code (modified for VS Code).
:)
my program for this is described here: What I am working on (my current projects)
(number 6)