Blame view
src/main/kotlin/application/controller/MapPanelController.kt
2.51 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 |
import javafx.fxml.FXML import javafx.fxml.Initializable import javafx.scene.layout.StackPane |
9e952e84e add message clust... |
7 |
import map.* |
53f01ecc3 display message o... |
8 9 |
import java.net.URL import java.util.* |
53f01ecc3 display message o... |
10 |
|
2bbe36a1b addd the possibil... |
11 |
class MapPanelController : Initializable { |
53f01ecc3 display message o... |
12 13 14 15 16 17 18 19 |
@FXML private lateinit var map: StackPane private val mapView = LeafletMapView() override fun initialize(location: URL?, resources: ResourceBundle?) { |
79b001037 heat map |
20 |
mapView.displayMap(MapConfig()) |
9e952e84e add message clust... |
21 22 23 |
setObservableVesselListener() setObservableSelectedVesselListener() setStateListener() |
79b001037 heat map |
24 25 |
/*val completeFutureMap: CompletableFuture<Worker.State> = mapView.displayMap(MapConfig()) completeFutureMap.whenComplete{ |
9e952e84e add message clust... |
26 27 28 29 30 31 32 33 34 35 36 |
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) { |
79b001037 heat map |
37 38 39 40 41 |
if (observableSelectedVessel.vessel.mmsi != null) { updateMap(observableSelectedVessel.vessel.mmsi!!) } else { updateMap() } |
9e952e84e add message clust... |
42 43 44 45 46 |
} }) } private fun updateMap() { |
79b001037 heat map |
47 48 |
when (observableState.state) { ALL_MESSAGES -> displayAllMessageOnMap(mapView) |
9e952e84e add message clust... |
49 50 51 52 |
CLUSTERED_MESSAGES -> displayClusterMessageOnMap(mapView) HEAT_MAP -> displayHeatMapOnMap(mapView) } } |
f39d90e60 Select/deselect MMSI |
53 |
private fun updateMap(selectedMMSI: String) { |
79b001037 heat map |
54 55 |
when (observableState.state) { ALL_MESSAGES -> displayAllMessageOnMap(mapView, selectedMMSI) |
9e952e84e add message clust... |
56 57 58 59 60 61 |
CLUSTERED_MESSAGES -> displayClusterMessageOnMap(mapView, selectedMMSI) HEAT_MAP -> displayHeatMapOnMap(mapView, selectedMMSI) } } private fun setObservableVesselListener() { |
2bbe36a1b addd the possibil... |
62 |
observableVessel.listeners.add(object : MessageListener { |
f39d90e60 Select/deselect MMSI |
63 |
override fun onValueChanged(newValue: MutableMap<String?, Vessel>) { |
9e952e84e add message clust... |
64 |
updateMap() |
2bbe36a1b addd the possibil... |
65 66 |
} }) |
9e952e84e add message clust... |
67 |
} |
2bbe36a1b addd the possibil... |
68 |
|
9e952e84e add message clust... |
69 |
private fun setObservableSelectedVesselListener() { |
2bbe36a1b addd the possibil... |
70 71 |
observableSelectedVessel.listeners.add(object : SelectedVesselListener { override fun onValueChanged(newValue: Vessel) { |
79b001037 heat map |
72 73 |
if (newValue.mmsi != null){ updateMap(newValue.mmsi) |
f39d90e60 Select/deselect MMSI |
74 75 |
}else { updateMap() |
79b001037 heat map |
76 |
} |
2bbe36a1b addd the possibil... |
77 78 |
} }) |
53f01ecc3 display message o... |
79 |
} |
53f01ecc3 display message o... |
80 81 |
} |