diff --git a/build.gradle b/build.gradle index 21964f8..5ee9a83 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,7 @@ repositories { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" + implementation 'org.jfxtras:jmetro:8.6.9' testCompile group: 'junit', name: 'junit', version: '4.12' } diff --git a/src/main/kotlin/application/App.kt b/src/main/kotlin/application/App.kt index fef4886..8dfb14d 100644 --- a/src/main/kotlin/application/App.kt +++ b/src/main/kotlin/application/App.kt @@ -5,18 +5,18 @@ import javafx.fxml.FXMLLoader import javafx.scene.Parent import javafx.scene.Scene import javafx.stage.Stage +import jfxtras.styles.jmetro.JMetro +import jfxtras.styles.jmetro.Style class App : Application() { - + var style : Style = Style.LIGHT override fun start(primaryStage: Stage?) { - - val fxmlLoader = FXMLLoader(App::class.java.getResource("/gui/windows.fxml")) val parent: Parent = fxmlLoader.load() val scene = Scene(parent) - + JMetro(scene, style) primaryStage!!.scene = scene primaryStage.title = "Maritime Visualisation" primaryStage.show() diff --git a/src/main/kotlin/application/model/Message.kt b/src/main/kotlin/application/model/Message.kt index 32f1209..ec918b5 100644 --- a/src/main/kotlin/application/model/Message.kt +++ b/src/main/kotlin/application/model/Message.kt @@ -20,4 +20,11 @@ class Message(split: List) { val draft: Double? = split[14].toDoubleOrNull() val cargo: Int? = split[15].toIntOrNull() + fun getHexColor(): String{ + var hex = Integer.toHexString(this.mmsi!!) + if (hex.length > 6){ + hex = hex.substring(hex.length - 6) + } + return hex + } } \ No newline at end of file diff --git a/src/main/kotlin/application/model/ObservableVessel.kt b/src/main/kotlin/application/model/ObservableVessel.kt index 41881a3..050ff8b 100644 --- a/src/main/kotlin/application/model/ObservableVessel.kt +++ b/src/main/kotlin/application/model/ObservableVessel.kt @@ -1,6 +1,5 @@ package application.model -import java.util.* import kotlin.properties.Delegates class ObservableVessel { @@ -8,8 +7,7 @@ class ObservableVessel { var vessels: MutableMap by Delegates.observable( initialValue = mutableMapOf(), - onChange = { - _, _, new -> + onChange = { _, _, new -> run { listeners.forEach { it.onValueChanged(new) diff --git a/src/main/kotlin/map/CircleMarkerGenerator.kt b/src/main/kotlin/map/CircleMarkerGenerator.kt index e30ebc0..cf81c8d 100644 --- a/src/main/kotlin/map/CircleMarkerGenerator.kt +++ b/src/main/kotlin/map/CircleMarkerGenerator.kt @@ -13,7 +13,7 @@ fun displayMessageOnMap(map: LeafletMapView) { clearMapCanvas(map) observableMessages.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> - map.execScript("L.circleMarker([${message.latitude}, ${message.longitude}], {renderer: myRenderer, radius: 0.01}).addTo(myMap)") + map.execScript("L.circleMarker([${message.latitude}, ${message.longitude}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColor()}'}).addTo(myMap)") } } } \ No newline at end of file diff --git a/src/main/resources/gui/windows.fxml b/src/main/resources/gui/windows.fxml index 6848204..d2fb1a8 100644 --- a/src/main/resources/gui/windows.fxml +++ b/src/main/resources/gui/windows.fxml @@ -1,35 +1,31 @@ - + - + + + - - + + - + - + - + +