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) } return timeList } fun getAllLatitudeBeforeSelectedTime(): ArrayList { val latitudeList = arrayListOf() messageBeforeSelectedTime.forEach { latitudeList.add(it.value.latitude) } return latitudeList } fun getAllLongitudeBeforeSelectedTime(): ArrayList { val longitudeList = arrayListOf() messageBeforeSelectedTime.forEach { longitudeList.add(it.value.longitude) } return longitudeList } fun getAllSpeedOverGroundBeforeSelectedTime(): ArrayList { val speedOverGroundList = arrayListOf() messageBeforeSelectedTime.forEach { speedOverGroundList.add(it.value.speedOverGround) } return speedOverGroundList } fun getAllCourseOverGroundBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.courseOverGround) } return res } fun getAllHeadingBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.heading) } return res } fun getAllVesselNameBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.vesselName) } return res } fun getAllIMOBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.imo) } return res } fun getAllCallSignBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.callSign) } return res } fun getAllVesselTypeBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.vesselType) } return res } fun getAllStatusBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.status) } return res } fun getAllLengthBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.length) } return res } fun getAllWidthBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.width) } return res } fun getAllDraftBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.draft) } return res } fun getAllCargoBeforeSelectedTime(): ArrayList { val res = arrayListOf() messageBeforeSelectedTime.forEach { res.add(it.value.cargo) } return res } fun getAllTime(): ArrayList { val timeList = arrayListOf() messages.forEach { timeList.add(it.value.time) } return timeList } fun getAllLatitude(): ArrayList { val latitudeList = arrayListOf() messages.forEach { latitudeList.add(it.value.latitude) } return latitudeList } fun getAllLongitude(): ArrayList { val longitudeList = arrayListOf() messages.forEach { longitudeList.add(it.value.longitude) } return longitudeList } fun getAllSpeedOverGround(): ArrayList { val speedOverGroundList = arrayListOf() messages.forEach { speedOverGroundList.add(it.value.speedOverGround) } return speedOverGroundList } fun getAllCourseOverGround(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.courseOverGround) } return res } fun getAllHeading(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.heading) } return res } fun getAllVesselName(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.vesselName) } return res } fun getAllIMO(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.imo) } return res } fun getAllCallSign(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.callSign) } return res } fun getAllVesselType(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.vesselType) } return res } fun getAllStatus(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.status) } return res } fun getAllLength(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.length) } return res } fun getAllWidth(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.width) } return res } fun getAllDraft(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.draft) } return res } fun getAllCargo(): ArrayList { val res = arrayListOf() messages.forEach { res.add(it.value.cargo) } return res } companion object { var maxTime: Long = 0 var minTime: Long = 0 } }