Blame view

src/main/kotlin/application/model/Vessel.kt 8.65 KB
b350f9dfe   lsagona   import vessels an...
1
  package application.model
53f01ecc3   lsagona   display message o...
2
  import java.util.*
b350f9dfe   lsagona   import vessels an...
3

f39d90e60   lsagona   Select/deselect MMSI
4
  class Vessel(val mmsi: String?) {
3b26be8f9   lsagona   controle the time...
5
      val messages: SortedMap<Long, Message> = sortedMapOf()
e220e082b   lsagona   graph binded to s...
6
7
8
9
      private val messageBeforeSelectedTime: Map<Long, Message>
          get() {
              return messages.filter { observableCurrentTime.value > it.key }
          }
3b26be8f9   lsagona   controle the time...
10
11
      var messageToDisplay: Message? = null
          get() {
78935bd62   lsagona   slider bind to al...
12
13
              field =
                  messages.asSequence().map { it }.firstOrNull { observableCurrentTime.value < it.key }.let { it?.value }
3b26be8f9   lsagona   controle the time...
14
15
              return field
          }
df68a9fdc   lsagona   refactor graph mi...
16
17
      fun getAllTimeBeforeSelectedTime(): ArrayList<String> {
          val timeList = arrayListOf<String>()
e220e082b   lsagona   graph binded to s...
18
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
19
20
              if (it.value.time.value != null)
                  timeList.add(it.value.time.value!!)
e220e082b   lsagona   graph binded to s...
21
22
23
24
          }
  
          return timeList
      }
df68a9fdc   lsagona   refactor graph mi...
25
26
      fun getAllLatitudeBeforeSelectedTime(): ArrayList<Double> {
          val latitudeList = arrayListOf<Double>()
e220e082b   lsagona   graph binded to s...
27
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
28
29
              if (it.value.latitude.value != null)
                  latitudeList.add(it.value.latitude.value!!)
e220e082b   lsagona   graph binded to s...
30
31
32
33
          }
  
          return latitudeList
      }
df68a9fdc   lsagona   refactor graph mi...
34
35
      fun getAllLongitudeBeforeSelectedTime(): ArrayList<Double> {
          val longitudeList = arrayListOf<Double>()
e220e082b   lsagona   graph binded to s...
36
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
37
38
              if (it.value.longitude.value != null)
                  longitudeList.add(it.value.longitude.value!!)
e220e082b   lsagona   graph binded to s...
39
40
41
42
          }
  
          return longitudeList
      }
df68a9fdc   lsagona   refactor graph mi...
43
44
      fun getAllSpeedOverGroundBeforeSelectedTime(): ArrayList<Double> {
          val speedOverGroundList = arrayListOf<Double>()
e220e082b   lsagona   graph binded to s...
45
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
46
47
              if (it.value.speedOverGround.value != null)
                  speedOverGroundList.add(it.value.speedOverGround.value!!)
e220e082b   lsagona   graph binded to s...
48
49
50
51
          }
  
          return speedOverGroundList
      }
df68a9fdc   lsagona   refactor graph mi...
52
53
      fun getAllCourseOverGroundBeforeSelectedTime(): ArrayList<Double> {
          val res = arrayListOf<Double>()
e220e082b   lsagona   graph binded to s...
54
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
55
56
              if (it.value.courseOverGround.value != null)
                  res.add(it.value.courseOverGround.value!!)
e220e082b   lsagona   graph binded to s...
57
58
59
60
          }
  
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
61
62
      fun getAllHeadingBeforeSelectedTime(): ArrayList<Double> {
          val res = arrayListOf<Double>()
e220e082b   lsagona   graph binded to s...
63
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
64
65
              if (it.value.heading.value != null)
                  res.add(it.value.heading.value!!)
e220e082b   lsagona   graph binded to s...
66
67
68
69
          }
  
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
70
71
      fun getAllVesselNameBeforeSelectedTime(): ArrayList<String> {
          val res = arrayListOf<String>()
e220e082b   lsagona   graph binded to s...
72
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
73
74
              if (it.value.vesselName.value != null)
                  res.add(it.value.vesselName.value!!)
e220e082b   lsagona   graph binded to s...
75
76
77
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
78
79
      fun getAllIMOBeforeSelectedTime(): ArrayList<String> {
          val res = arrayListOf<String>()
e220e082b   lsagona   graph binded to s...
80
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
81
82
              if (it.value.imo.value != null)
                  res.add(it.value.imo.value!!)
e220e082b   lsagona   graph binded to s...
83
84
85
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
86
87
      fun getAllCallSignBeforeSelectedTime(): ArrayList<String> {
          val res = arrayListOf<String>()
e220e082b   lsagona   graph binded to s...
88
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
89
90
              if (it.value.callSign.value != null)
                  res.add(it.value.callSign.value!!)
e220e082b   lsagona   graph binded to s...
91
92
93
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
94
95
      fun getAllVesselTypeBeforeSelectedTime(): ArrayList<Double> {
          val res = arrayListOf<Double>()
e220e082b   lsagona   graph binded to s...
96
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
97
98
              if (it.value.vesselType.value != null)
                  res.add(it.value.vesselType.value!!)
e220e082b   lsagona   graph binded to s...
99
100
101
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
102
103
      fun getAllStatusBeforeSelectedTime(): ArrayList<String> {
          val res = arrayListOf<String>()
e220e082b   lsagona   graph binded to s...
104
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
105
106
              if (it.value.status.value != null)
                  res.add(it.value.status.value!!)
e220e082b   lsagona   graph binded to s...
107
108
109
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
110
111
      fun getAllLengthBeforeSelectedTime(): ArrayList<Double> {
          val res = arrayListOf<Double>()
e220e082b   lsagona   graph binded to s...
112
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
113
114
              if (it.value.length.value != null)
                  res.add(it.value.length.value!!)
e220e082b   lsagona   graph binded to s...
115
116
117
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
118
119
      fun getAllWidthBeforeSelectedTime(): ArrayList<Double> {
          val res = arrayListOf<Double>()
e220e082b   lsagona   graph binded to s...
120
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
121
122
              if (it.value.width.value != null)
                  res.add(it.value.width.value!!)
e220e082b   lsagona   graph binded to s...
123
124
125
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
126
127
      fun getAllDraftBeforeSelectedTime(): ArrayList<Double> {
          val res = arrayListOf<Double>()
e220e082b   lsagona   graph binded to s...
128
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
129
130
              if (it.value.draft.value != null)
                  res.add(it.value.draft.value!!)
e220e082b   lsagona   graph binded to s...
131
132
133
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
134
135
      fun getAllCargoBeforeSelectedTime(): ArrayList<Double> {
          val res = arrayListOf<Double>()
e220e082b   lsagona   graph binded to s...
136
          messageBeforeSelectedTime.forEach {
ea7eacbe6   lsagona   fix NPE
137
138
              if (it.value.cargo.value != null)
                  res.add(it.value.cargo.value!!)
e220e082b   lsagona   graph binded to s...
139
140
141
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
142
143
      fun getAllTime(): ArrayList<String> {
          val timeList = arrayListOf<String>()
513c0341c   lsagona   add chart
144
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
145
146
              if (it.value.time.value != null)
                  timeList.add(it.value.time.value!!)
513c0341c   lsagona   add chart
147
148
149
150
          }
  
          return timeList
      }
df68a9fdc   lsagona   refactor graph mi...
151
152
      fun getAllLatitude(): ArrayList<Double> {
          val latitudeList = arrayListOf<Double>()
513c0341c   lsagona   add chart
153
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
154
155
              if (it.value.latitude.value != null)
                  latitudeList.add(it.value.latitude.value!!)
513c0341c   lsagona   add chart
156
157
158
159
          }
  
          return latitudeList
      }
df68a9fdc   lsagona   refactor graph mi...
160
161
      fun getAllLongitude(): ArrayList<Double> {
          val longitudeList = arrayListOf<Double>()
513c0341c   lsagona   add chart
162
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
163
164
              if (it.value.longitude.value != null)
                  longitudeList.add(it.value.longitude.value!!)
513c0341c   lsagona   add chart
165
166
167
168
          }
  
          return longitudeList
      }
df68a9fdc   lsagona   refactor graph mi...
169
170
      fun getAllSpeedOverGround(): ArrayList<Double> {
          val speedOverGroundList = arrayListOf<Double>()
513c0341c   lsagona   add chart
171
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
172
173
              if (it.value.speedOverGround.value != null)
                  speedOverGroundList.add(it.value.speedOverGround.value!!)
513c0341c   lsagona   add chart
174
175
176
177
          }
  
          return speedOverGroundList
      }
df68a9fdc   lsagona   refactor graph mi...
178
179
      fun getAllCourseOverGround(): ArrayList<Double> {
          val res = arrayListOf<Double>()
513c0341c   lsagona   add chart
180
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
181
182
              if (it.value.courseOverGround.value != null)
                  res.add(it.value.courseOverGround.value!!)
513c0341c   lsagona   add chart
183
184
185
186
          }
  
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
187
188
      fun getAllHeading(): ArrayList<Double> {
          val res = arrayListOf<Double>()
513c0341c   lsagona   add chart
189
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
190
              if (it.value.heading.value != null)
df68a9fdc   lsagona   refactor graph mi...
191
              res.add(it.value.heading.value!!)
513c0341c   lsagona   add chart
192
193
194
195
          }
  
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
196
197
      fun getAllVesselName(): ArrayList<String> {
          val res = arrayListOf<String>()
513c0341c   lsagona   add chart
198
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
199
200
              if (it.value.vesselName.value != null)
                  res.add(it.value.vesselName.value!!)
513c0341c   lsagona   add chart
201
202
203
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
204
205
      fun getAllIMO(): ArrayList<String> {
          val res = arrayListOf<String>()
513c0341c   lsagona   add chart
206
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
207
208
              if (it.value.imo.value != null)
                  res.add(it.value.imo.value!!)
513c0341c   lsagona   add chart
209
210
211
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
212
213
      fun getAllCallSign(): ArrayList<String> {
          val res = arrayListOf<String>()
513c0341c   lsagona   add chart
214
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
215
216
              if (it.value.callSign.value != null)
                  res.add(it.value.callSign.value!!)
513c0341c   lsagona   add chart
217
218
219
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
220
221
      fun getAllVesselType(): ArrayList<Double> {
          val res = arrayListOf<Double>()
513c0341c   lsagona   add chart
222
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
223
224
              if (it.value.vesselType.value != null)
                  res.add(it.value.vesselType.value!!)
513c0341c   lsagona   add chart
225
226
227
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
228
229
      fun getAllStatus(): ArrayList<String> {
          val res = arrayListOf<String>()
513c0341c   lsagona   add chart
230
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
231
232
              if (it.value.status.value != null)
                  res.add(it.value.status.value!!)
513c0341c   lsagona   add chart
233
234
235
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
236
237
      fun getAllLength(): ArrayList<Double> {
          val res = arrayListOf<Double>()
513c0341c   lsagona   add chart
238
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
239
240
              if (it.value.length.value != null)
                  res.add(it.value.length.value!!)
513c0341c   lsagona   add chart
241
242
243
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
244
245
      fun getAllWidth(): ArrayList<Double> {
          val res = arrayListOf<Double>()
513c0341c   lsagona   add chart
246
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
247
248
              if (it.value.width.value != null)
                  res.add(it.value.width.value!!)
513c0341c   lsagona   add chart
249
250
251
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
252
253
      fun getAllDraft(): ArrayList<Double> {
          val res = arrayListOf<Double>()
513c0341c   lsagona   add chart
254
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
255
256
              if (it.value.draft.value != null)
                  res.add(it.value.draft.value!!)
513c0341c   lsagona   add chart
257
258
259
          }
          return res
      }
df68a9fdc   lsagona   refactor graph mi...
260
261
      fun getAllCargo(): ArrayList<Double> {
          val res = arrayListOf<Double>()
513c0341c   lsagona   add chart
262
          messages.forEach {
ea7eacbe6   lsagona   fix NPE
263
264
              if (it.value.cargo.value != null)
                  res.add(it.value.cargo.value!!)
513c0341c   lsagona   add chart
265
266
267
          }
          return res
      }
78935bd62   lsagona   slider bind to al...
268
      companion object {
3b26be8f9   lsagona   controle the time...
269
270
271
          var maxTime: Long = 0
          var minTime: Long = 0
      }
b350f9dfe   lsagona   import vessels an...
272
  }