parent
f89b81c09f
commit
20016ad19d
@ -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*
|
||||||
|
|
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="18" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/Capteurs.iml" filepath="$PROJECT_DIR$/Capteurs.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/ressources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="lib" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -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");
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
<?import java.lang.Integer?>
|
||||||
|
<?import javafx.scene.image.ImageView?>
|
||||||
|
<SplitPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml">
|
||||||
|
<items>
|
||||||
|
<ListView fx:id="listeDesCapteurs" />
|
||||||
|
<TextArea fx:id="temperatureCapteur" wrapText="true" />
|
||||||
|
<TextArea fx:id="temperatureCapteurVirtuel"/>
|
||||||
|
</items>
|
||||||
|
</SplitPane>
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.*?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import java.lang.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
|
|
||||||
|
<SplitPane dividerPositions="0.3" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml">
|
||||||
|
<fx:define>
|
||||||
|
<Integer fx:id="moins1" fx:value="-1" />
|
||||||
|
</fx:define>
|
||||||
|
<items>
|
||||||
|
<TreeView fx:id="tree"/>
|
||||||
|
</items>
|
||||||
|
|
||||||
|
</SplitPane>
|
@ -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<Capteur> 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<Float, Capteur> 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);
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -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<Float, Capteur> capteurObs = FXCollections.observableHashMap();
|
||||||
|
private final MapProperty<Float, Capteur> lesCapteurs = new SimpleMapProperty<>(capteurObs);
|
||||||
|
public ObservableMap<Float, Capteur> getLesCapteurs() {return lesCapteurs.getValue();}
|
||||||
|
|
||||||
|
public void setLesCapteurs(ObservableMap<Float, Capteur> value) {lesCapteurs.set(value);}
|
||||||
|
public MapProperty<Float, Capteur> 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<Float, Capteur> map : capteurObs.entrySet()) {
|
||||||
|
tempTotal+=map.getValue().getTemperature()*map.getKey();
|
||||||
|
}
|
||||||
|
if (getLesCapteurs().size()==0) return;
|
||||||
|
tempTotal=tempTotal/getLesCapteurs().size();
|
||||||
|
setTemperature(tempTotal);
|
||||||
|
}
|
||||||
|
}
|
@ -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"))));
|
||||||
|
}
|
||||||
|
}
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
@ -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<Capteur> genererObservableList(){
|
||||||
|
List<Capteur> 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);
|
||||||
|
}
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
@ -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() {
|
||||||
|
}
|
||||||
|
}
|
@ -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<Capteur> lesCapteurs, String url, String title) throws IOException {
|
||||||
|
super(url,title);
|
||||||
|
this.lesCapteurs = lesCapteurs;
|
||||||
|
|
||||||
|
TreeItem<Capteur> root=new TreeItem<>();
|
||||||
|
for (Capteur capteur: lesCapteurs) {
|
||||||
|
TreeItem<Capteur> item = new TreeItem<>(capteur);
|
||||||
|
addTreeItem(item);
|
||||||
|
root.getChildren().add(item);
|
||||||
|
}
|
||||||
|
tree=new TreeView<>(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addTreeItem(TreeItem<Capteur> cap){
|
||||||
|
if (cap.getValue() instanceof CapteurVirtuel){
|
||||||
|
for (Capteur capteur : ((CapteurVirtuel) cap.getValue()).getLesCapteurs().values()){
|
||||||
|
TreeItem<Capteur> item = new TreeItem<>(capteur);
|
||||||
|
addTreeItem(item);
|
||||||
|
cap.getChildren().add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cap.getChildren().add(cap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TreeView<Capteur> tree;
|
||||||
|
@FXML
|
||||||
|
private TextArea name;
|
||||||
|
@FXML
|
||||||
|
private TextArea temperature;
|
||||||
|
private ObservableList<Capteur> lesCapteurs;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void initialize() {
|
||||||
|
tree.getSelectionModel().selectedItemProperty().addListener((observableValue, capteurTreeItem, t1) -> {
|
||||||
|
name.textProperty().unbindBidirectional(t1.getValue().nomProperty());
|
||||||
|
temperature.textProperty().unbindBidirectional(t1.getValue().temperatureProperty());
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -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<Capteur> lesCapteurs = new SimpleListProperty<>(FXCollections.observableList(new ArrayList<>(leCapteur.getLesCapteurs().values())));
|
||||||
|
listeDesCapteurs.itemsProperty().bind(lesCapteurs);
|
||||||
|
temperatureCapteurVirtuel.textProperty().bindBidirectional(leCapteur.temperatureProperty(), new NumberStringConverter());
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ListView<Capteur> listeDesCapteurs;
|
||||||
|
@FXML
|
||||||
|
private TextArea temperatureCapteur;
|
||||||
|
@FXML
|
||||||
|
private TextArea temperatureCapteurVirtuel;
|
||||||
|
private Capteur leCapteur;
|
||||||
|
|
||||||
|
public void initialize() {
|
||||||
|
listeDesCapteurs.setCellFactory((param) ->
|
||||||
|
new ListCell<Capteur>() {
|
||||||
|
@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<String>) newV.temperatureProperty().asString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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;
|
Loading…
Reference in new issue