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