Blame view
src/main/kotlin/application/controller/MapPanelController.kt
2.24 KB
53f01ecc3 display message o... |
1 |
package application.controller |
2bbe36a1b addd the possibil... |
2 |
import application.model.* |
9e952e84e add message clust... |
3 |
import application.model.State.* |
53f01ecc3 display message o... |
4 5 6 7 |
import javafx.concurrent.Worker import javafx.fxml.FXML import javafx.fxml.Initializable import javafx.scene.layout.StackPane |
9e952e84e add message clust... |
8 |
import map.* |
53f01ecc3 display message o... |
9 10 11 |
import java.net.URL import java.util.* import java.util.concurrent.CompletableFuture |
2bbe36a1b addd the possibil... |
12 |
class MapPanelController : Initializable { |
53f01ecc3 display message o... |
13 14 15 16 17 18 19 20 21 |
@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()) |
9e952e84e add message clust... |
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
setObservableVesselListener() setObservableSelectedVesselListener() setStateListener() /*completeFutureMap.whenComplete{ workerState, _ -> if (workerState == Worker.State.SUCCEEDED) { } }*/ map.children.add(mapView) map.children } private fun setStateListener() { observableState.listeners.add(object : StateListener { override fun onValueChanged(newValue: State) { updateMap() } }) } private fun updateMap() { when(observableState.state){ ALL_MESSAGES -> displayAllMessageOnMap(mapView) CLUSTERED_MESSAGES -> displayClusterMessageOnMap(mapView) HEAT_MAP -> displayHeatMapOnMap(mapView) } } private fun updateMap(selectedMMSI: Int) { when(observableState.state){ ALL_MESSAGES -> displayAllMessageOnMap(mapView, selectedMMSI) CLUSTERED_MESSAGES -> displayClusterMessageOnMap(mapView, selectedMMSI) HEAT_MAP -> displayHeatMapOnMap(mapView, selectedMMSI) } } private fun setObservableVesselListener() { |
2bbe36a1b addd the possibil... |
60 61 |
observableVessel.listeners.add(object : MessageListener { override fun onValueChanged(newValue: MutableMap<Int?, Vessel>) { |
9e952e84e add message clust... |
62 |
updateMap() |
2bbe36a1b addd the possibil... |
63 64 |
} }) |
9e952e84e add message clust... |
65 |
} |
2bbe36a1b addd the possibil... |
66 |
|
9e952e84e add message clust... |
67 |
private fun setObservableSelectedVesselListener() { |
2bbe36a1b addd the possibil... |
68 69 |
observableSelectedVessel.listeners.add(object : SelectedVesselListener { override fun onValueChanged(newValue: Vessel) { |
9e952e84e add message clust... |
70 |
updateMap(newValue.mmsi!!) |
2bbe36a1b addd the possibil... |
71 72 |
} }) |
53f01ecc3 display message o... |
73 |
} |
53f01ecc3 display message o... |
74 75 |
} |