Commit 93534e6934081af5ee10c423e560a20800ffba5e
1 parent
867a0df461
Exists in
master
and in
1 other branch
fix exception
Showing 1 changed file with 1 additions and 1 deletions Inline Diff
src/main/kotlin/application/controller/DataPanelController.kt
View file @
93534e6
package application.controller | 1 | 1 | package application.controller | |
2 | 2 | |||
import application.model.* | 3 | 3 | import application.model.* | |
import javafx.collections.FXCollections | 4 | 4 | import javafx.collections.FXCollections | |
import javafx.collections.ObservableList | 5 | 5 | import javafx.collections.ObservableList | |
import javafx.fxml.FXML | 6 | 6 | import javafx.fxml.FXML | |
import javafx.fxml.Initializable | 7 | 7 | import javafx.fxml.Initializable | |
import javafx.scene.control.ListCell | 8 | 8 | import javafx.scene.control.ListCell | |
import javafx.scene.control.ListView | 9 | 9 | import javafx.scene.control.ListView | |
import kotlinx.coroutines.GlobalScope | 10 | 10 | import kotlinx.coroutines.GlobalScope | |
import kotlinx.coroutines.launch | 11 | 11 | import kotlinx.coroutines.launch | |
import org.charts.dataviewer.api.config.DataViewerConfiguration | 12 | 12 | import org.charts.dataviewer.api.config.DataViewerConfiguration | |
import org.charts.dataviewer.api.data.PlotData | 13 | 13 | import org.charts.dataviewer.api.data.PlotData | |
import org.charts.dataviewer.api.trace.ScatterTrace | 14 | 14 | import org.charts.dataviewer.api.trace.ScatterTrace | |
import org.charts.dataviewer.javafx.JavaFxDataViewer | 15 | 15 | import org.charts.dataviewer.javafx.JavaFxDataViewer | |
import org.charts.dataviewer.utils.TraceColour | 16 | 16 | import org.charts.dataviewer.utils.TraceColour | |
import org.charts.dataviewer.utils.TraceVisibility | 17 | 17 | import org.charts.dataviewer.utils.TraceVisibility | |
import java.net.URL | 18 | 18 | import java.net.URL | |
import java.util.* | 19 | 19 | import java.util.* | |
20 | 20 | |||
21 | 21 | |||
class DataPanelController : Initializable, SelectedVesselListener { | 22 | 22 | class DataPanelController : Initializable, SelectedVesselListener { | |
private var dataList: ObservableList<Pair<String, ArrayList<MessageData?>>> = FXCollections.observableArrayList() | 23 | 23 | private var dataList: ObservableList<Pair<String, ArrayList<MessageData?>>> = FXCollections.observableArrayList() | |
private lateinit var timeData: ArrayList<MessageData?> | 24 | 24 | private lateinit var timeData: ArrayList<MessageData?> | |
25 | 25 | |||
private val latitude: ArrayList<MessageData?> = arrayListOf() | 26 | 26 | private val latitude: ArrayList<MessageData?> = arrayListOf() | |
private val longitude: ArrayList<MessageData?> = arrayListOf() | 27 | 27 | private val longitude: ArrayList<MessageData?> = arrayListOf() | |
private val speedOverGround: ArrayList<MessageData?> = arrayListOf() | 28 | 28 | private val speedOverGround: ArrayList<MessageData?> = arrayListOf() | |
private val courseOverGround: ArrayList<MessageData?> = arrayListOf() | 29 | 29 | private val courseOverGround: ArrayList<MessageData?> = arrayListOf() | |
private val heading: ArrayList<MessageData?> = arrayListOf() | 30 | 30 | private val heading: ArrayList<MessageData?> = arrayListOf() | |
private val vesselName: ArrayList<MessageData?> = arrayListOf() | 31 | 31 | private val vesselName: ArrayList<MessageData?> = arrayListOf() | |
private val imo: ArrayList<MessageData?> = arrayListOf() | 32 | 32 | private val imo: ArrayList<MessageData?> = arrayListOf() | |
private val callSign: ArrayList<MessageData?> = arrayListOf() | 33 | 33 | private val callSign: ArrayList<MessageData?> = arrayListOf() | |
private val vesselType: ArrayList<MessageData?> = arrayListOf() | 34 | 34 | private val vesselType: ArrayList<MessageData?> = arrayListOf() | |
private val status: ArrayList<MessageData?> = arrayListOf() | 35 | 35 | private val status: ArrayList<MessageData?> = arrayListOf() | |
private val length: ArrayList<MessageData?> = arrayListOf() | 36 | 36 | private val length: ArrayList<MessageData?> = arrayListOf() | |
private val width: ArrayList<MessageData?> = arrayListOf() | 37 | 37 | private val width: ArrayList<MessageData?> = arrayListOf() | |
private val draft: ArrayList<MessageData?> = arrayListOf() | 38 | 38 | private val draft: ArrayList<MessageData?> = arrayListOf() | |
private val cargo: ArrayList<MessageData?> = arrayListOf() | 39 | 39 | private val cargo: ArrayList<MessageData?> = arrayListOf() | |
40 | 40 | |||
private var selectedItem: Pair<String, ArrayList<MessageData?>>? = null | 41 | 41 | private var selectedItem: Pair<String, ArrayList<MessageData?>>? = null | |
42 | 42 | |||
@FXML | 43 | 43 | @FXML | |
var dataListView = ListView<Pair<String, ArrayList<MessageData?>>>() | 44 | 44 | var dataListView = ListView<Pair<String, ArrayList<MessageData?>>>() | |
45 | 45 | |||
@FXML | 46 | 46 | @FXML | |
var dataViewer = JavaFxDataViewer() | 47 | 47 | var dataViewer = JavaFxDataViewer() | |
48 | 48 | |||
private val plotData = PlotData() | 49 | 49 | private val plotData = PlotData() | |
private val config = DataViewerConfiguration() | 50 | 50 | private val config = DataViewerConfiguration() | |
51 | 51 | |||
override fun initialize(location: URL?, resources: ResourceBundle?) { | 52 | 52 | override fun initialize(location: URL?, resources: ResourceBundle?) { | |
setObservableSelectedVesselListener() | 53 | 53 | setObservableSelectedVesselListener() | |
dataListView.items = dataList | 54 | 54 | dataListView.items = dataList | |
55 | 55 | |||
56 | 56 | |||
57 | 57 | |||
config.showLegend(false) | 58 | 58 | config.showLegend(false) | |
config.setLegendInsidePlot(false) | 59 | 59 | config.setLegendInsidePlot(false) | |
60 | 60 | |||
setObservableCurrentTimeListener() | 61 | 61 | setObservableCurrentTimeListener() | |
62 | 62 | |||
dataListView.setCellFactory { | 63 | 63 | dataListView.setCellFactory { | |
object : ListCell<Pair<String, ArrayList<MessageData?>>?>() { | 64 | 64 | object : ListCell<Pair<String, ArrayList<MessageData?>>?>() { | |
override fun updateItem(item: Pair<String, ArrayList<MessageData?>>?, empty: Boolean) { | 65 | 65 | override fun updateItem(item: Pair<String, ArrayList<MessageData?>>?, empty: Boolean) { | |
super.updateItem(item, empty) | 66 | 66 | super.updateItem(item, empty) | |
text = if (empty) { | 67 | 67 | text = if (empty) { | |
null | 68 | 68 | null | |
} else { | 69 | 69 | } else { | |
item?.first | 70 | 70 | item?.first | |
} | 71 | 71 | } | |
} | 72 | 72 | } | |
} | 73 | 73 | } | |
} | 74 | 74 | } | |
75 | 75 | |||
dataListView.selectionModel.selectedItemProperty().addListener { _, _, newValue -> | 76 | 76 | dataListView.selectionModel.selectedItemProperty().addListener { _, _, newValue -> | |
selectedItem = newValue | 77 | 77 | selectedItem = newValue | |
updateDataList(observableSelectedVessel.value) | 78 | 78 | updateDataList(observableSelectedVessel.value) | |
plot(newValue) | 79 | 79 | plot(newValue) | |
} | 80 | 80 | } | |
81 | 81 | |||
plotData.allTraces.clear() | 82 | 82 | plotData.allTraces.clear() | |
config.setxAxisTitle("") | 83 | 83 | config.setxAxisTitle("") | |
config.setyAxisTitle("") | 84 | 84 | config.setyAxisTitle("") | |
config.plotTitle = "" | 85 | 85 | config.plotTitle = "" | |
dataViewer.updateConfiguration(config) | 86 | 86 | dataViewer.updateConfiguration(config) | |
dataViewer.updatePlot(plotData) | 87 | 87 | dataViewer.updatePlot(plotData) | |
initDataList() | 88 | 88 | initDataList() | |
89 | 89 | |||
90 | 90 | |||
} | 91 | 91 | } | |
92 | 92 | |||
private fun plot() { | 93 | 93 | private fun plot() { | |
if (selectedItem != null || observableSelectedVessel.value == Vessel(null)) { | 94 | 94 | if (selectedItem != null && observableSelectedVessel.value.messages.size != 0) { | |
GlobalScope.launch { | 95 | 95 | GlobalScope.launch { | |
plot(selectedItem) | 96 | 96 | plot(selectedItem) | |
} | 97 | 97 | } | |
} | 98 | 98 | } | |
} | 99 | 99 | } | |
100 | 100 | |||
private fun plot(data: Pair<String, ArrayList<MessageData?>>?) { | 101 | 101 | private fun plot(data: Pair<String, ArrayList<MessageData?>>?) { | |
if (data == null) { | 102 | 102 | if (data == null) { | |
plotData.allTraces.clear() | 103 | 103 | plotData.allTraces.clear() | |
config.setxAxisTitle("") | 104 | 104 | config.setxAxisTitle("") | |
config.setyAxisTitle("") | 105 | 105 | config.setyAxisTitle("") | |
dataViewer.updateConfiguration(config) | 106 | 106 | dataViewer.updateConfiguration(config) | |
107 | 107 | |||
dataViewer.resetPlot() | 108 | 108 | dataViewer.resetPlot() | |
109 | 109 | |||
return | 110 | 110 | return | |
}else if (data.second.size < timeData.size) return | 111 | 111 | }else if (data.second.size < timeData.size) return | |
112 | 112 | |||
val getValueVisitorX = GetValueVisitor() | 113 | 113 | val getValueVisitorX = GetValueVisitor() | |
val getValueVisitorY = GetValueVisitor() | 114 | 114 | val getValueVisitorY = GetValueVisitor() | |
115 | 115 | |||
val arrayListStringX = arrayListOf<String>() | 116 | 116 | val arrayListStringX = arrayListOf<String>() | |
// val arrayListDoubleX = arrayListOf<Double>() | 117 | 117 | // val arrayListDoubleX = arrayListOf<Double>() | |
val arrayListStringY = arrayListOf<String>() | 118 | 118 | val arrayListStringY = arrayListOf<String>() | |
val arrayListDoubleY = arrayListOf<Double>() | 119 | 119 | val arrayListDoubleY = arrayListOf<Double>() | |
120 | 120 | |||
for (x in 0 until timeData.size) { | 121 | 121 | for (x in 0 until timeData.size) { | |
timeData[x]?.accept(getValueVisitorX) | 122 | 122 | timeData[x]?.accept(getValueVisitorX) | |
data.second[x]?.accept(getValueVisitorY) | 123 | 123 | data.second[x]?.accept(getValueVisitorY) | |
124 | 124 | |||
if (getValueVisitorY.value.toDoubleOrNull() == null) { | 125 | 125 | if (getValueVisitorY.value.toDoubleOrNull() == null) { | |
arrayListStringX.add(getValueVisitorX.value) | 126 | 126 | arrayListStringX.add(getValueVisitorX.value) | |
arrayListStringY.add(getValueVisitorY.value) | 127 | 127 | arrayListStringY.add(getValueVisitorY.value) | |
} else { | 128 | 128 | } else { | |
arrayListStringX.add(getValueVisitorX.value) | 129 | 129 | arrayListStringX.add(getValueVisitorX.value) | |
arrayListDoubleY.add(getValueVisitorY.value.toDouble()) | 130 | 130 | arrayListDoubleY.add(getValueVisitorY.value.toDouble()) | |
} | 131 | 131 | } | |
} | 132 | 132 | } | |
133 | 133 | |||
val scatterTrace = ScatterTrace<Any>() | 134 | 134 | val scatterTrace = ScatterTrace<Any>() | |
scatterTrace.traceColour = TraceColour.RED | 135 | 135 | scatterTrace.traceColour = TraceColour.RED | |
scatterTrace.traceVisibility = TraceVisibility.TRUE | 136 | 136 | scatterTrace.traceVisibility = TraceVisibility.TRUE | |
137 | 137 | |||
val serieStringX: Array<String> = arrayListStringX.toTypedArray() | 138 | 138 | val serieStringX: Array<String> = arrayListStringX.toTypedArray() | |
// val serieDoubleX: Array<Double> = arrayListDoubleX.toTypedArray() | 139 | 139 | // val serieDoubleX: Array<Double> = arrayListDoubleX.toTypedArray() | |
val serieStringY: Array<String> = arrayListStringY.toTypedArray() | 140 | 140 | val serieStringY: Array<String> = arrayListStringY.toTypedArray() | |
val serieDoubleY: Array<Double> = arrayListDoubleY.toTypedArray() | 141 | 141 | val serieDoubleY: Array<Double> = arrayListDoubleY.toTypedArray() | |
142 | 142 | |||
if (getValueVisitorY.value.toDoubleOrNull() == null) { | 143 | 143 | if (getValueVisitorY.value.toDoubleOrNull() == null) { | |
scatterTrace.setxArray(serieStringX) | 144 | 144 | scatterTrace.setxArray(serieStringX) | |
scatterTrace.setyArray(serieStringY) | 145 | 145 | scatterTrace.setyArray(serieStringY) | |
} else { | 146 | 146 | } else { | |
scatterTrace.setxArray(serieStringX) | 147 | 147 | scatterTrace.setxArray(serieStringX) | |
scatterTrace.setyArray(serieDoubleY) | 148 | 148 | scatterTrace.setyArray(serieDoubleY) | |
} | 149 | 149 | } | |
150 | 150 | |||
config.plotTitle = "" | 151 | 151 | config.plotTitle = "" | |
config.setxAxisTitle("Time (s)") | 152 | 152 | config.setxAxisTitle("Time (s)") | |
config.setyAxisTitle(data.first) | 153 | 153 | config.setyAxisTitle(data.first) | |
dataViewer.resetPlot() | 154 | 154 | dataViewer.resetPlot() | |
plotData.allTraces.clear() | 155 | 155 | plotData.allTraces.clear() | |
plotData.addTrace(scatterTrace) | 156 | 156 | plotData.addTrace(scatterTrace) | |
dataViewer.updateConfiguration(config) | 157 | 157 | dataViewer.updateConfiguration(config) | |
dataViewer.updatePlot(plotData) | 158 | 158 | dataViewer.updatePlot(plotData) | |
159 | 159 | |||
} | 160 | 160 | } | |
161 | 161 | |||
162 | 162 | |||
private fun setObservableSelectedVesselListener() { | 163 | 163 | private fun setObservableSelectedVesselListener() { | |
observableSelectedVessel.listeners.add(this) | 164 | 164 | observableSelectedVessel.listeners.add(this) | |
} | 165 | 165 | } | |
166 | 166 | |||
private fun populateTime(vessel: Vessel): ArrayList<MessageData?> { | 167 | 167 | private fun populateTime(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 168 | 168 | return if (observableIsReplayState.value) { | |
vessel.getAllTimeBeforeSelectedTime() | 169 | 169 | vessel.getAllTimeBeforeSelectedTime() | |
} else { | 170 | 170 | } else { | |
vessel.getAllTime() | 171 | 171 | vessel.getAllTime() | |
} | 172 | 172 | } | |
} | 173 | 173 | } | |
174 | 174 | |||
175 | 175 | |||
private fun populateLatitude(vessel: Vessel): ArrayList<MessageData?> { | 176 | 176 | private fun populateLatitude(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 177 | 177 | return if (observableIsReplayState.value) { | |
vessel.getAllLatitudeBeforeSelectedTime() | 178 | 178 | vessel.getAllLatitudeBeforeSelectedTime() | |
} else { | 179 | 179 | } else { | |
vessel.getAllLatitude() | 180 | 180 | vessel.getAllLatitude() | |
} | 181 | 181 | } | |
} | 182 | 182 | } | |
183 | 183 | |||
private fun populateLongitude(vessel: Vessel): ArrayList<MessageData?> { | 184 | 184 | private fun populateLongitude(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 185 | 185 | return if (observableIsReplayState.value) { | |
vessel.getAllLongitudeBeforeSelectedTime() | 186 | 186 | vessel.getAllLongitudeBeforeSelectedTime() | |
} else { | 187 | 187 | } else { | |
vessel.getAllLongitude() | 188 | 188 | vessel.getAllLongitude() | |
} | 189 | 189 | } | |
} | 190 | 190 | } | |
191 | 191 | |||
private fun populateSpeedOverGround(vessel: Vessel): ArrayList<MessageData?> { | 192 | 192 | private fun populateSpeedOverGround(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 193 | 193 | return if (observableIsReplayState.value) { | |
vessel.getAllSpeedOverGroundBeforeSelectedTime() | 194 | 194 | vessel.getAllSpeedOverGroundBeforeSelectedTime() | |
} else { | 195 | 195 | } else { | |
vessel.getAllSpeedOverGround() | 196 | 196 | vessel.getAllSpeedOverGround() | |
} | 197 | 197 | } | |
} | 198 | 198 | } | |
199 | 199 | |||
private fun populateCourseOverGround(vessel: Vessel): ArrayList<MessageData?> { | 200 | 200 | private fun populateCourseOverGround(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 201 | 201 | return if (observableIsReplayState.value) { | |
vessel.getAllCourseOverGroundBeforeSelectedTime() | 202 | 202 | vessel.getAllCourseOverGroundBeforeSelectedTime() | |
} else { | 203 | 203 | } else { | |
vessel.getAllCourseOverGround() | 204 | 204 | vessel.getAllCourseOverGround() | |
} | 205 | 205 | } | |
} | 206 | 206 | } | |
207 | 207 | |||
private fun populateHeading(vessel: Vessel): ArrayList<MessageData?> { | 208 | 208 | private fun populateHeading(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 209 | 209 | return if (observableIsReplayState.value) { | |
vessel.getAllHeadingBeforeSelectedTime() | 210 | 210 | vessel.getAllHeadingBeforeSelectedTime() | |
} else { | 211 | 211 | } else { | |
vessel.getAllHeading() | 212 | 212 | vessel.getAllHeading() | |
} | 213 | 213 | } | |
} | 214 | 214 | } | |
215 | 215 | |||
private fun populateVesselName(vessel: Vessel): ArrayList<MessageData?> { | 216 | 216 | private fun populateVesselName(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 217 | 217 | return if (observableIsReplayState.value) { | |
vessel.getAllVesselNameBeforeSelectedTime() | 218 | 218 | vessel.getAllVesselNameBeforeSelectedTime() | |
} else { | 219 | 219 | } else { | |
vessel.getAllVesselName() | 220 | 220 | vessel.getAllVesselName() | |
} | 221 | 221 | } | |
} | 222 | 222 | } | |
223 | 223 | |||
private fun populateIMO(vessel: Vessel): ArrayList<MessageData?> { | 224 | 224 | private fun populateIMO(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 225 | 225 | return if (observableIsReplayState.value) { | |
vessel.getAllIMOBeforeSelectedTime() | 226 | 226 | vessel.getAllIMOBeforeSelectedTime() | |
} else { | 227 | 227 | } else { | |
vessel.getAllIMO() | 228 | 228 | vessel.getAllIMO() | |
} | 229 | 229 | } | |
} | 230 | 230 | } | |
231 | 231 | |||
private fun populateCallSign(vessel: Vessel): ArrayList<MessageData?> { | 232 | 232 | private fun populateCallSign(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 233 | 233 | return if (observableIsReplayState.value) { | |
vessel.getAllCallSignBeforeSelectedTime() | 234 | 234 | vessel.getAllCallSignBeforeSelectedTime() | |
} else { | 235 | 235 | } else { | |
vessel.getAllCallSign() | 236 | 236 | vessel.getAllCallSign() | |
} | 237 | 237 | } | |
} | 238 | 238 | } | |
239 | 239 | |||
private fun populateVesselType(vessel: Vessel): ArrayList<MessageData?> { | 240 | 240 | private fun populateVesselType(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 241 | 241 | return if (observableIsReplayState.value) { | |
vessel.getAllVesselTypeBeforeSelectedTime() | 242 | 242 | vessel.getAllVesselTypeBeforeSelectedTime() | |
} else { | 243 | 243 | } else { | |
vessel.getAllVesselType() | 244 | 244 | vessel.getAllVesselType() | |
} | 245 | 245 | } | |
} | 246 | 246 | } | |
247 | 247 | |||
private fun populateStatus(vessel: Vessel): ArrayList<MessageData?> { | 248 | 248 | private fun populateStatus(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 249 | 249 | return if (observableIsReplayState.value) { | |
vessel.getAllStatusBeforeSelectedTime() | 250 | 250 | vessel.getAllStatusBeforeSelectedTime() | |
} else { | 251 | 251 | } else { | |
vessel.getAllStatus() | 252 | 252 | vessel.getAllStatus() | |
} | 253 | 253 | } | |
} | 254 | 254 | } | |
255 | 255 | |||
private fun populateLength(vessel: Vessel): ArrayList<MessageData?> { | 256 | 256 | private fun populateLength(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 257 | 257 | return if (observableIsReplayState.value) { | |
vessel.getAllLengthBeforeSelectedTime() | 258 | 258 | vessel.getAllLengthBeforeSelectedTime() | |
} else { | 259 | 259 | } else { | |
vessel.getAllLength() | 260 | 260 | vessel.getAllLength() | |
} | 261 | 261 | } | |
} | 262 | 262 | } | |
263 | 263 | |||
private fun populateWidth(vessel: Vessel): ArrayList<MessageData?> { | 264 | 264 | private fun populateWidth(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 265 | 265 | return if (observableIsReplayState.value) { | |
vessel.getAllWidthBeforeSelectedTime() | 266 | 266 | vessel.getAllWidthBeforeSelectedTime() | |
} else { | 267 | 267 | } else { | |
vessel.getAllWidth() | 268 | 268 | vessel.getAllWidth() | |
} | 269 | 269 | } | |
} | 270 | 270 | } | |
271 | 271 | |||
private fun populateDraft(vessel: Vessel): ArrayList<MessageData?> { | 272 | 272 | private fun populateDraft(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 273 | 273 | return if (observableIsReplayState.value) { | |
vessel.getAllDraftBeforeSelectedTime() | 274 | 274 | vessel.getAllDraftBeforeSelectedTime() | |
} else { | 275 | 275 | } else { | |
vessel.getAllDraft() | 276 | 276 | vessel.getAllDraft() | |
} | 277 | 277 | } | |
} | 278 | 278 | } | |
279 | 279 | |||
private fun populateCargo(vessel: Vessel): ArrayList<MessageData?> { | 280 | 280 | private fun populateCargo(vessel: Vessel): ArrayList<MessageData?> { | |
return if (observableIsReplayState.value) { | 281 | 281 | return if (observableIsReplayState.value) { | |
vessel.getAllCargoBeforeSelectedTime() | 282 | 282 | vessel.getAllCargoBeforeSelectedTime() | |
} else { | 283 | 283 | } else { | |
vessel.getAllCargo() | 284 | 284 | vessel.getAllCargo() | |
} | 285 | 285 | } | |
} | 286 | 286 | } | |
287 | 287 | |||
private fun initDataList() { | 288 | 288 | private fun initDataList() { | |
val data = arrayListOf<Pair<String, ArrayList<MessageData?>>>() | 289 | 289 | val data = arrayListOf<Pair<String, ArrayList<MessageData?>>>() | |
290 | 290 | |||
data.add(Pair("Latitude", latitude)) | 291 | 291 | data.add(Pair("Latitude", latitude)) | |
data.add(Pair("Longitude", longitude)) | 292 | 292 | data.add(Pair("Longitude", longitude)) | |
data.add(Pair("Speed Over Ground", speedOverGround)) | 293 | 293 | data.add(Pair("Speed Over Ground", speedOverGround)) | |
data.add(Pair("Course Over Ground", courseOverGround)) | 294 | 294 | data.add(Pair("Course Over Ground", courseOverGround)) | |
data.add(Pair("Heading", heading)) | 295 | 295 | data.add(Pair("Heading", heading)) | |
data.add(Pair("Vessel Name", vesselName)) | 296 | 296 | data.add(Pair("Vessel Name", vesselName)) | |
data.add(Pair("IMO", imo)) | 297 | 297 | data.add(Pair("IMO", imo)) | |
data.add(Pair("Call Sign", callSign)) | 298 | 298 | data.add(Pair("Call Sign", callSign)) | |
data.add(Pair("Vessel Type", vesselType)) | 299 | 299 | data.add(Pair("Vessel Type", vesselType)) | |
data.add(Pair("Status", status)) | 300 | 300 | data.add(Pair("Status", status)) | |
data.add(Pair("Length", length)) | 301 | 301 | data.add(Pair("Length", length)) | |
data.add(Pair("Width", width)) | 302 | 302 | data.add(Pair("Width", width)) | |
data.add(Pair("Draft", draft)) | 303 | 303 | data.add(Pair("Draft", draft)) | |
data.add(Pair("Cargo", cargo)) | 304 | 304 | data.add(Pair("Cargo", cargo)) | |
305 | 305 | |||
dataList.addAll(data) | 306 | 306 | dataList.addAll(data) | |
} | 307 | 307 | } | |
308 | 308 | |||
private fun updateDataList(vessel: Vessel) { | 309 | 309 | private fun updateDataList(vessel: Vessel) { | |
timeData = populateTime(vessel) | 310 | 310 | timeData = populateTime(vessel) | |
311 | 311 | |||
if(dataListView.selectionModel.selectedItem == null) return | 312 | 312 | if(dataListView.selectionModel.selectedItem == null) return | |
313 | 313 | |||
when (dataListView.selectionModel.selectedItem.first) { | 314 | 314 | when (dataListView.selectionModel.selectedItem.first) { | |
"Latitude" -> { | 315 | 315 | "Latitude" -> { | |
latitude.clear() | 316 | 316 | latitude.clear() | |
latitude.addAll(populateLatitude(vessel)) | 317 | 317 | latitude.addAll(populateLatitude(vessel)) | |
} | 318 | 318 | } | |
"Longitude" -> { | 319 | 319 | "Longitude" -> { | |
longitude.clear() | 320 | 320 | longitude.clear() | |
longitude.addAll(populateLongitude(vessel)) | 321 | 321 | longitude.addAll(populateLongitude(vessel)) | |
} | 322 | 322 | } | |
"Speed Over Ground" -> { | 323 | 323 | "Speed Over Ground" -> { | |
speedOverGround.clear() | 324 | 324 | speedOverGround.clear() | |
speedOverGround.addAll(populateSpeedOverGround(vessel)) | 325 | 325 | speedOverGround.addAll(populateSpeedOverGround(vessel)) | |
} | 326 | 326 | } | |
"Course Over Ground" -> { | 327 | 327 | "Course Over Ground" -> { | |
courseOverGround.clear() | 328 | 328 | courseOverGround.clear() | |
courseOverGround.addAll(populateCourseOverGround(vessel)) | 329 | 329 | courseOverGround.addAll(populateCourseOverGround(vessel)) | |
} | 330 | 330 | } | |
"Heading" -> { | 331 | 331 | "Heading" -> { |