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() } private fun setSliderMinMax() { timeSlider.min = 0.0 timeSlider.max = 0.0 observableVessel.listeners.add(object : MessageListener{ override fun onValueChanged(newValue: MutableMap) { timeSlider.max = Vessel.maxTime.toDouble() timeSlider.min = Vessel.minTime.toDouble() } }) } private fun setSliderListener() { timeSlider.valueProperty().addListener { _, _, newValue -> observableCurrentTime.value = newValue.toInt() } } }