|
|
@ -3,25 +3,27 @@ package fr.uca.iut.clfreville2.gui;
|
|
|
|
import fr.uca.iut.clfreville2.gui.image.ImageSupplier;
|
|
|
|
import fr.uca.iut.clfreville2.gui.image.ImageSupplier;
|
|
|
|
import fr.uca.iut.clfreville2.gui.image.StandardImageSupplier;
|
|
|
|
import fr.uca.iut.clfreville2.gui.image.StandardImageSupplier;
|
|
|
|
import fr.uca.iut.clfreville2.gui.list.NameableListCell;
|
|
|
|
import fr.uca.iut.clfreville2.gui.list.NameableListCell;
|
|
|
|
|
|
|
|
import fr.uca.iut.clfreville2.gui.thread.Ticker;
|
|
|
|
import fr.uca.iut.clfreville2.model.SensorRegistry;
|
|
|
|
import fr.uca.iut.clfreville2.model.SensorRegistry;
|
|
|
|
import fr.uca.iut.clfreville2.model.binding.ToBooleanBinding;
|
|
|
|
import fr.uca.iut.clfreville2.model.binding.ToBooleanBinding;
|
|
|
|
import fr.uca.iut.clfreville2.model.sensor.ManualSensor;
|
|
|
|
import fr.uca.iut.clfreville2.model.sensor.ManualSensor;
|
|
|
|
import fr.uca.iut.clfreville2.model.sensor.Sensor;
|
|
|
|
import fr.uca.iut.clfreville2.model.sensor.Sensor;
|
|
|
|
import fr.uca.iut.clfreville2.persistence.StubSensorRegistryLoader;
|
|
|
|
import fr.uca.iut.clfreville2.persistence.StubSensorRegistryLoader;
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
import javafx.scene.Scene;
|
|
|
|
|
|
|
|
import javafx.scene.control.Button;
|
|
|
|
import javafx.scene.control.Button;
|
|
|
|
import javafx.scene.control.ListView;
|
|
|
|
import javafx.scene.control.ListView;
|
|
|
|
import javafx.scene.control.Slider;
|
|
|
|
import javafx.scene.control.Slider;
|
|
|
|
import javafx.scene.control.TextField;
|
|
|
|
import javafx.scene.control.TextField;
|
|
|
|
import javafx.scene.image.ImageView;
|
|
|
|
import javafx.scene.image.ImageView;
|
|
|
|
import javafx.scene.text.Text;
|
|
|
|
import javafx.scene.text.Text;
|
|
|
|
|
|
|
|
import javafx.stage.Stage;
|
|
|
|
|
|
|
|
|
|
|
|
public class MainWindows {
|
|
|
|
public class MainWindows {
|
|
|
|
|
|
|
|
|
|
|
|
private final SensorRegistry registry = new StubSensorRegistryLoader().load();
|
|
|
|
private final SensorRegistry registry = new StubSensorRegistryLoader().load();
|
|
|
|
private final ImageSupplier imageSupplier = new StandardImageSupplier();
|
|
|
|
private final ImageSupplier imageSupplier = new StandardImageSupplier();
|
|
|
|
private ModalFactory modalFactory;
|
|
|
|
private final Ticker ticker;
|
|
|
|
|
|
|
|
private final ModalFactory modalFactory;
|
|
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
@FXML
|
|
|
|
private ListView<Sensor> sensorsList;
|
|
|
|
private ListView<Sensor> sensorsList;
|
|
|
@ -38,13 +40,20 @@ public class MainWindows {
|
|
|
|
@FXML
|
|
|
|
@FXML
|
|
|
|
private Button visualizeBtn;
|
|
|
|
private Button visualizeBtn;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MainWindows(Stage primaryStage) {
|
|
|
|
|
|
|
|
this.ticker = new Ticker(registry);
|
|
|
|
|
|
|
|
this.modalFactory = new ModalFactory(primaryStage);
|
|
|
|
|
|
|
|
primaryStage.setOnHidden((e) -> ticker.interrupt());
|
|
|
|
|
|
|
|
ticker.start();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
@FXML
|
|
|
|
public void onChangeClick() {
|
|
|
|
public void onChangeClick() {
|
|
|
|
Sensor selected = getSelectedSensor();
|
|
|
|
Sensor selected = getSelectedSensor();
|
|
|
|
if (!(selected instanceof ManualSensor sensor)) {
|
|
|
|
if (!(selected instanceof ManualSensor sensor)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getModalFactory().createModal(selected, root -> {
|
|
|
|
modalFactory.createModal(selected, root -> {
|
|
|
|
Slider slider = new Slider(-5, 30, sensor.getTemperature());
|
|
|
|
Slider slider = new Slider(-5, 30, sensor.getTemperature());
|
|
|
|
slider.setBlockIncrement(0.5);
|
|
|
|
slider.setBlockIncrement(0.5);
|
|
|
|
slider.setMajorTickUnit(0.5);
|
|
|
|
slider.setMajorTickUnit(0.5);
|
|
|
@ -61,7 +70,7 @@ public class MainWindows {
|
|
|
|
if (selected == null) {
|
|
|
|
if (selected == null) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getModalFactory().createModal(selected, root -> {
|
|
|
|
modalFactory.createModal(selected, root -> {
|
|
|
|
ImageView imageView = new ImageView();
|
|
|
|
ImageView imageView = new ImageView();
|
|
|
|
imageView.setPreserveRatio(true);
|
|
|
|
imageView.setPreserveRatio(true);
|
|
|
|
imageView.setFitHeight(200);
|
|
|
|
imageView.setFitHeight(200);
|
|
|
@ -107,15 +116,4 @@ public class MainWindows {
|
|
|
|
private Sensor getSelectedSensor() {
|
|
|
|
private Sensor getSelectedSensor() {
|
|
|
|
return sensorsList.getSelectionModel().getSelectedItem();
|
|
|
|
return sensorsList.getSelectionModel().getSelectedItem();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ModalFactory getModalFactory() {
|
|
|
|
|
|
|
|
if (modalFactory == null) {
|
|
|
|
|
|
|
|
Scene scene = sensorsList.getScene();
|
|
|
|
|
|
|
|
if (scene == null) {
|
|
|
|
|
|
|
|
throw new IllegalStateException("No scene found");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
modalFactory = new ModalFactory(scene.getWindow());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return modalFactory;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|