package application.model import java.util.* class Vessel(val mmsi: String?) { val messages: SortedMap = sortedMapOf() private val messageBeforeSelectedTime: Map get() { return messages.filter { observableCurrentTime.value > it.key } } var messageToDisplay: Message? = null get() { field = messages.asSequence().map { it }.firstOrNull { observableCurrentTime.value < it.key }.let { it?.value } return field } fun getAllTimeBeforeSelectedTime(): ArrayList { val timeList = arrayListOf() messageBeforeSelectedTime.forEach { timeList.add(it.value.time.value!!) } return timeList } fun getAllLatitudeBeforeSelectedTime(): ArrayList { val latitudeList = arrayListOf() messageBeforeSelectedTime.forEach { latitudeList.add(it.value.latitude.value!!) } return latitudeList } fun getAllLongitudeBeforeSelectedTime(): ArrayList { val longitudeList = arrayListOf() messageBeforeSelectedTime.forEach { longitudeList.add(it.value.longitude.value!!) } return longitudeList } fun getAllSpeedOverGroundBeforeSelectedTime(): ArrayList { val speedOverGroundList = arrayListOf() messageBeforeSelectedTime.forEach { speedOverGroundList.add(it.value.speedOverGround.value!!) } return speedOverGroundList } fun getAllCourseOverGroundBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.courseOverGround.value!!) } return res } fun getAllHeadingBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.heading.value!!) } return res } fun getAllVesselNameBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.vesselName.value!!) } return res } fun getAllIMOBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.imo.value!!) } return res } fun getAllCallSignBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.callSign.value!!) } return res } fun getAllVesselTypeBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.vesselType.value!!) } return res } fun getAllStatusBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.status.value!!) } return res } fun getAllLengthBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.length.value!!) } return res } fun getAllWidthBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.width.value!!) } return res } fun getAllDraftBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.draft.value!!) } return res } fun getAllCargoBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.cargo.value!!) } return res } fun getAllTime(): ArrayList { val timeList = arrayListOf() messages.forEach { timeList.add(it.value.time.value!!) } return timeList } fun getAllLatitude(): ArrayList { val latitudeList = arrayListOf() messages.forEach { latitudeList.add(it.value.latitude.value!!) } return latitudeList } fun getAllLongitude(): ArrayList { val longitudeList = arrayListOf() messages.forEach { longitudeList.add(it.value.longitude.value!!) } return longitudeList } fun getAllSpeedOverGround(): ArrayList { val speedOverGroundList = arrayListOf() messages.forEach { speedOverGroundList.add(it.value.speedOverGround.value!!) } return speedOverGroundList } fun getAllCourseOverGround(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.courseOverGround.value!!) } return res } fun getAllHeading(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.heading.value!!) } return res } fun getAllVesselName(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.vesselName.value!!) } return res } fun getAllIMO(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.imo.value!!) } return res } fun getAllCallSign(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.callSign.value!!) } return res } fun getAllVesselType(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.vesselType.value!!) } return res } fun getAllStatus(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.status.value!!) } return res } fun getAllLength(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.length.value!!) } return res } fun getAllWidth(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.width.value!!) } return res } fun getAllDraft(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.draft.value!!) } return res } fun getAllCargo(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.cargo.value!!) } return res } companion object { var maxTime: Long = 0 var minTime: Long = 0 } }