Commit 52321443a825ac8fb03d327344e14db4da305d0a
1 parent
43370abfea
Exists in
master
and in
1 other branch
different color for different boat + JMetro
Showing 6 changed files with 24 additions and 22 deletions Side-by-side Diff
build.gradle
View file @
5232144
src/main/kotlin/application/App.kt
View file @
5232144
... | ... | @@ -5,18 +5,18 @@ |
5 | 5 | import javafx.scene.Parent |
6 | 6 | import javafx.scene.Scene |
7 | 7 | import javafx.stage.Stage |
8 | +import jfxtras.styles.jmetro.JMetro | |
9 | +import jfxtras.styles.jmetro.Style | |
8 | 10 | |
9 | 11 | class App : Application() { |
12 | + var style : Style = Style.LIGHT | |
10 | 13 | |
11 | - | |
12 | 14 | override fun start(primaryStage: Stage?) { |
13 | 15 | |
14 | - | |
15 | - | |
16 | 16 | val fxmlLoader = FXMLLoader(App::class.java.getResource("/gui/windows.fxml")) |
17 | 17 | val parent: Parent = fxmlLoader.load() |
18 | 18 | val scene = Scene(parent) |
19 | - | |
19 | + JMetro(scene, style) | |
20 | 20 | primaryStage!!.scene = scene |
21 | 21 | primaryStage.title = "Maritime Visualisation" |
22 | 22 | primaryStage.show() |
src/main/kotlin/application/model/Message.kt
View file @
5232144
... | ... | @@ -20,5 +20,12 @@ |
20 | 20 | val draft: Double? = split[14].toDoubleOrNull() |
21 | 21 | val cargo: Int? = split[15].toIntOrNull() |
22 | 22 | |
23 | + fun getHexColor(): String{ | |
24 | + var hex = Integer.toHexString(this.mmsi!!) | |
25 | + if (hex.length > 6){ | |
26 | + hex = hex.substring(hex.length - 6) | |
27 | + } | |
28 | + return hex | |
29 | + } | |
23 | 30 | } |
src/main/kotlin/application/model/ObservableVessel.kt
View file @
5232144
1 | 1 | package application.model |
2 | 2 | |
3 | -import java.util.* | |
4 | 3 | import kotlin.properties.Delegates |
5 | 4 | |
6 | 5 | class ObservableVessel { |
... | ... | @@ -8,8 +7,7 @@ |
8 | 7 | |
9 | 8 | var vessels: MutableMap<Int?, Vessel> by Delegates.observable( |
10 | 9 | initialValue = mutableMapOf(), |
11 | - onChange = { | |
12 | - _, _, new -> | |
10 | + onChange = { _, _, new -> | |
13 | 11 | run { |
14 | 12 | listeners.forEach { |
15 | 13 | it.onValueChanged(new) |
src/main/kotlin/map/CircleMarkerGenerator.kt
View file @
5232144
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 | clearMapCanvas(map) |
14 | 14 | observableMessages.vessels.forEach { (_, value) -> |
15 | 15 | value.messages.forEach { (_, message) -> |
16 | - map.execScript("L.circleMarker([${message.latitude}, ${message.longitude}], {renderer: myRenderer, radius: 0.01}).addTo(myMap)") | |
16 | + map.execScript("L.circleMarker([${message.latitude}, ${message.longitude}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColor()}'}).addTo(myMap)") | |
17 | 17 | } |
18 | 18 | } |
19 | 19 | } |
src/main/resources/gui/windows.fxml
View file @
5232144
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | 2 | |
3 | -<?import javafx.scene.control.SplitPane?> | |
3 | +<?import javafx.scene.control.*?> | |
4 | 4 | <?import javafx.scene.layout.*?> |
5 | -<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="900.0" | |
6 | - prefWidth="1200.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1"> | |
5 | +<?import javafx.scene.shape.*?> | |
6 | + | |
7 | +<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="900.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1"> | |
7 | 8 | <children> |
8 | - <fx:include source="menuBar.fxml" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" | |
9 | - AnchorPane.topAnchor="0.0"/> | |
10 | - <SplitPane dividerPositions="0.29797979797979796" layoutY="25.0" prefHeight="379.0" prefWidth="594.0" | |
11 | - AnchorPane.bottomAnchor="-4.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="6.0" | |
12 | - AnchorPane.topAnchor="25.0"> | |
9 | + <fx:include source="menuBar.fxml" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> | |
10 | + <SplitPane dividerPositions="0.29797979797979796" layoutY="39.0" prefHeight="865.0" prefWidth="1194.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="35.0"> | |
13 | 11 | <items> |
14 | 12 | <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> |
15 | 13 | <children> |
16 | - <fx:include source="controlPanel.fxml" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" | |
17 | - AnchorPane.topAnchor="0.0"/> | |
14 | + <fx:include source="controlPanel.fxml" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> | |
18 | 15 | </children> |
19 | 16 | </AnchorPane> |
20 | 17 | <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> |
21 | 18 | <children> |
22 | - <SplitPane dividerPositions="0.536" layoutX="127.0" layoutY="74.0" orientation="VERTICAL" | |
23 | - prefHeight="200.0" prefWidth="160.0" AnchorPane.bottomAnchor="0.0" | |
24 | - AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> | |
19 | + <SplitPane dividerPositions="0.536" layoutX="127.0" layoutY="74.0" orientation="VERTICAL" prefHeight="200.0" prefWidth="160.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> | |
25 | 20 | <items> |
26 | 21 | <fx:include source="mapPanel.fxml" /> |
27 | - <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0"/> | |
22 | + <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0" /> | |
28 | 23 | </items> |
29 | 24 | </SplitPane> |
30 | 25 | </children> |
31 | 26 | </AnchorPane> |
32 | 27 | </items> |
33 | 28 | </SplitPane> |
29 | + <Line endX="1101.0" endY="1.1444091796875E-5" layoutX="101.0" layoutY="35.0" startX="-100.0" /> | |
34 | 30 | </children> |
35 | 31 | </AnchorPane> |