Compare View
Commits (2)
Diff
Showing 2 changed files Side-by-side Diff
src/main/kotlin/application/controller/MenuBarController.kt
View file @
6b2760a
... | ... | @@ -10,9 +10,11 @@ import javafx.fxml.FXML |
10 | 10 | import javafx.fxml.Initializable |
11 | 11 | import javafx.scene.control.* |
12 | 12 | import javafx.stage.FileChooser |
13 | +import java.io.* | |
13 | 14 | import java.net.URL |
14 | 15 | import java.util.* |
15 | 16 | |
17 | + | |
16 | 18 | class MenuBarController : Initializable { |
17 | 19 | |
18 | 20 | @FXML |
... | ... | @@ -60,6 +62,7 @@ class MenuBarController : Initializable { |
60 | 62 | fileChooser.title = "Choose a file to import" |
61 | 63 | val window = menuBar.scene.window |
62 | 64 | val file = fileChooser.showOpenDialog(window) |
65 | + | |
63 | 66 | try { |
64 | 67 | if (file.extension != "csv") { |
65 | 68 | val alert = Alert(Alert.AlertType.WARNING) |
... | ... | @@ -68,15 +71,36 @@ class MenuBarController : Initializable { |
68 | 71 | alert.contentText = "Please choose à .csv file." |
69 | 72 | alert.showAndWait() |
70 | 73 | } |
71 | - val vessels = createVesselCollection(file) | |
72 | 74 | observableVessel.vessels.clear() |
73 | - observableVessel.vessels = vessels | |
75 | + if(toMuchVessel(file)){ | |
76 | + observableVessel.vessels = mutableMapOf() | |
77 | + }else { | |
78 | + val vessels = createVesselCollection(file) | |
79 | + observableVessel.vessels = vessels | |
80 | + } | |
74 | 81 | } catch (ignore: IllegalStateException) { |
75 | 82 | |
76 | 83 | } |
77 | 84 | } |
78 | 85 | } |
79 | 86 | |
87 | + private fun toMuchVessel(file: File): Boolean { | |
88 | + val nbLine = file.readLines().size | |
89 | + if (nbLine > 50000) { | |
90 | + val alert = Alert(Alert.AlertType.CONFIRMATION) | |
91 | + alert.title = "Warning!!" | |
92 | + alert.headerText = "Warning: This file contain a lot of messages." | |
93 | + alert.contentText = "Are you sure you want to continue." | |
94 | + val buttonTypeYes = ButtonType("Yes") | |
95 | + val buttonTypeNo = ButtonType("No ") | |
96 | + alert.buttonTypes.setAll(buttonTypeYes, buttonTypeNo) | |
97 | + val result = alert.showAndWait() | |
98 | + | |
99 | + return result.get() != buttonTypeYes | |
100 | + } | |
101 | + return false | |
102 | + } | |
103 | + | |
80 | 104 | private fun setOnActionAllMessageButton() { |
81 | 105 | allMessages.onAction = EventHandler { |
82 | 106 | observableMapState.state = ALL_MESSAGES |
src/main/kotlin/application/model/Vessel.kt
View file @
6b2760a
... | ... | @@ -19,7 +19,8 @@ class Vessel(val mmsi: String?) { |
19 | 19 | fun getAllTimeBeforeSelectedTime(): ArrayList<String> { |
20 | 20 | val timeList = arrayListOf<String>() |
21 | 21 | messageBeforeSelectedTime.forEach { |
22 | - timeList.add(it.value.time.value!!) | |
22 | + if (it.value.time.value != null) | |
23 | + timeList.add(it.value.time.value!!) | |
23 | 24 | } |
24 | 25 | |
25 | 26 | return timeList |
... | ... | @@ -28,7 +29,8 @@ class Vessel(val mmsi: String?) { |
28 | 29 | fun getAllLatitudeBeforeSelectedTime(): ArrayList<Double> { |
29 | 30 | val latitudeList = arrayListOf<Double>() |
30 | 31 | messageBeforeSelectedTime.forEach { |
31 | - latitudeList.add(it.value.latitude.value!!) | |
32 | + if (it.value.latitude.value != null) | |
33 | + latitudeList.add(it.value.latitude.value!!) | |
32 | 34 | } |
33 | 35 | |
34 | 36 | return latitudeList |
... | ... | @@ -37,7 +39,8 @@ class Vessel(val mmsi: String?) { |
37 | 39 | fun getAllLongitudeBeforeSelectedTime(): ArrayList<Double> { |
38 | 40 | val longitudeList = arrayListOf<Double>() |
39 | 41 | messageBeforeSelectedTime.forEach { |
40 | - longitudeList.add(it.value.longitude.value!!) | |
42 | + if (it.value.longitude.value != null) | |
43 | + longitudeList.add(it.value.longitude.value!!) | |
41 | 44 | } |
42 | 45 | |
43 | 46 | return longitudeList |
... | ... | @@ -46,7 +49,8 @@ class Vessel(val mmsi: String?) { |
46 | 49 | fun getAllSpeedOverGroundBeforeSelectedTime(): ArrayList<Double> { |
47 | 50 | val speedOverGroundList = arrayListOf<Double>() |
48 | 51 | messageBeforeSelectedTime.forEach { |
49 | - speedOverGroundList.add(it.value.speedOverGround.value!!) | |
52 | + if (it.value.speedOverGround.value != null) | |
53 | + speedOverGroundList.add(it.value.speedOverGround.value!!) | |
50 | 54 | } |
51 | 55 | |
52 | 56 | return speedOverGroundList |
... | ... | @@ -55,7 +59,8 @@ class Vessel(val mmsi: String?) { |
55 | 59 | fun getAllCourseOverGroundBeforeSelectedTime(): ArrayList<Double> { |
56 | 60 | val res = arrayListOf<Double>() |
57 | 61 | messageBeforeSelectedTime.forEach { |
58 | - res.add(it.value.courseOverGround.value!!) | |
62 | + if (it.value.courseOverGround.value != null) | |
63 | + res.add(it.value.courseOverGround.value!!) | |
59 | 64 | } |
60 | 65 | |
61 | 66 | return res |
... | ... | @@ -64,7 +69,8 @@ class Vessel(val mmsi: String?) { |
64 | 69 | fun getAllHeadingBeforeSelectedTime(): ArrayList<Double> { |
65 | 70 | val res = arrayListOf<Double>() |
66 | 71 | messageBeforeSelectedTime.forEach { |
67 | - res.add(it.value.heading.value!!) | |
72 | + if (it.value.heading.value != null) | |
73 | + res.add(it.value.heading.value!!) | |
68 | 74 | } |
69 | 75 | |
70 | 76 | return res |
... | ... | @@ -73,7 +79,8 @@ class Vessel(val mmsi: String?) { |
73 | 79 | fun getAllVesselNameBeforeSelectedTime(): ArrayList<String> { |
74 | 80 | val res = arrayListOf<String>() |
75 | 81 | messageBeforeSelectedTime.forEach { |
76 | - res.add(it.value.vesselName.value!!) | |
82 | + if (it.value.vesselName.value != null) | |
83 | + res.add(it.value.vesselName.value!!) | |
77 | 84 | } |
78 | 85 | return res |
79 | 86 | } |
... | ... | @@ -81,7 +88,8 @@ class Vessel(val mmsi: String?) { |
81 | 88 | fun getAllIMOBeforeSelectedTime(): ArrayList<String> { |
82 | 89 | val res = arrayListOf<String>() |
83 | 90 | messageBeforeSelectedTime.forEach { |
84 | - res.add(it.value.imo.value!!) | |
91 | + if (it.value.imo.value != null) | |
92 | + res.add(it.value.imo.value!!) | |
85 | 93 | } |
86 | 94 | return res |
87 | 95 | } |
... | ... | @@ -89,7 +97,8 @@ class Vessel(val mmsi: String?) { |
89 | 97 | fun getAllCallSignBeforeSelectedTime(): ArrayList<String> { |
90 | 98 | val res = arrayListOf<String>() |
91 | 99 | messageBeforeSelectedTime.forEach { |
92 | - res.add(it.value.callSign.value!!) | |
100 | + if (it.value.callSign.value != null) | |
101 | + res.add(it.value.callSign.value!!) | |
93 | 102 | } |
94 | 103 | return res |
95 | 104 | } |
... | ... | @@ -97,7 +106,8 @@ class Vessel(val mmsi: String?) { |
97 | 106 | fun getAllVesselTypeBeforeSelectedTime(): ArrayList<Double> { |
98 | 107 | val res = arrayListOf<Double>() |
99 | 108 | messageBeforeSelectedTime.forEach { |
100 | - res.add(it.value.vesselType.value!!) | |
109 | + if (it.value.vesselType.value != null) | |
110 | + res.add(it.value.vesselType.value!!) | |
101 | 111 | } |
102 | 112 | return res |
103 | 113 | } |
... | ... | @@ -105,7 +115,8 @@ class Vessel(val mmsi: String?) { |
105 | 115 | fun getAllStatusBeforeSelectedTime(): ArrayList<String> { |
106 | 116 | val res = arrayListOf<String>() |
107 | 117 | messageBeforeSelectedTime.forEach { |
108 | - res.add(it.value.status.value!!) | |
118 | + if (it.value.status.value != null) | |
119 | + res.add(it.value.status.value!!) | |
109 | 120 | } |
110 | 121 | return res |
111 | 122 | } |
... | ... | @@ -113,7 +124,8 @@ class Vessel(val mmsi: String?) { |
113 | 124 | fun getAllLengthBeforeSelectedTime(): ArrayList<Double> { |
114 | 125 | val res = arrayListOf<Double>() |
115 | 126 | messageBeforeSelectedTime.forEach { |
116 | - res.add(it.value.length.value!!) | |
127 | + if (it.value.length.value != null) | |
128 | + res.add(it.value.length.value!!) | |
117 | 129 | } |
118 | 130 | return res |
119 | 131 | } |
... | ... | @@ -121,7 +133,8 @@ class Vessel(val mmsi: String?) { |
121 | 133 | fun getAllWidthBeforeSelectedTime(): ArrayList<Double> { |
122 | 134 | val res = arrayListOf<Double>() |
123 | 135 | messageBeforeSelectedTime.forEach { |
124 | - res.add(it.value.width.value!!) | |
136 | + if (it.value.width.value != null) | |
137 | + res.add(it.value.width.value!!) | |
125 | 138 | } |
126 | 139 | return res |
127 | 140 | } |
... | ... | @@ -129,7 +142,8 @@ class Vessel(val mmsi: String?) { |
129 | 142 | fun getAllDraftBeforeSelectedTime(): ArrayList<Double> { |
130 | 143 | val res = arrayListOf<Double>() |
131 | 144 | messageBeforeSelectedTime.forEach { |
132 | - res.add(it.value.draft.value!!) | |
145 | + if (it.value.draft.value != null) | |
146 | + res.add(it.value.draft.value!!) | |
133 | 147 | } |
134 | 148 | return res |
135 | 149 | } |
... | ... | @@ -137,7 +151,8 @@ class Vessel(val mmsi: String?) { |
137 | 151 | fun getAllCargoBeforeSelectedTime(): ArrayList<Double> { |
138 | 152 | val res = arrayListOf<Double>() |
139 | 153 | messageBeforeSelectedTime.forEach { |
140 | - res.add(it.value.cargo.value!!) | |
154 | + if (it.value.cargo.value != null) | |
155 | + res.add(it.value.cargo.value!!) | |
141 | 156 | } |
142 | 157 | return res |
143 | 158 | } |
... | ... | @@ -145,7 +160,8 @@ class Vessel(val mmsi: String?) { |
145 | 160 | fun getAllTime(): ArrayList<String> { |
146 | 161 | val timeList = arrayListOf<String>() |
147 | 162 | messages.forEach { |
148 | - timeList.add(it.value.time.value!!) | |
163 | + if (it.value.time.value != null) | |
164 | + timeList.add(it.value.time.value!!) | |
149 | 165 | } |
150 | 166 | |
151 | 167 | return timeList |
... | ... | @@ -154,7 +170,8 @@ class Vessel(val mmsi: String?) { |
154 | 170 | fun getAllLatitude(): ArrayList<Double> { |
155 | 171 | val latitudeList = arrayListOf<Double>() |
156 | 172 | messages.forEach { |
157 | - latitudeList.add(it.value.latitude.value!!) | |
173 | + if (it.value.latitude.value != null) | |
174 | + latitudeList.add(it.value.latitude.value!!) | |
158 | 175 | } |
159 | 176 | |
160 | 177 | return latitudeList |
... | ... | @@ -163,7 +180,8 @@ class Vessel(val mmsi: String?) { |
163 | 180 | fun getAllLongitude(): ArrayList<Double> { |
164 | 181 | val longitudeList = arrayListOf<Double>() |
165 | 182 | messages.forEach { |
166 | - longitudeList.add(it.value.longitude.value!!) | |
183 | + if (it.value.longitude.value != null) | |
184 | + longitudeList.add(it.value.longitude.value!!) | |
167 | 185 | } |
168 | 186 | |
169 | 187 | return longitudeList |
... | ... | @@ -172,7 +190,8 @@ class Vessel(val mmsi: String?) { |
172 | 190 | fun getAllSpeedOverGround(): ArrayList<Double> { |
173 | 191 | val speedOverGroundList = arrayListOf<Double>() |
174 | 192 | messages.forEach { |
175 | - speedOverGroundList.add(it.value.speedOverGround.value!!) | |
193 | + if (it.value.speedOverGround.value != null) | |
194 | + speedOverGroundList.add(it.value.speedOverGround.value!!) | |
176 | 195 | } |
177 | 196 | |
178 | 197 | return speedOverGroundList |
... | ... | @@ -181,7 +200,8 @@ class Vessel(val mmsi: String?) { |
181 | 200 | fun getAllCourseOverGround(): ArrayList<Double> { |
182 | 201 | val res = arrayListOf<Double>() |
183 | 202 | messages.forEach { |
184 | - res.add(it.value.courseOverGround.value!!) | |
203 | + if (it.value.courseOverGround.value != null) | |
204 | + res.add(it.value.courseOverGround.value!!) | |
185 | 205 | } |
186 | 206 | |
187 | 207 | return res |
... | ... | @@ -190,6 +210,7 @@ class Vessel(val mmsi: String?) { |
190 | 210 | fun getAllHeading(): ArrayList<Double> { |
191 | 211 | val res = arrayListOf<Double>() |
192 | 212 | messages.forEach { |
213 | + if (it.value.heading.value != null) | |
193 | 214 | res.add(it.value.heading.value!!) |
194 | 215 | } |
195 | 216 | |
... | ... | @@ -199,7 +220,8 @@ class Vessel(val mmsi: String?) { |
199 | 220 | fun getAllVesselName(): ArrayList<String> { |
200 | 221 | val res = arrayListOf<String>() |
201 | 222 | messages.forEach { |
202 | - res.add(it.value.vesselName.value!!) | |
223 | + if (it.value.vesselName.value != null) | |
224 | + res.add(it.value.vesselName.value!!) | |
203 | 225 | } |
204 | 226 | return res |
205 | 227 | } |
... | ... | @@ -207,7 +229,8 @@ class Vessel(val mmsi: String?) { |
207 | 229 | fun getAllIMO(): ArrayList<String> { |
208 | 230 | val res = arrayListOf<String>() |
209 | 231 | messages.forEach { |
210 | - res.add(it.value.imo.value!!) | |
232 | + if (it.value.imo.value != null) | |
233 | + res.add(it.value.imo.value!!) | |
211 | 234 | } |
212 | 235 | return res |
213 | 236 | } |
... | ... | @@ -215,7 +238,8 @@ class Vessel(val mmsi: String?) { |
215 | 238 | fun getAllCallSign(): ArrayList<String> { |
216 | 239 | val res = arrayListOf<String>() |
217 | 240 | messages.forEach { |
218 | - res.add(it.value.callSign.value!!) | |
241 | + if (it.value.callSign.value != null) | |
242 | + res.add(it.value.callSign.value!!) | |
219 | 243 | } |
220 | 244 | return res |
221 | 245 | } |
... | ... | @@ -223,7 +247,8 @@ class Vessel(val mmsi: String?) { |
223 | 247 | fun getAllVesselType(): ArrayList<Double> { |
224 | 248 | val res = arrayListOf<Double>() |
225 | 249 | messages.forEach { |
226 | - res.add(it.value.vesselType.value!!) | |
250 | + if (it.value.vesselType.value != null) | |
251 | + res.add(it.value.vesselType.value!!) | |
227 | 252 | } |
228 | 253 | return res |
229 | 254 | } |
... | ... | @@ -231,7 +256,8 @@ class Vessel(val mmsi: String?) { |
231 | 256 | fun getAllStatus(): ArrayList<String> { |
232 | 257 | val res = arrayListOf<String>() |
233 | 258 | messages.forEach { |
234 | - res.add(it.value.status.value!!) | |
259 | + if (it.value.status.value != null) | |
260 | + res.add(it.value.status.value!!) | |
235 | 261 | } |
236 | 262 | return res |
237 | 263 | } |
... | ... | @@ -239,7 +265,8 @@ class Vessel(val mmsi: String?) { |
239 | 265 | fun getAllLength(): ArrayList<Double> { |
240 | 266 | val res = arrayListOf<Double>() |
241 | 267 | messages.forEach { |
242 | - res.add(it.value.length.value!!) | |
268 | + if (it.value.length.value != null) | |
269 | + res.add(it.value.length.value!!) | |
243 | 270 | } |
244 | 271 | return res |
245 | 272 | } |
... | ... | @@ -247,7 +274,8 @@ class Vessel(val mmsi: String?) { |
247 | 274 | fun getAllWidth(): ArrayList<Double> { |
248 | 275 | val res = arrayListOf<Double>() |
249 | 276 | messages.forEach { |
250 | - res.add(it.value.width.value!!) | |
277 | + if (it.value.width.value != null) | |
278 | + res.add(it.value.width.value!!) | |
251 | 279 | } |
252 | 280 | return res |
253 | 281 | } |
... | ... | @@ -255,7 +283,8 @@ class Vessel(val mmsi: String?) { |
255 | 283 | fun getAllDraft(): ArrayList<Double> { |
256 | 284 | val res = arrayListOf<Double>() |
257 | 285 | messages.forEach { |
258 | - res.add(it.value.draft.value!!) | |
286 | + if (it.value.draft.value != null) | |
287 | + res.add(it.value.draft.value!!) | |
259 | 288 | } |
260 | 289 | return res |
261 | 290 | } |
... | ... | @@ -263,7 +292,9 @@ class Vessel(val mmsi: String?) { |
263 | 292 | fun getAllCargo(): ArrayList<Double> { |
264 | 293 | val res = arrayListOf<Double>() |
265 | 294 | messages.forEach { |
266 | - res.add(it.value.cargo.value!!) | |
295 | + if (it.value.cargo.value != null) | |
296 | + res.add(it.value.cargo.value!!) | |
297 | + | |
267 | 298 | } |
268 | 299 | return res |
269 | 300 | } |