Blame view
src/main/kotlin/application/controller/MapPanelController.kt
2.91 KB
53f01ecc3 display message o... |
1 |
package application.controller |
2bbe36a1b addd the possibil... |
2 |
import application.model.* |
3b26be8f9 controle the time... |
3 |
import application.model.MapState.* |
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() |
3b26be8f9 controle the time... |
24 |
observableCurrentTime() |
79b001037 heat map |
25 26 |
/*val completeFutureMap: CompletableFuture<Worker.State> = mapView.displayMap(MapConfig()) completeFutureMap.whenComplete{ |
9e952e84e add message clust... |
27 28 29 30 31 32 33 34 35 |
workerState, _ -> if (workerState == Worker.State.SUCCEEDED) { } }*/ map.children.add(mapView) map.children } private fun setStateListener() { |
3b26be8f9 controle the time... |
36 37 |
observableMapState.listeners.add(object : StateListener { override fun onValueChanged(newValue: MapState) { |
79b001037 heat map |
38 39 40 41 42 |
if (observableSelectedVessel.vessel.mmsi != null) { updateMap(observableSelectedVessel.vessel.mmsi!!) } else { updateMap() } |
9e952e84e add message clust... |
43 44 45 |
} }) } |
3b26be8f9 controle the time... |
46 47 48 49 50 51 52 |
private fun observableCurrentTime() { observableCurrentTime.listeners.add(object : CurrentTime{ override fun onValueChanged(newValue: Int) { updateMap() } }) } |
9e952e84e add message clust... |
53 |
private fun updateMap() { |
3b26be8f9 controle the time... |
54 55 56 57 58 59 60 61 |
if (observableIsReplayState.value){ displayTargetedVessels(mapView) } else { when (observableMapState.state) { ALL_MESSAGES -> displayAllMessageOnMap(mapView) CLUSTERED_MESSAGES -> displayClusterMessageOnMap(mapView) HEAT_MAP -> displayHeatMapOnMap(mapView) } |
9e952e84e add message clust... |
62 63 |
} } |
f39d90e60 Select/deselect MMSI |
64 |
private fun updateMap(selectedMMSI: String) { |
3b26be8f9 controle the time... |
65 |
when (observableMapState.state) { |
79b001037 heat map |
66 |
ALL_MESSAGES -> displayAllMessageOnMap(mapView, selectedMMSI) |
9e952e84e add message clust... |
67 68 69 70 71 72 |
CLUSTERED_MESSAGES -> displayClusterMessageOnMap(mapView, selectedMMSI) HEAT_MAP -> displayHeatMapOnMap(mapView, selectedMMSI) } } private fun setObservableVesselListener() { |
2bbe36a1b addd the possibil... |
73 |
observableVessel.listeners.add(object : MessageListener { |
f39d90e60 Select/deselect MMSI |
74 |
override fun onValueChanged(newValue: MutableMap<String?, Vessel>) { |
9e952e84e add message clust... |
75 |
updateMap() |
2bbe36a1b addd the possibil... |
76 77 |
} }) |
9e952e84e add message clust... |
78 |
} |
2bbe36a1b addd the possibil... |
79 |
|
9e952e84e add message clust... |
80 |
private fun setObservableSelectedVesselListener() { |
2bbe36a1b addd the possibil... |
81 82 |
observableSelectedVessel.listeners.add(object : SelectedVesselListener { override fun onValueChanged(newValue: Vessel) { |
79b001037 heat map |
83 84 |
if (newValue.mmsi != null){ updateMap(newValue.mmsi) |
f39d90e60 Select/deselect MMSI |
85 86 |
}else { updateMap() |
79b001037 heat map |
87 |
} |
2bbe36a1b addd the possibil... |
88 89 |
} }) |
53f01ecc3 display message o... |
90 |
} |
53f01ecc3 display message o... |
91 92 |
} |