diff --git a/projet/.gitignore b/projet/.gitignore
new file mode 100644
index 0000000..35e755d
--- /dev/null
+++ b/projet/.gitignore
@@ -0,0 +1,133 @@
+# ---> JetBrains
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# AWS User-specific
+.idea/**/aws.xml
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+.idea/**/libraries
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn. Uncomment if using
+# auto-import.
+# .idea/artifacts
+# .idea/compiler.xml
+# .idea/jarRepositories.xml
+# .idea/modules.xml
+# .idea/*.iml
+# .idea/modules
+# *.iml
+# *.ipr
+
+# CMake
+cmake-build-*/
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# SonarLint plugin
+.idea/sonarlint/
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+# Editor-based Rest Client
+.idea/httpRequests
+
+# Android studio 3.1+ serialized cache file
+.idea/caches/build_file_checksums.ser
+
+# ---> macOS
+# General
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+# ---> Java
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+replay_pid*
+
diff --git a/projet/.idea/.gitignore b/projet/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/projet/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/projet/.idea/misc.xml b/projet/.idea/misc.xml
new file mode 100644
index 0000000..a346fd7
--- /dev/null
+++ b/projet/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projet/.idea/modules.xml b/projet/.idea/modules.xml
new file mode 100644
index 0000000..0395c8f
--- /dev/null
+++ b/projet/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projet/.idea/vcs.xml b/projet/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/projet/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projet/Capteurs.iml b/projet/Capteurs.iml
new file mode 100644
index 0000000..1d85562
--- /dev/null
+++ b/projet/Capteurs.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projet/README.md b/projet/README.md
new file mode 100644
index 0000000..d5792fa
--- /dev/null
+++ b/projet/README.md
@@ -0,0 +1,85 @@
+# La course de dé (version JavaFX)
+
+L'objectif de ce TP est d'ajouter une interface graphique au jeu de dé que vous avez codé en C++ en première année. Pour rappel :
+
+> La « course de dé » se joue en lançant un dé. Les joueurs jouent tour à tour (pour ce TP nous nous limiterons à deux joueurs). Lorsque c'est à son tour, le joueur lance un dé et, tant qu'il ne fait pas 1, accumule les points des lancers successifs. S'il fait 1, il perd les points qu'il avait accumulés pendant son tour de jeu et la main passe, c'est à l'autre joueur de jouer. Un joueur peut sciemment décider d'arrêter de lancer le dé et ainsi sécuriser le score de son tour de jeu. Le premier joueur qui atteint un score de victoire (par exemple 50) gagne.
+
+Afin de vous concenter sur l'interface graphique, nous vous fournissons la version Java du jeu que vous avez codé en C++. La conception de ce dernier est rappelé ci-dessous.
+
+```plantuml
+@startuml
+skinparam defaultFontName Tahoma
+skinparam classAttributeIconSize 0
+skinparam monochrome true
+skinparam shadowing false
+skinparam linetype ortho
+skinparam class {
+ BackgroundColor transparent
+}
+skinparam package {
+ BackgroundColor transparent
+}
+hide circle
+
+package launcher {
+
+class ConsoleGame {
+ +{static} main(args : String[])
+}
+
+}
+
+package model {
+
+class Dice {
+ -{static}NB_FACES_DEFAULT : int = 6 {frozen}
+ -nbFaces : int
+ -value : int
+
+ +Dice(nbFaces : int)
+ +Dice()
+ +getValue() : int
+ +roll() : int
+ +clear()
+}
+
+class Player {
+ -{static}num : int = 0
+ -name : string
+ -totalScore : int
+ -currentScore : int
+
+ +Player(name : string)
+ +Player()
+ +getName() : string
+ +getCurrentScore() : int
+ +setCurrentScore(score : int)
+ +getTotalScore() : int
+ +setTotalScore(score : int)
+}
+
+class Game {
+ +{static}LOSE_DICE_VALUE : int = 1 {frozen}
+ +{static}SCORE_TO_WIN : int = 50 {frozen}
+ -gameOver : boolean
+ -currentPlayerIndex : int
+
+ +Game()
+ +addPlayer(player : Player)
+ +getCurrentPlayer() : Player
+ +rollDice()
+ +getDiceValue() : int
+ +isGameOver() : boolean
+ +passToNextPlayer()
+ +restart()
+}
+
+Game --> "-dice" Dice
+Game --> "*\n-players" Player
+ConsoleGame ..> Game
+
+}
+
+@enduml
+```
+
diff --git a/projet/ressources/css/application.css b/projet/ressources/css/application.css
new file mode 100644
index 0000000..1ec7fc1
--- /dev/null
+++ b/projet/ressources/css/application.css
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2012, 2014 Oracle and/or its affiliates.
+ * All rights reserved. Use is subject to license terms.
+ *
+ * This file is available and licensed under the following license:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ * - Neither the name of Oracle nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+root {
+ display: block;
+}
+
+.root {
+ -fx-background-image: url("https://www.francetvinfo.fr/pictures/zwzFc6PU5JuzL2NA0BwMqhCrvo0/1200x900/2016/08/23/shrek-5.jpg");
+}
+
+.label {
+ -fx-font-size: 12px;
+ -fx-font-weight: bold;
+ -fx-text-fill: #333333;
+ -fx-effect: dropshadow( gaussian , rgba(255,255,255,0.5) , 0,0,0,1 );
+}
+
+#welcome {
+ -fx-font-size: 75px;
+ -fx-font-family: "Arial Black";
+ -fx-fill: #818181;
+ -fx-effect: innershadow( three-pass-box , rgba(0,0,0,0.7) , 6, 0.0 , 0 , 2 );
+}
+
+#left{
+ -fx-text-fill: red;
+}
+
+
+.button {
+ -fx-text-fill: white;
+ -fx-font-family: "Arial Narrow";
+ -fx-font-weight: bold;
+ -fx-background-color: #B0E0E6;
+ -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 );
+}
+
+
+.button:hover {
+ -fx-background-color: linear-gradient(#2A5058, #61a2b1);
+}
+
+#rectangle{
+ -fx-background-image: url("https://i-mom.unimedias.fr/2020/09/16/gingy-shrek.jpg?auto=format,compress&cs=tinysrgb");
+}
\ No newline at end of file
diff --git a/projet/ressources/fxml/Capteur.fxml b/projet/ressources/fxml/Capteur.fxml
new file mode 100644
index 0000000..ca031a8
--- /dev/null
+++ b/projet/ressources/fxml/Capteur.fxml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projet/ressources/fxml/TreeViewCapteur.fxml b/projet/ressources/fxml/TreeViewCapteur.fxml
new file mode 100644
index 0000000..8a2f537
--- /dev/null
+++ b/projet/ressources/fxml/TreeViewCapteur.fxml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projet/src/launcher/Launch.java b/projet/src/launcher/Launch.java
new file mode 100644
index 0000000..d7c4c6e
--- /dev/null
+++ b/projet/src/launcher/Launch.java
@@ -0,0 +1,60 @@
+package launcher;
+
+import javafx.application.Application;
+import javafx.application.Platform;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.collections.ObservableMap;
+import javafx.stage.Stage;
+import modele.Capteur;
+import modele.CapteurVirtuel;
+import modele.Stub;
+import view.TreeViewCapteur;
+import view.ViewCapteurVirtuel;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+public class Launch extends Application {
+
+ @Override
+ public void start(Stage primaryStage) throws IOException {
+
+ /*Parent root = FXMLLoader.load(getClass().getResource("/fxml/Capteur.fxml"));
+ Scene scene = new Scene(root);*/
+ CapteurVirtuel leCapteurVirtuel = (CapteurVirtuel) Stub.genererCapteur();
+ ObservableList capteurs = Stub.genererObservableList();
+ TreeViewCapteur treeViewCapteur = new TreeViewCapteur(capteurs,"/fxml/TreeViewCapteur.fxml","Mon capteur");
+
+ Thread t = new Thread(() -> {
+ Random r = new Random();
+ while (true) {
+ try {
+ Thread.sleep(1000);
+ Platform.runLater(() -> {
+ for (ObservableMap.Entry map : leCapteurVirtuel.getLesCapteurs().entrySet()) {
+ try {
+ map.getValue().genTemp(r.nextFloat(50));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ leCapteurVirtuel.genTemp(1);
+ });
+
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+
+ t.start();
+
+ }
+
+ public static void main(String args[]) {
+ Application.launch(args);
+ }
+}
\ No newline at end of file
diff --git a/projet/src/modele/Capteur.java b/projet/src/modele/Capteur.java
new file mode 100644
index 0000000..fdaf089
--- /dev/null
+++ b/projet/src/modele/Capteur.java
@@ -0,0 +1,34 @@
+package modele;
+
+import javafx.beans.InvalidationListener;
+import javafx.beans.Observable;
+import javafx.beans.property.*;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class Capteur {
+
+ public Capteur(float temp, String nom) {
+
+ this.temperature.set(temp);
+ this.nom.set(nom);
+ }
+
+ private final FloatProperty temperature = new SimpleFloatProperty();
+ public float getTemperature() {return temperature.get();}
+ public FloatProperty temperatureProperty() {return temperature;}
+ public void setTemperature(float temperature) {this.temperature.set(temperature);}
+
+ private final StringProperty nom = new SimpleStringProperty();
+ public String getNom() {return nom.get();}
+ public StringProperty nomProperty() {return nom;}
+ public void setNom(String nom) {this.nom.set(nom);}
+
+
+ public abstract void genTemp(float x) throws IOException;
+}
+
diff --git a/projet/src/modele/CapteurVirtuel.java b/projet/src/modele/CapteurVirtuel.java
new file mode 100644
index 0000000..c29724e
--- /dev/null
+++ b/projet/src/modele/CapteurVirtuel.java
@@ -0,0 +1,42 @@
+package modele;
+
+import javafx.beans.property.ListProperty;
+import javafx.beans.property.MapProperty;
+import javafx.beans.property.SimpleListProperty;
+import javafx.beans.property.SimpleMapProperty;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.collections.ObservableMap;
+
+public class CapteurVirtuel extends Capteur{
+
+ public CapteurVirtuel(float temp, String nom) {
+ super(temp, nom);
+ }
+
+ private ObservableMap capteurObs = FXCollections.observableHashMap();
+ private final MapProperty lesCapteurs = new SimpleMapProperty<>(capteurObs);
+ public ObservableMap getLesCapteurs() {return lesCapteurs.getValue();}
+
+ public void setLesCapteurs(ObservableMap value) {lesCapteurs.set(value);}
+ public MapProperty lesCapteursProperty() {return lesCapteurs;}
+
+ public void addCapteur(Capteur capteur, Float poids) {
+ capteurObs.put(poids, capteur);
+ }
+
+ @Override
+ public void genTemp(float x) {
+ float tempTotal=0;
+ if (getLesCapteurs().size()==0){
+ setTemperature(0);
+ return;
+ }
+ for (ObservableMap.Entry map : capteurObs.entrySet()) {
+ tempTotal+=map.getValue().getTemperature()*map.getKey();
+ }
+ if (getLesCapteurs().size()==0) return;
+ tempTotal=tempTotal/getLesCapteurs().size();
+ setTemperature(tempTotal);
+ }
+}
diff --git a/projet/src/modele/CpuCapteur.java b/projet/src/modele/CpuCapteur.java
new file mode 100644
index 0000000..66efa0e
--- /dev/null
+++ b/projet/src/modele/CpuCapteur.java
@@ -0,0 +1,19 @@
+package modele;
+
+import javafx.beans.InvalidationListener;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class CpuCapteur extends Capteur{
+
+ public CpuCapteur(float temperature, String nom) {
+ super(temperature,nom);
+ }
+
+ @Override
+ public void genTemp(float x) throws IOException {
+ setTemperature(Float.parseFloat(Files.readString(Path.of("/sys/class/thermal/thermal_zone2/temp"))));
+ }
+}
diff --git a/projet/src/modele/RandomCapteur.java b/projet/src/modele/RandomCapteur.java
new file mode 100644
index 0000000..2ebc8da
--- /dev/null
+++ b/projet/src/modele/RandomCapteur.java
@@ -0,0 +1,18 @@
+package modele;
+
+import javafx.beans.InvalidationListener;
+
+import java.util.Random;
+
+public class RandomCapteur extends Capteur{
+
+ public RandomCapteur(float temperature, String nom) {
+ super(temperature, nom);
+ }
+
+ @Override
+ public void genTemp(float x) {
+ Random random = new Random();
+ setTemperature(random.nextFloat(x));
+ }
+}
diff --git a/projet/src/modele/Stub.java b/projet/src/modele/Stub.java
new file mode 100644
index 0000000..d1aa843
--- /dev/null
+++ b/projet/src/modele/Stub.java
@@ -0,0 +1,37 @@
+package modele;
+
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Stub {
+ public static Capteur genererCapteur() {
+ CapteurVirtuel retour = new CapteurVirtuel(45, "cap1");
+ retour.addCapteur(new CpuCapteur(12, "cap2"), 12F);
+ retour.addCapteur(new CpuCapteur(0, "cap3"), 7F);
+ retour.addCapteur(new CpuCapteur(20 ,"cap4"), 6F);
+ retour.addCapteur(new CpuCapteur(5, "cap5"), 4.5F);
+ retour.addCapteur(new RandomCapteur(25,"cap6"), 3F);
+ retour.addCapteur(new RandomCapteur(40,"cap7"), 1F);
+ retour.addCapteur(new RandomCapteur(30,"cap8"), 12F);
+
+ return retour;
+ }
+
+ public static ObservableList genererObservableList(){
+ List capteurs = new ArrayList<>();
+ CapteurVirtuel retour = new CapteurVirtuel(45, "cap1");
+ retour.addCapteur(new CpuCapteur(12, "cap2"), 12F);
+ retour.addCapteur(new CpuCapteur(0, "cap3"), 7F);
+ retour.addCapteur(new CpuCapteur(20 ,"cap4"), 6F);
+ retour.addCapteur(new CpuCapteur(5, "cap5"), 4.5F);
+ capteurs.add(retour);
+ capteurs.add(new CpuCapteur(0, "cap6"));
+ capteurs.add(new CpuCapteur(20 ,"cap7"));
+ capteurs.add(new CpuCapteur(5, "cap8"));
+
+ return FXCollections.observableList(capteurs);
+ }
+}
diff --git a/projet/src/view/FxmlWindow.java b/projet/src/view/FxmlWindow.java
new file mode 100644
index 0000000..ed097ca
--- /dev/null
+++ b/projet/src/view/FxmlWindow.java
@@ -0,0 +1,19 @@
+package view;
+
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.scene.SubScene;
+import javafx.stage.Stage;
+
+import java.io.IOException;
+import java.net.URL;
+
+public class FxmlWindow extends Stage {
+
+ public FxmlWindow(String url, String title) throws IOException {
+ FXMLLoader loader = new FXMLLoader(this.getClass().getResource(url));
+ loader.setController(this);
+ setScene(new Scene(loader.load()));
+ show();
+ }
+}
diff --git a/projet/src/view/Home.java b/projet/src/view/Home.java
new file mode 100644
index 0000000..54d2a10
--- /dev/null
+++ b/projet/src/view/Home.java
@@ -0,0 +1,15 @@
+package view;
+
+import javafx.event.Event;
+import javafx.fxml.FXML;
+import javafx.scene.Parent;
+import javafx.scene.control.Label;
+import javafx.scene.layout.Pane;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.Rectangle;
+import modele.RandomCapteur;
+
+public class Home {
+ public Home() {
+ }
+}
\ No newline at end of file
diff --git a/projet/src/view/TreeViewCapteur.java b/projet/src/view/TreeViewCapteur.java
new file mode 100644
index 0000000..39c7130
--- /dev/null
+++ b/projet/src/view/TreeViewCapteur.java
@@ -0,0 +1,66 @@
+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.Event;
+import javafx.event.EventHandler;
+import javafx.event.EventType;
+import javafx.fxml.FXML;
+import javafx.scene.control.*;
+import javafx.util.converter.NumberStringConverter;
+import modele.Capteur;
+import modele.CapteurVirtuel;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+public class TreeViewCapteur extends FxmlWindow {
+
+ public TreeViewCapteur(ObservableList lesCapteurs, String url, String title) throws IOException {
+ super(url,title);
+ this.lesCapteurs = lesCapteurs;
+
+ TreeItem root=new TreeItem<>();
+ for (Capteur capteur: lesCapteurs) {
+ TreeItem item = new TreeItem<>(capteur);
+ addTreeItem(item);
+ root.getChildren().add(item);
+ }
+ tree=new TreeView<>(root);
+ }
+
+ private void addTreeItem(TreeItem cap){
+ if (cap.getValue() instanceof CapteurVirtuel){
+ for (Capteur capteur : ((CapteurVirtuel) cap.getValue()).getLesCapteurs().values()){
+ TreeItem item = new TreeItem<>(capteur);
+ addTreeItem(item);
+ cap.getChildren().add(item);
+ }
+ }
+ cap.getChildren().add(cap);
+ }
+
+
+ @FXML
+ private TreeView tree;
+ @FXML
+ private TextArea name;
+ @FXML
+ private TextArea temperature;
+ private ObservableList lesCapteurs;
+
+
+
+ public void initialize() {
+ tree.getSelectionModel().selectedItemProperty().addListener((observableValue, capteurTreeItem, t1) -> {
+ name.textProperty().unbindBidirectional(t1.getValue().nomProperty());
+ temperature.textProperty().unbindBidirectional(t1.getValue().temperatureProperty());
+ });
+
+ }
+}
diff --git a/projet/src/view/ViewCapteurVirtuel.java b/projet/src/view/ViewCapteurVirtuel.java
new file mode 100644
index 0000000..409ec0a
--- /dev/null
+++ b/projet/src/view/ViewCapteurVirtuel.java
@@ -0,0 +1,65 @@
+package view;
+
+import javafx.beans.property.*;
+import javafx.beans.value.ObservableValue;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableArray;
+import javafx.collections.ObservableList;
+import javafx.collections.ObservableMap;
+import javafx.fxml.FXML;
+import javafx.scene.control.ListCell;
+import javafx.scene.control.ListView;
+import javafx.scene.control.TextArea;
+import javafx.util.converter.NumberStringConverter;
+import modele.Capteur;
+import modele.CapteurVirtuel;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ViewCapteurVirtuel extends FxmlWindow {
+
+ public ViewCapteurVirtuel(CapteurVirtuel leCapteur, String url, String title) throws IOException {
+ super(url,title);
+ this.leCapteur = leCapteur;
+ ListProperty lesCapteurs = new SimpleListProperty<>(FXCollections.observableList(new ArrayList<>(leCapteur.getLesCapteurs().values())));
+ listeDesCapteurs.itemsProperty().bind(lesCapteurs);
+ temperatureCapteurVirtuel.textProperty().bindBidirectional(leCapteur.temperatureProperty(), new NumberStringConverter());
+ }
+
+ @FXML
+ private ListView listeDesCapteurs;
+ @FXML
+ private TextArea temperatureCapteur;
+ @FXML
+ private TextArea temperatureCapteurVirtuel;
+ private Capteur leCapteur;
+
+ public void initialize() {
+ listeDesCapteurs.setCellFactory((param) ->
+ new ListCell() {
+ @Override
+ protected void updateItem(Capteur item, boolean empty) {
+ super.updateItem(item, empty);
+ if (!empty) {
+ textProperty().bind(item.temperatureProperty().asString());
+ } else {
+ textProperty().unbind();
+ setText("");
+ }
+ }
+ });
+
+ listeDesCapteurs.getSelectionModel().selectedItemProperty().addListener((__,old,newV)->{
+ if (old != null) {
+ temperatureCapteur.textProperty().unbindBidirectional(old.temperatureProperty());
+ }
+ if (newV != null) {
+ temperatureCapteur.textProperty().bindBidirectional((Property) newV.temperatureProperty().asString());
+ }
+ });
+
+ }
+
+}
diff --git a/projet/src/view/ViewRandom.java b/projet/src/view/ViewRandom.java
new file mode 100644
index 0000000..d08afed
--- /dev/null
+++ b/projet/src/view/ViewRandom.java
@@ -0,0 +1,11 @@
+package view;
+
+import javafx.beans.InvalidationListener;
+import javafx.beans.Observable;
+import javafx.scene.control.Spinner;
+import javafx.scene.control.TextArea;
+import javafx.scene.layout.BorderPane;
+import modele.RandomCapteur;
+import org.w3c.dom.Text;
+
+import java.io.IOException;
\ No newline at end of file