Blame view
src/main/kotlin/application/controller/MenuBarController.kt
3.21 KB
b350f9dfe import vessels an... |
1 |
package application.controller |
3b26be8f9 controle the time... |
2 |
import application.model.MapState.* |
b350f9dfe import vessels an... |
3 |
import application.model.createVesselCollection |
dd1ce7fe8 add button to swi... |
4 |
import application.model.observableIsReplayState |
3b26be8f9 controle the time... |
5 |
import application.model.observableMapState |
2bbe36a1b addd the possibil... |
6 |
import application.model.observableVessel |
b350f9dfe import vessels an... |
7 8 |
import javafx.event.EventHandler import javafx.fxml.FXML |
b350f9dfe import vessels an... |
9 |
import javafx.fxml.Initializable |
dd1ce7fe8 add button to swi... |
10 |
import javafx.scene.control.* |
b350f9dfe import vessels an... |
11 12 13 14 15 16 17 18 19 20 21 |
import javafx.stage.FileChooser import java.net.URL import java.util.* class MenuBarController : Initializable { @FXML var menuBar: MenuBar = MenuBar() @FXML var import: MenuItem = MenuItem() |
9e952e84e add message clust... |
22 23 24 25 26 27 28 29 |
@FXML var allMessages: CheckMenuItem = CheckMenuItem() @FXML var clusteredMessage: CheckMenuItem = CheckMenuItem() @FXML var heatMap: CheckMenuItem = CheckMenuItem() |
dd1ce7fe8 add button to swi... |
30 31 |
@FXML var activateReplayButton: RadioMenuItem = RadioMenuItem() |
b350f9dfe import vessels an... |
32 |
override fun initialize(location: URL?, resources: ResourceBundle?) { |
9e952e84e add message clust... |
33 34 35 36 37 |
setOnActionImportButton() setOnActionAllMessageButton() setOnActionClusteredMessageButton() setOnActionHeatMapButton() |
dd1ce7fe8 add button to swi... |
38 |
setOnActionActivateReplayButton() |
3b26be8f9 controle the time... |
39 |
observableMapState.state = CLUSTERED_MESSAGES |
79b001037 heat map |
40 |
allMessages.isSelected = false |
9e952e84e add message clust... |
41 |
clusteredMessage.isSelected = true |
79b001037 heat map |
42 |
heatMap.isSelected = false |
9e952e84e add message clust... |
43 44 |
} |
dd1ce7fe8 add button to swi... |
45 46 47 48 49 |
private fun setOnActionActivateReplayButton() { activateReplayButton.onAction = EventHandler { observableIsReplayState.value = activateReplayButton.isSelected } } |
9e952e84e add message clust... |
50 |
private fun setOnActionImportButton() { |
b350f9dfe import vessels an... |
51 52 53 54 55 |
import.onAction = EventHandler { val fileChooser = FileChooser() fileChooser.title = "Choose a file to import" val window = menuBar.scene.window val file = fileChooser.showOpenDialog(window) |
79b001037 heat map |
56 |
try { |
07bf03cd8 add alert message... |
57 58 59 60 61 62 63 |
if (file.extension != "csv") { val alert = Alert(Alert.AlertType.WARNING) alert.title = "Warning Alert" alert.headerText = "Wrong file format." alert.contentText = "Please choose à .csv file." alert.showAndWait() } |
79b001037 heat map |
64 65 66 |
val vessels = createVesselCollection(file) observableVessel.vessels.clear() observableVessel.vessels = vessels |
07bf03cd8 add alert message... |
67 |
} catch (ignore: IllegalStateException) { |
79b001037 heat map |
68 69 |
} |
b350f9dfe import vessels an... |
70 71 |
} } |
9e952e84e add message clust... |
72 73 74 |
private fun setOnActionAllMessageButton() { allMessages.onAction = EventHandler { |
3b26be8f9 controle the time... |
75 |
observableMapState.state = ALL_MESSAGES |
9e952e84e add message clust... |
76 77 78 79 80 81 82 83 |
allMessages.isSelected = true clusteredMessage.isSelected = false heatMap.isSelected = false } } private fun setOnActionClusteredMessageButton() { clusteredMessage.onAction = EventHandler { |
3b26be8f9 controle the time... |
84 |
observableMapState.state = CLUSTERED_MESSAGES |
9e952e84e add message clust... |
85 86 87 88 89 90 91 92 |
heatMap.isSelected = false allMessages.isSelected = false clusteredMessage.isSelected = true } } private fun setOnActionHeatMapButton() { heatMap.onAction = EventHandler { |
3b26be8f9 controle the time... |
93 |
observableMapState.state = HEAT_MAP |
9e952e84e add message clust... |
94 95 96 97 98 |
heatMap.isSelected = true clusteredMessage.isSelected = false allMessages.isSelected = false } } |
b350f9dfe import vessels an... |
99 |
} |