Commit 8108656dd176ec86d8f699e4285e9e50896393cc
1 parent
d8ee252de4
Exists in
master
and in
1 other branch
remove plot title
Showing 1 changed file with 2 additions and 0 deletions Inline Diff
src/main/kotlin/application/controller/DataPanelController.kt
View file @
8108656
| 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 org.charts.dataviewer.api.config.DataViewerConfiguration | 10 | 10 | import org.charts.dataviewer.api.config.DataViewerConfiguration | |
| import org.charts.dataviewer.api.data.PlotData | 11 | 11 | import org.charts.dataviewer.api.data.PlotData | |
| import org.charts.dataviewer.api.trace.ScatterTrace | 12 | 12 | import org.charts.dataviewer.api.trace.ScatterTrace | |
| import org.charts.dataviewer.javafx.JavaFxDataViewer | 13 | 13 | import org.charts.dataviewer.javafx.JavaFxDataViewer | |
| import org.charts.dataviewer.utils.TraceColour | 14 | 14 | import org.charts.dataviewer.utils.TraceColour | |
| import org.charts.dataviewer.utils.TraceVisibility | 15 | 15 | import org.charts.dataviewer.utils.TraceVisibility | |
| import java.net.URL | 16 | 16 | import java.net.URL | |
| import java.util.* | 17 | 17 | import java.util.* | |
| 18 | 18 | |||
| 19 | 19 | |||
| class DataPanelController : Initializable, SelectedVesselListener { | 20 | 20 | class DataPanelController : Initializable, SelectedVesselListener { | |
| private var dataList: ObservableList<Pair<String, ArrayList<MessageData?>>> = FXCollections.observableArrayList() | 21 | 21 | private var dataList: ObservableList<Pair<String, ArrayList<MessageData?>>> = FXCollections.observableArrayList() | |
| private lateinit var timeData: ArrayList<MessageData?> | 22 | 22 | private lateinit var timeData: ArrayList<MessageData?> | |
| 23 | 23 | |||
| 24 | 24 | |||
| @FXML | 25 | 25 | @FXML | |
| var dataListView = ListView<Pair<String, ArrayList<MessageData?>>>() | 26 | 26 | var dataListView = ListView<Pair<String, ArrayList<MessageData?>>>() | |
| 27 | 27 | |||
| @FXML | 28 | 28 | @FXML | |
| var dataViewer = JavaFxDataViewer() | 29 | 29 | var dataViewer = JavaFxDataViewer() | |
| 30 | 30 | |||
| 31 | 31 | |||
| override fun initialize(location: URL?, resources: ResourceBundle?) { | 32 | 32 | override fun initialize(location: URL?, resources: ResourceBundle?) { | |
| setObservableSelectedVesselListener() | 33 | 33 | setObservableSelectedVesselListener() | |
| dataListView.items = dataList | 34 | 34 | dataListView.items = dataList | |
| 35 | 35 | |||
| 36 | 36 | |||
| val plotData = PlotData() | 37 | 37 | val plotData = PlotData() | |
| val config = DataViewerConfiguration() | 38 | 38 | val config = DataViewerConfiguration() | |
| config.showLegend(true) | 39 | 39 | config.showLegend(true) | |
| config.setLegendInsidePlot(false) | 40 | 40 | config.setLegendInsidePlot(false) | |
| 41 | 41 | |||
| dataListView.setCellFactory { | 42 | 42 | dataListView.setCellFactory { | |
| object : ListCell<Pair<String, ArrayList<MessageData?>>?>() { | 43 | 43 | object : ListCell<Pair<String, ArrayList<MessageData?>>?>() { | |
| override fun updateItem(item: Pair<String, ArrayList<MessageData?>>?, empty: Boolean) { | 44 | 44 | override fun updateItem(item: Pair<String, ArrayList<MessageData?>>?, empty: Boolean) { | |
| super.updateItem(item, empty) | 45 | 45 | super.updateItem(item, empty) | |
| text = if (empty) { | 46 | 46 | text = if (empty) { | |
| null | 47 | 47 | null | |
| } else { | 48 | 48 | } else { | |
| item?.first | 49 | 49 | item?.first | |
| } | 50 | 50 | } | |
| } | 51 | 51 | } | |
| } | 52 | 52 | } | |
| } | 53 | 53 | } | |
| 54 | 54 | |||
| dataListView.selectionModel.selectedItemProperty().addListener { _, _, newValue -> | 55 | 55 | dataListView.selectionModel.selectedItemProperty().addListener { _, _, newValue -> | |
| if (newValue == null) { | 56 | 56 | if (newValue == null) { | |
| plotData.allTraces.clear() | 57 | 57 | plotData.allTraces.clear() | |
| config.setxAxisTitle("") | 58 | 58 | config.setxAxisTitle("") | |
| config.setyAxisTitle("") | 59 | 59 | config.setyAxisTitle("") | |
| dataViewer.updateConfiguration(config) | 60 | 60 | dataViewer.updateConfiguration(config) | |
| 61 | 61 | |||
| dataViewer.resetPlot() | 62 | 62 | dataViewer.resetPlot() | |
| 63 | 63 | |||
| return@addListener | 64 | 64 | return@addListener | |
| } | 65 | 65 | } | |
| 66 | 66 | |||
| val getValueVisitorX = GetValueVisitor() | 67 | 67 | val getValueVisitorX = GetValueVisitor() | |
| val getValueVisitorY = GetValueVisitor() | 68 | 68 | val getValueVisitorY = GetValueVisitor() | |
| 69 | 69 | |||
| val arrayListStringX = arrayListOf<String>() | 70 | 70 | val arrayListStringX = arrayListOf<String>() | |
| val arrayListDoubleX = arrayListOf<Double>() | 71 | 71 | val arrayListDoubleX = arrayListOf<Double>() | |
| val arrayListStringY = arrayListOf<String>() | 72 | 72 | val arrayListStringY = arrayListOf<String>() | |
| val arrayListDoubleY = arrayListOf<Double>() | 73 | 73 | val arrayListDoubleY = arrayListOf<Double>() | |
| 74 | 74 | |||
| for (x in 0 until newValue.second.size) { | 75 | 75 | for (x in 0 until newValue.second.size) { | |
| timeData[x]?.accept(getValueVisitorX) | 76 | 76 | timeData[x]?.accept(getValueVisitorX) | |
| newValue.second[x]?.accept(getValueVisitorY) | 77 | 77 | newValue.second[x]?.accept(getValueVisitorY) | |
| 78 | 78 | |||
| if (getValueVisitorY.value.toDoubleOrNull() == null) { | 79 | 79 | if (getValueVisitorY.value.toDoubleOrNull() == null) { | |
| arrayListStringX.add(getValueVisitorX.value) | 80 | 80 | arrayListStringX.add(getValueVisitorX.value) | |
| arrayListStringY.add(getValueVisitorY.value) | 81 | 81 | arrayListStringY.add(getValueVisitorY.value) | |
| } else { | 82 | 82 | } else { | |
| arrayListStringX.add(getValueVisitorX.value) | 83 | 83 | arrayListStringX.add(getValueVisitorX.value) | |
| arrayListDoubleY.add(getValueVisitorY.value.toDouble()) | 84 | 84 | arrayListDoubleY.add(getValueVisitorY.value.toDouble()) | |
| } | 85 | 85 | } | |
| } | 86 | 86 | } | |
| 87 | 87 | |||
| val scatterTrace = ScatterTrace<Any>() | 88 | 88 | val scatterTrace = ScatterTrace<Any>() | |
| scatterTrace.traceColour = TraceColour.RED | 89 | 89 | scatterTrace.traceColour = TraceColour.RED | |
| scatterTrace.traceVisibility = TraceVisibility.TRUE | 90 | 90 | scatterTrace.traceVisibility = TraceVisibility.TRUE | |
| 91 | 91 | |||
| val serieStringX: Array<String> = arrayListStringX.toTypedArray() | 92 | 92 | val serieStringX: Array<String> = arrayListStringX.toTypedArray() | |
| // val serieDoubleX: Array<Double> = arrayListDoubleX.toTypedArray() | 93 | 93 | // val serieDoubleX: Array<Double> = arrayListDoubleX.toTypedArray() | |
| val serieStringY: Array<String> = arrayListStringY.toTypedArray() | 94 | 94 | val serieStringY: Array<String> = arrayListStringY.toTypedArray() | |
| val serieDoubleY: Array<Double> = arrayListDoubleY.toTypedArray() | 95 | 95 | val serieDoubleY: Array<Double> = arrayListDoubleY.toTypedArray() | |
| 96 | 96 | |||
| if (getValueVisitorY.value.toDoubleOrNull() == null) { | 97 | 97 | if (getValueVisitorY.value.toDoubleOrNull() == null) { | |
| scatterTrace.setxArray(serieStringX) | 98 | 98 | scatterTrace.setxArray(serieStringX) | |
| scatterTrace.setyArray(serieStringY) | 99 | 99 | scatterTrace.setyArray(serieStringY) | |
| } else { | 100 | 100 | } else { | |
| scatterTrace.setxArray(serieStringX) | 101 | 101 | scatterTrace.setxArray(serieStringX) | |
| scatterTrace.setyArray(serieDoubleY) | 102 | 102 | scatterTrace.setyArray(serieDoubleY) | |
| } | 103 | 103 | } | |
| 104 | 104 | |||
| 105 | config.plotTitle = "" | |||
| config.setxAxisTitle("Date") | 105 | 106 | config.setxAxisTitle("Date") | |
| config.setyAxisTitle(newValue.first) | 106 | 107 | config.setyAxisTitle(newValue.first) | |
| dataViewer.resetPlot() | 107 | 108 | dataViewer.resetPlot() | |
| plotData.allTraces.clear() | 108 | 109 | plotData.allTraces.clear() | |
| plotData.addTrace(scatterTrace) | 109 | 110 | plotData.addTrace(scatterTrace) | |
| dataViewer.updateConfiguration(config) | 110 | 111 | dataViewer.updateConfiguration(config) | |
| dataViewer.updatePlot(plotData) | 111 | 112 | dataViewer.updatePlot(plotData) | |
| 112 | 113 | |||
| } | 113 | 114 | } | |
| 114 | 115 | |||
| plotData.allTraces.clear() | 115 | 116 | plotData.allTraces.clear() | |
| config.setxAxisTitle("") | 116 | 117 | config.setxAxisTitle("") | |
| config.setyAxisTitle("") | 117 | 118 | config.setyAxisTitle("") | |
| 119 | config.plotTitle = "" | |||
| dataViewer.updateConfiguration(config) | 118 | 120 | dataViewer.updateConfiguration(config) | |
| dataViewer.updatePlot(plotData) | 119 | 121 | dataViewer.updatePlot(plotData) | |
| 120 | 122 | |||
| } | 121 | 123 | } | |
| 122 | 124 | |||
| private fun setObservableSelectedVesselListener() { | 123 | 125 | private fun setObservableSelectedVesselListener() { | |
| observableSelectedVessel.listeners.add(this) | 124 | 126 | observableSelectedVessel.listeners.add(this) | |
| } | 125 | 127 | } | |
| 126 | 128 | |||
| private fun populateTime(vessel: Vessel): ArrayList<MessageData?> { | 127 | 129 | private fun populateTime(vessel: Vessel): ArrayList<MessageData?> { | |
| val allTime: ArrayList<MessageData?> = vessel.getAllTime() | 128 | 130 | val allTime: ArrayList<MessageData?> = vessel.getAllTime() | |
| allTime.sortBy { (it as Time).value } | 129 | 131 | allTime.sortBy { (it as Time).value } | |
| 130 | 132 | |||
| return allTime | 131 | 133 | return allTime | |
| } | 132 | 134 | } | |
| 133 | 135 | |||
| private fun populateLatitude(vessel: Vessel): ArrayList<MessageData?> { | 134 | 136 | private fun populateLatitude(vessel: Vessel): ArrayList<MessageData?> { | |
| val allLatitude: ArrayList<MessageData?> = vessel.getAllLatitude() | 135 | 137 | val allLatitude: ArrayList<MessageData?> = vessel.getAllLatitude() | |
| allLatitude.sortBy { (it as Latitude).value } | 136 | 138 | allLatitude.sortBy { (it as Latitude).value } | |
| 137 | 139 | |||
| return allLatitude | 138 | 140 | return allLatitude | |
| } | 139 | 141 | } | |
| 140 | 142 | |||
| private fun populateLongitude(vessel: Vessel): ArrayList<MessageData?> { | 141 | 143 | private fun populateLongitude(vessel: Vessel): ArrayList<MessageData?> { | |
| val allLongitude: ArrayList<MessageData?> = vessel.getAllLongitude() | 142 | 144 | val allLongitude: ArrayList<MessageData?> = vessel.getAllLongitude() | |
| allLongitude.sortBy { (it as Longitude).value } | 143 | 145 | allLongitude.sortBy { (it as Longitude).value } | |
| 144 | 146 | |||
| return allLongitude | 145 | 147 | return allLongitude | |
| } | 146 | 148 | } | |
| 147 | 149 | |||
| private fun populateSpeedOverGround(vessel: Vessel): ArrayList<MessageData?> { | 148 | 150 | private fun populateSpeedOverGround(vessel: Vessel): ArrayList<MessageData?> { | |
| val allSpeedOverGround: ArrayList<MessageData?> = vessel.getAllSpeedOverGround() | 149 | 151 | val allSpeedOverGround: ArrayList<MessageData?> = vessel.getAllSpeedOverGround() | |
| allSpeedOverGround.sortBy { (it as SpeedOverGround).value } | 150 | 152 | allSpeedOverGround.sortBy { (it as SpeedOverGround).value } | |
| 151 | 153 | |||
| return allSpeedOverGround | 152 | 154 | return allSpeedOverGround | |
| } | 153 | 155 | } | |
| 154 | 156 | |||
| private fun populateCourseOverGround(vessel: Vessel): ArrayList<MessageData?> { | 155 | 157 | private fun populateCourseOverGround(vessel: Vessel): ArrayList<MessageData?> { | |
| val allCourseOverGround: ArrayList<MessageData?> = vessel.getAllCourseOverGround() | 156 | 158 | val allCourseOverGround: ArrayList<MessageData?> = vessel.getAllCourseOverGround() | |
| allCourseOverGround.sortBy { (it as CourseOverGround).value } | 157 | 159 | allCourseOverGround.sortBy { (it as CourseOverGround).value } | |
| 158 | 160 | |||
| return allCourseOverGround | 159 | 161 | return allCourseOverGround | |
| } | 160 | 162 | } | |
| 161 | 163 | |||
| private fun populateHeading(vessel: Vessel): ArrayList<MessageData?> { | 162 | 164 | private fun populateHeading(vessel: Vessel): ArrayList<MessageData?> { | |
| val allHeading: ArrayList<MessageData?> = vessel.getAllHeading() | 163 | 165 | val allHeading: ArrayList<MessageData?> = vessel.getAllHeading() | |
| allHeading.sortBy { (it as Heading).value } | 164 | 166 | allHeading.sortBy { (it as Heading).value } | |
| 165 | 167 | |||
| return allHeading | 166 | 168 | return allHeading | |
| } | 167 | 169 | } | |
| 168 | 170 | |||
| private fun populateVesselName(vessel: Vessel): ArrayList<MessageData?> { | 169 | 171 | private fun populateVesselName(vessel: Vessel): ArrayList<MessageData?> { | |
| val allVesselName: ArrayList<MessageData?> = vessel.getAllVesselName() | 170 | 172 | val allVesselName: ArrayList<MessageData?> = vessel.getAllVesselName() | |
| allVesselName.sortBy { (it as VesselName).value } | 171 | 173 | allVesselName.sortBy { (it as VesselName).value } | |
| 172 | 174 | |||
| return allVesselName | 173 | 175 | return allVesselName | |
| } | 174 | 176 | } | |
| 175 | 177 | |||
| private fun populateIMO(vessel: Vessel): ArrayList<MessageData?> { | 176 | 178 | private fun populateIMO(vessel: Vessel): ArrayList<MessageData?> { | |
| val allIMO: ArrayList<MessageData?> = vessel.getAllIMO() | 177 | 179 | val allIMO: ArrayList<MessageData?> = vessel.getAllIMO() | |
| allIMO.sortBy { (it as IMO).value } | 178 | 180 | allIMO.sortBy { (it as IMO).value } | |
| 179 | 181 | |||
| return allIMO | 180 | 182 | return allIMO | |
| } | 181 | 183 | } | |
| 182 | 184 | |||
| private fun populateCallSign(vessel: Vessel): ArrayList<MessageData?> { | 183 | 185 | private fun populateCallSign(vessel: Vessel): ArrayList<MessageData?> { | |
| val allCallSign: ArrayList<MessageData?> = vessel.getAllCallSign() | 184 | 186 | val allCallSign: ArrayList<MessageData?> = vessel.getAllCallSign() | |
| allCallSign.sortBy { (it as CallSign).value } | 185 | 187 | allCallSign.sortBy { (it as CallSign).value } | |
| 186 | 188 | |||
| return allCallSign | 187 | 189 | return allCallSign | |
| } | 188 | 190 | } | |
| 189 | 191 | |||
| private fun populateVesselType(vessel: Vessel): ArrayList<MessageData?> { | 190 | 192 | private fun populateVesselType(vessel: Vessel): ArrayList<MessageData?> { | |
| val allVesselType: ArrayList<MessageData?> = vessel.getAllVesselType() | 191 | 193 | val allVesselType: ArrayList<MessageData?> = vessel.getAllVesselType() | |
| allVesselType.sortBy { (it as VesselType).value } | 192 | 194 | allVesselType.sortBy { (it as VesselType).value } | |
| 193 | 195 | |||
| return allVesselType | 194 | 196 | return allVesselType | |
| } | 195 | 197 | } | |
| 196 | 198 | |||
| private fun populateStatus(vessel: Vessel): ArrayList<MessageData?> { | 197 | 199 | private fun populateStatus(vessel: Vessel): ArrayList<MessageData?> { | |
| val allStatus: ArrayList<MessageData?> = vessel.getAllStatus() | 198 | 200 | val allStatus: ArrayList<MessageData?> = vessel.getAllStatus() |