kotlinjavafxtornadofx

Dynamically updating Polyline points in tornadofx


This question is a bit simplistic, but i couldn't figure it out for myself... What I'm trying to do is using a JavaFX Timeline to update my Polyline points. What I've got until now is as follows:

class MainView : View("Hello TornadoFX") {
    var myLine: Polyline by singleAssign()
    val myTimeline = timeline {
        cycleCount = INDEFINITE
    }

    override val root = hbox {
        myLine = polyline(0.0, 0.0, 100.0, 100.0)
        myTimeline.apply {
            keyFrames += KeyFrame((1/10.0).seconds, {
                myLine.points.forEachIndexed { i, d ->
                    myLine.points[i] = d + 1
                }
                println(myLine.points)
            })
            play()
        }
    }
}

Although the point list does update the values, as shown when printing them, the change is not reflected in the ui.

Thank you very much for your help!


Solution

  • Figured out that the issue was simply using an hbox as the parent layout, instead of a pane, which handles the chidren positioning with absolute coordinates.