Fin de la partie des bouttons pour voir avec les différentes vues

master
thchazot1 2 years ago
parent 5ad2b7e2b0
commit 2934812ae7

@ -7,6 +7,8 @@
<?import java.lang.Integer?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.text.Text?>
<BorderPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml">
<Text fx:id="temperatureCapteur"/>
<BorderPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" prefWidth="550" prefHeight="350">
<center>
<Text fx:id="temperatureCapteur"/>
</center>
</BorderPane>

@ -1,16 +1,8 @@
package view;
import javafx.beans.property.ListProperty;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleListProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.event.EventType;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
@ -20,10 +12,6 @@ import javafx.util.converter.NumberStringConverter;
import modele.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static java.lang.Float.parseFloat;
public class TreeViewCapteur extends FxmlWindow {
@ -111,7 +99,7 @@ public class TreeViewCapteur extends FxmlWindow {
EventHandler<ActionEvent> eventTextView = e -> {
try {
new ViewCapteurText(newV.getValue(), "/fxml/Capteur.fxml", "TextView");
new ViewCapteurText(newV.getValue(), "/fxml/CapteurText.fxml", "TextView");
} catch (IOException ex) {
throw new RuntimeException(ex);
}

@ -22,12 +22,19 @@ public class ViewCapteurImage extends FxmlWindow {
public ViewCapteurImage(Capteur leCapteur, String url, String title) throws IOException {
super(url, title);
temperature.textProperty().bindBidirectional(leCapteur.temperatureProperty(), new NumberStringConverter());
if (leCapteur.getTemperature()<0){
chooseImage((int) leCapteur.getTemperature());
leCapteur.temperatureProperty().addListener(((observableValue, oldV, newV) -> {
chooseImage(newV.intValue());
}));
}
private void chooseImage(int value){
if (value<0){
image.setImage(new Image("/Assets/hilarious-snow-memes.jpg"));
}
else if (leCapteur.getTemperature()<20){
else if (value<20){
image.setImage(new Image("https://www.francetvinfo.fr/pictures/sbviI2swQTsA1oabZGCUO9wWajQ/1200x900/2017/08/30/phppmKyIc_1.jpg"));
}
else {

Loading…
Cancel
Save