Blame view
src/main/kotlin/application/controller/TimePanel.kt
1.76 KB
3b26be8f9 controle the time... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
package application.controller import application.model.* import javafx.fxml.FXML import javafx.fxml.Initializable import javafx.scene.control.Button import javafx.scene.control.Slider import java.net.URL import java.util.* class TimePanel : Initializable { @FXML var timeSlider = Slider() @FXML var timeStop = Button() @FXML var timePlay = Button() override fun initialize(location: URL?, resources: ResourceBundle?) { setSliderMinMax() setSliderListener() |
dd1ce7fe8 add button to swi... |
27 28 |
disableAllButton() setDisable() |
3b26be8f9 controle the time... |
29 30 31 |
} private fun setSliderMinMax() { |
78935bd62 slider bind to al... |
32 33 |
timeSlider.min = 0.0 timeSlider.max = 0.0 |
dd1ce7fe8 add button to swi... |
34 |
observableVessel.listeners.add(object : MessageListener { |
3b26be8f9 controle the time... |
35 36 37 38 39 40 41 42 43 44 45 46 |
override fun onValueChanged(newValue: MutableMap<String?, Vessel>) { timeSlider.max = Vessel.maxTime.toDouble() timeSlider.min = Vessel.minTime.toDouble() } }) } private fun setSliderListener() { timeSlider.valueProperty().addListener { _, _, newValue -> observableCurrentTime.value = newValue.toInt() } } |
dd1ce7fe8 add button to swi... |
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
private fun disableAllButton() { timeStop.isDisable = true timeSlider.isDisable = true timePlay.isDisable = true } private fun unableAllButton() { timeStop.isDisable = false timeSlider.isDisable = false timePlay.isDisable = false } private fun setDisable() { observableIsReplayState.listeners.add(object : ReplayState { override fun onValueChanged(newValue: Boolean) { if (observableIsReplayState.value) { unableAllButton() } else { disableAllButton() } } }) } |
3b26be8f9 controle the time... |
70 |
} |