MapPanelController.kt 1.27 KB
package application.controller

import application.model.*
import javafx.concurrent.Worker
import javafx.fxml.FXML
import javafx.fxml.Initializable
import javafx.scene.layout.StackPane
import map.LeafletMapView
import map.MapConfig
import map.displayMessageOnMap
import java.net.URL
import java.util.*
import java.util.concurrent.CompletableFuture

class MapPanelController : Initializable {

    @FXML
    private lateinit var map: StackPane

    private val mapView = LeafletMapView()


    override fun initialize(location: URL?, resources: ResourceBundle?) {
        val completeFutureMap: CompletableFuture<Worker.State> = mapView.displayMap(MapConfig())
        observableVessel.listeners.add(object : MessageListener {
            override fun onValueChanged(newValue: MutableMap<Int?, Vessel>) {
                displayMessageOnMap(mapView)
            }
        })

        observableSelectedVessel.listeners.add(object : SelectedVesselListener {
            override fun onValueChanged(newValue: Vessel) {
                displayMessageOnMap(mapView, newValue.mmsi!!)
            }
        })

        /*completeFutureMap.whenComplete{
            workerState, _ ->
            if (workerState == Worker.State.SUCCEEDED) {
            }
        }*/
        map.children.add(mapView)
    }


}