# Give some examples (Unfolding library)

**URL:** https://discourse.processing.org/t/give-some-examples-unfolding-library/44362
**Category:** Libraries
**Created:** [April 28, 2024, 11:29pm UTC](https://discourse.processing.org/t/give-some-examples-unfolding-library/44362 "2024-04-28T23:29:36Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Ciosiek](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@Ciosiek](https://discourse.processing.org/u/Ciosiek)
#### Post date: [April 28, 2024, 11:29pm UTC](https://discourse.processing.org/t/give-some-examples-unfolding-library/44362/1 "2024-04-28T23:29:36Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [April 29, 2024, 5:17am UTC](https://discourse.processing.org/t/give-some-examples-unfolding-library/44362/2 "2024-04-29T05:17:58Z")

</div>

Can we see your entire code please

I used unfolding once but not javafx version

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [April 29, 2024, 10:55am UTC](https://discourse.processing.org/t/give-some-examples-unfolding-library/44362/3 "2024-04-29T10:55:22Z")

</div>

> [@Ciosiek](#):
>
> Can you provide me with simple example how to make working processing 4 with javafx

You must import the JavaFX library (only rendering supported) with Processing 4:

```auto
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](https://github.com/benfry/processing4/issues/522)
- [Error trying to import JavaFX classes in Processing 4 · Issue #15 · processing/processing4-javafx · GitHub](https://github.com/processing/processing4-javafx/issues/15)

Some work arounds:

- [JavaFX Unable to add modules to Processing IDE - #5 by svan](https://discourse.processing.org/t/javafx-unable-to-add-modules-to-processing-ide/41272/5)
- [Webview in Processing](https://discourse.processing.org/t/webview-in-processing/42599)

> [@Ciosiek](#):
>
> i’m trying to use processing 4 because it’s needed for Unfolding 0.9.6 library for javafx

Are you referring to this? This is a _[fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo)_ and I do not use this version.

- [GitHub - jimbok8/unfoldingFX: Integration of unfolding with JavaFX. A library to create interactive maps and geovisualizations in Processing and Java](https://github.com/jimbok8/unfoldingFX)

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_:

 ![Capture](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/c/ec77796cf5077293ecc84d1e36f6df4a2b852efa.png)

The latest Unfolding 0.9.92 link is available here and I am using it with success in Processing 4.3:

- [Template with examples not working · Issue #167 · tillnagel/unfolding · GitHub](https://github.com/tillnagel/unfolding/issues/167)

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:

- [mouseWheel() not working when using FX2D renderer · Issue #4169 · processing/processing · GitHub](https://github.com/processing/processing/issues/4169)

Have fun with this!

`:)`

---

<div class="post-metadata">

### Author: ![Ciosiek](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@Ciosiek](https://discourse.processing.org/u/Ciosiek)
#### Post date: [April 29, 2024, 1:46pm UTC](https://discourse.processing.org/t/give-some-examples-unfolding-library/44362/4 "2024-04-29T13:46:58Z")

</div>

The thing is I’m not using your sketchbook, but rather VS Code. I’m talking about this library: [http://unfoldingmaps.org/](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.

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [May 1, 2024, 2:32am UTC](https://discourse.processing.org/t/give-some-examples-unfolding-library/44362/5 "2024-05-01T02:32:06Z")

</div>

Hello @Ciosiek ,

This example uses _Processing 4.3_ library and _Unfolding 0.9.92_ library and worked in _Visual Studio Code 1.88.1_:

```auto
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);
        }
    }
}

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/b/5b8b22b574dfd4e838abd43af580cd121e93d183.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/2/7268930f0a3629155204863c5cae13ec15bb32da.jpeg)

This is a link to the _Unfolding 0.9.92_ library I used:

- [Template with examples not working · Issue #167 · tillnagel/unfolding · GitHub](https://github.com/tillnagel/unfolding/issues/167) \< 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:

```auto
{
    // 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:

> **[Unfolding Maps: Downloads](http://unfoldingmaps.org/downloads)**
>
> Mapping Library For Processing And Java

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!

`:)`

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [May 1, 2024, 5:43am UTC](https://discourse.processing.org/t/give-some-examples-unfolding-library/44362/6 "2024-05-01T05:43:17Z")

</div>

> 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.

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [June 15, 2024, 12:36pm UTC](https://discourse.processing.org/t/give-some-examples-unfolding-library/44362/7 "2024-06-15T12:36:35Z")

</div>

There is an updated link to Unfolding 0.9.92 here:

> <https://github.com/tillnagel/unfolding/pull/119>
>
> Added compilation with Maven, and distribution with shell script.

These worked for me in Processing 4.3 and in Java code (modified for VS Code).

`:)`

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [June 15, 2024, 3:11pm UTC](https://discourse.processing.org/t/give-some-examples-unfolding-library/44362/8 "2024-06-15T15:11:42Z")

</div>

my program for this is described here: [What I am working on (my current projects)](https://discourse.processing.org/t/what-i-am-working-on-my-current-projects/44258)

(number 6)
