From 867a0df4617a6c1355868b60f50a41b9e74d0140 Mon Sep 17 00:00:00 2001 From: lsagona Date: Mon, 31 Aug 2020 11:04:01 +0200 Subject: [PATCH] populate plot when the property is selected --- .../application/controller/DataPanelController.kt | 107 ++++++++++++-------- 1 file changed, 63 insertions(+), 44 deletions(-) diff --git a/src/main/kotlin/application/controller/DataPanelController.kt b/src/main/kotlin/application/controller/DataPanelController.kt index 69a9f2d..5b2f5f1 100644 --- a/src/main/kotlin/application/controller/DataPanelController.kt +++ b/src/main/kotlin/application/controller/DataPanelController.kt @@ -55,7 +55,7 @@ class DataPanelController : Initializable, SelectedVesselListener { - config.showLegend(true) + config.showLegend(false) config.setLegendInsidePlot(false) setObservableCurrentTimeListener() @@ -75,6 +75,7 @@ class DataPanelController : Initializable, SelectedVesselListener { dataListView.selectionModel.selectedItemProperty().addListener { _, _, newValue -> selectedItem = newValue + updateDataList(observableSelectedVessel.value) plot(newValue) } @@ -90,7 +91,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } private fun plot() { - if (selectedItem != null) { + if (selectedItem != null || observableSelectedVessel.value == Vessel(null)) { GlobalScope.launch { plot(selectedItem) } @@ -107,7 +108,7 @@ class DataPanelController : Initializable, SelectedVesselListener { dataViewer.resetPlot() return - } + }else if (data.second.size < timeData.size) return val getValueVisitorX = GetValueVisitor() val getValueVisitorY = GetValueVisitor() @@ -308,48 +309,66 @@ class DataPanelController : Initializable, SelectedVesselListener { private fun updateDataList(vessel: Vessel) { timeData = populateTime(vessel) - latitude.clear() - latitude.addAll(populateLatitude(vessel)) - - longitude.clear() - longitude.addAll(populateLongitude(vessel)) - - speedOverGround.clear() - speedOverGround.addAll(populateSpeedOverGround(vessel)) - - courseOverGround.clear() - courseOverGround.addAll(populateCourseOverGround(vessel)) - - heading.clear() - heading.addAll(populateHeading(vessel)) - - vesselName.clear() - vesselName.addAll(populateVesselName(vessel)) - - imo.clear() - imo.addAll(populateIMO(vessel)) - - callSign.clear() - callSign.addAll(populateCallSign(vessel)) - - vesselType.clear() - vesselType.addAll(populateVesselType(vessel)) - - status.clear() - status.addAll(populateStatus(vessel)) - - length.clear() - length.addAll(populateLength(vessel)) - - width.clear() - width.addAll(populateWidth(vessel)) - - draft.clear() - draft.addAll(populateDraft(vessel)) - - cargo.clear() - cargo.addAll(populateCargo(vessel)) + if(dataListView.selectionModel.selectedItem == null) return + when (dataListView.selectionModel.selectedItem.first) { + "Latitude" -> { + latitude.clear() + latitude.addAll(populateLatitude(vessel)) + } + "Longitude" -> { + longitude.clear() + longitude.addAll(populateLongitude(vessel)) + } + "Speed Over Ground" -> { + speedOverGround.clear() + speedOverGround.addAll(populateSpeedOverGround(vessel)) + } + "Course Over Ground" -> { + courseOverGround.clear() + courseOverGround.addAll(populateCourseOverGround(vessel)) + } + "Heading" -> { + heading.clear() + heading.addAll(populateHeading(vessel)) + } + "Vessel Name" -> { + vesselName.clear() + vesselName.addAll(populateVesselName(vessel)) + } + "IMO" -> { + imo.clear() + imo.addAll(populateIMO(vessel)) + } + "Call Sign" -> { + callSign.clear() + callSign.addAll(populateCallSign(vessel)) + } + "Vessel Type" -> { + vesselType.clear() + vesselType.addAll(populateVesselType(vessel)) + } + "Status" -> { + status.clear() + status.addAll(populateStatus(vessel)) + } + "Length" -> { + length.clear() + length.addAll(populateLength(vessel)) + } + "Width" -> { + width.clear() + width.addAll(populateWidth(vessel)) + } + "Draft" -> { + draft.clear() + draft.addAll(populateDraft(vessel)) + } + "Cargo" -> { + cargo.clear() + cargo.addAll(populateCargo(vessel)) + } + } } private fun setObservableCurrentTimeListener() { -- 1.7.10.4