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