first commit

master
Théo DUPIN 2 years ago
commit 4c9e9ccc94

3
.idea/.gitignore vendored

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="lib">
<CLASSES>
<root url="file://$PROJECT_DIR$/../../../../openjfx-19_windows-x64_bin-sdk/javafx-sdk-19/lib" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$PROJECT_DIR$/../../../../openjfx-19_windows-x64_bin-sdk/javafx-sdk-19/lib" recursive="false" />
</library>
</component>

@ -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$/TP2.iml" filepath="$PROJECT_DIR$/TP2.iml" />
</modules>
</component>
</project>

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" 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$/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="openjdk-19" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="lib" level="project" />
</component>
</module>

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<BorderPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="view.CaptorMonitorWindow"
prefHeight="400.0" prefWidth="600.0">
<center>
<VBox>
<children>
<Label alignment="CENTER" contentDisplay="CENTER" prefHeight="31.0" prefWidth="280.0" text="Informations du capteur">
<font>
<Font name="System Bold" size="12.0" />
</font></Label>
<Label fx:id="idCapteur" text="ID:" />
<HBox prefHeight="10.0" prefWidth="280.0">
<children>
<Label prefHeight="25.0" prefWidth="70.0" text="Nom:" />
<TextField fx:id="nomCapteur" prefHeight="25.0" prefWidth="205.0">
<HBox.margin>
<Insets left="5.0" />
</HBox.margin>
</TextField>
</children>
</HBox>
</children>
</VBox>
</center>
<bottom>
<Button onAction="#exit" fx:id="buttonExit">Fermer</Button>
</bottom>
</BorderPane>

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane xmlns:fx="http://javafx.com/fxml"
xmlns="http://javafx.com/javafx"
fx:controller="view.ImageWindow"
prefHeight="400.0" prefWidth="600.0">
<BorderPane>
<ImageView fx:id="imageView"/>
</BorderPane>
<bottom>
<Button onAction="#exit" fx:id="buttonExit">Fermer</Button>
</bottom>
</BorderPane>

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<VBox xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="view.SpinnerWindow"
prefHeight="400.0" prefWidth="600.0">
<VBox>
<HBox>
<Spinner fx:id="spinner"/>
</HBox>
</VBox>
<Button onAction="#exit" fx:id="buttonExit">Fermer</Button>
</VBox>

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<BorderPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="view.CaptorMonitorWindow"
prefHeight="400.0" prefWidth="600.0">
<left>
<ListView fx:id="listView"/>
</left>
<center>
<VBox>
<BorderPane>
<center>
<VBox>
<HBox>
<Text>Id :</Text>
<Text> </Text>
<Text fx:id="id"/>
</HBox>
<HBox>
<Text>Nom du capteur :</Text>
<Text> </Text>
<Text fx:id="name"/>
</HBox>
</VBox>
</center>
</BorderPane>
<BorderPane>
<center>
<TableView style="-fx-padding: 20" fx:id="tableView">
<columns>
<TableColumn fx:id="nomInTable" text="Nom"/>
<TableColumn fx:id="idInTable" text="Id"/>
<TableColumn fx:id="poidsInTable" text="Poids"/>
<TableColumn fx:id="tempInTable" text="Température"/>
</columns>
</TableView>
</center>
<bottom>
<BorderPane>
<center>
<Button onAction="#update" fx:id="buttonRun" style="-fx-padding: 20">Demarrer</Button>
</center>
</BorderPane>
</bottom>
</BorderPane>
</VBox>
</center>
<bottom>
<Button onAction="#exit" fx:id="buttonExit">Fermer</Button>
</bottom>
</BorderPane>

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane xmlns:fx="http://javafx.com/fxml"
xmlns="http://javafx.com/javafx"
fx:controller="view.ImageWindow"
prefHeight="400.0" prefWidth="600.0">
<BorderPane>
<ImageView fx:id="imageView"/>
</BorderPane>
<bottom>
<Button onAction="#exit" fx:id="buttonExit">Fermer</Button>
</bottom>
</BorderPane>

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<VBox xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="view.SpinnerWindow"
prefHeight="400.0" prefWidth="600.0">
<Spinner/>
<Button onAction="#exit" fx:id="buttonExit">Fermer</Button>
</VBox>

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

@ -0,0 +1,48 @@
package launcher;
import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.stage.Stage;
import model.Captor;
public class Main extends Application {
@FXML
private TreeView<Captor> treeView;
@FXML
private TreeItem<Captor> root;
@FXML
private TextField texte;
@Override
public void start(Stage stage) throws Exception {
// Fenêtre Principale
Parent monitorWindow = FXMLLoader.load(getClass().getResource("/fxml/CaptorMonitorWindow.fxml"));
Stage monitorWindowStage = new Stage();
monitorWindowStage.setScene(new Scene(monitorWindow));
monitorWindowStage.setTitle("CaptorMonitorWindow");
monitorWindowStage.show();
// Fenêtre Image
Parent image = FXMLLoader.load(getClass().getResource("/fxml/ImageWindow.fxml"));
Stage imageStage = new Stage();
imageStage.setScene(new Scene(image));
imageStage.setTitle("ImageWindow");
imageStage.show();
// Fenêtre Spinner
/*Parent spinner = FXMLLoader.load(getClass().getResource("/fxml/SpinnerWindow.fxml"));
Stage spinnerStage = new Stage();
spinnerStage.setScene(new Scene(spinner));
spinnerStage.setTitle("SpinnerWindow");
spinnerStage.show();*/
}
}

@ -0,0 +1,70 @@
package model;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import java.util.UUID;
public abstract class Captor extends Observable {
// Id Property
private StringProperty id = new SimpleStringProperty();
public String getId(){
return id.get();
}
public void setId(String newId){
id.set(newId);
}
public StringProperty idProperty(){
return id;
}
// Name property
private StringProperty name = new SimpleStringProperty();
public String getName(){
return name.get();
}
public void setName(String newName){
name.set(newName);
}
public StringProperty nameProperty(){
return name;
}
// Temperature property
private DoubleProperty temp = new SimpleDoubleProperty();
public double getTemp(){
return temp.get();
}
public void setTemp(double newTemp){
temp.set(newTemp);
}
public DoubleProperty tempProperty(){
return temp;
}
// Generation
private String generationStrategy;
Captor(String name){
this.setName(name);
this.setId(UUID.randomUUID().toString());
this.setTemp(0);
}
public void setStrategie(String s){
this.generationStrategy = s;
}
public String getGenerationStrategy() {
return this.generationStrategy;
}
public void add(Captor captor,double coef){}
public abstract void run();
public String toString(){
return getName();
}
}

@ -0,0 +1,61 @@
package model;
import javafx.application.Platform;
public class CaptorBasique extends Captor {
private GenerationStrategy generationStrategy;
private int poids = 0;
private int delay = 1000;
public CaptorBasique(String nom, GenerationStrategy generation) {
super(nom);
this.generationStrategy = generation;
if(!(generationStrategy instanceof GenerationRandom)){
Thread t = new Thread((Runnable) this);
t.setDaemon(true);
t.start();
}
}
@Override
public void run(){
while (true){
try{
Platform.runLater( () -> this.setTemp(generationStrategy.generator()));
Thread.sleep(this.delay);
}
catch (InterruptedException e){
break;
}
}
}
@Override
public String toString() {
return "[" + super.getId() + "] " + super.getName() + ": " + generationStrategy.toString();
}
public int getPoids() {
return poids;
}
public void setPoids(int poids) {
this.poids = poids;
}
public GenerationStrategy getGenStrat() {
return generationStrategy;
}
public void setGenStrat(GenerationStrategy generationStrategy) {
this.generationStrategy = generationStrategy;
}
public int getDelay() {
return delay;
}
public void setDelay(int delay) {
this.delay = delay;
}
}

@ -0,0 +1,75 @@
package model;
import javafx.application.Platform;
import java.util.ArrayList;
import java.util.List;
public class CaptorZone extends Captor{
private List<Captor> listeCapteurs = new ArrayList<Captor>();
private int poids = 0;
private String generationStrategy = "Capteur Virtuel";
public CaptorZone(String nom) {
super(nom);
Thread t = new Thread((Runnable) this);
t.setDaemon(true);
t.start();
}
public int getPoids() {
return poids;
}
public void setPoids(int poids) {
this.poids = poids;
}
public String getGenerateurStrategique() {
return generationStrategy;
}
@Override
public String toString() {
return "[" + super.getId() + "] " + super.getName() + ": Virtuel";
}
public void addToList(Captor c){
this.listeCapteurs.add(c);
}
public void removeToList(Captor c){
listeCapteurs.remove(c);
}
public List<Captor> getListeCapteurs() {
return listeCapteurs;
}
@Override
public void run(){
while (true){
try{
Platform.runLater(() -> {
if(listeCapteurs.isEmpty()) return;
double temperatureMoyenne = 0;
int err = 0;
for(Captor c : listeCapteurs){
if(c == null){
err++;
break;
}
temperatureMoyenne += c.getTemp();
}
this.setTemp(temperatureMoyenne/(listeCapteurs.size()-err));
} );
Thread.sleep(1000);
}
catch (InterruptedException e){
break;
}
}
}
}

@ -0,0 +1,20 @@
package model;
import com.sun.management.OperatingSystemMXBean;
import java.lang.management.ManagementFactory;
public class GenerationCPU implements GenerationStrategy {
public GenerationCPU() {
generator();
}
@Override
public double generator() {
OperatingSystemMXBean sysBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
double temperature = sysBean.getSystemCpuLoad() * 100;
System.out.println("La température du CPU est de " + temperature + "°C");
return temperature;
}
}

@ -0,0 +1,9 @@
package model;
public class GenerationRandom implements GenerationStrategy{
@Override
public double generator() {
double tmp = Math.random()/Math.nextDown(1);
return 0*(1 - tmp) + 50 * tmp;
}
}

@ -0,0 +1,6 @@
package model;
public interface GenerationStrategy {
public abstract double generator();
}

@ -0,0 +1,21 @@
package model;
import java.util.List;
public class Observable {
protected List<Observer> observers;
public void attach(Observer o) {
observers.add(o);
}
public void detach(Observer o) {
observers.remove(o);
}
public void notifyObserver() {
for(Observer o : observers) {
o.update();
}
}
}

@ -0,0 +1,5 @@
package model;
public interface Observer {
public abstract void update();
}

@ -0,0 +1,35 @@
package view;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.*;
import javafx.scene.layout.VBox;
import model.CaptorBasique;
import java.io.IOException;
public class CaptorMonitorWindow extends VBox {
@FXML
private Label idCapteur;
@FXML
private TextField nomCapteur;
CaptorBasique captorBasique;
public void CaptorMonitorWindow(CaptorBasique c){
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/CaptorMonitorWindow.fxml"));
loader.setRoot(this);
loader.setController(this);
try {
loader.load();
} catch (IOException e) {
throw new RuntimeException(e);
}
this.captorBasique = c;
idCapteur.setText("ID: " + captorBasique.getId());
nomCapteur.setText(captorBasique.getName());
}
}

@ -0,0 +1,33 @@
package view;
import javafx.stage.Stage;
public class ControlWindow extends Stage {
private String title;
private String pathToFXMLRessource;
public ControlWindow(){}
public ControlWindow(String title,String pathToFXMLRessource){
this.title = title;
this.pathToFXMLRessource = pathToFXMLRessource;
}
public String getTitleFXMLWindow() {
return this.title;
}
public void setTitleFXMLWindow(String title) {
this.title = title;
}
public String getPathToFXMLRessource(){
return this.pathToFXMLRessource;
}
public void setPathToFXMLRessource(String pathToFXMLRessource) {
this.pathToFXMLRessource = pathToFXMLRessource;
}
}

@ -0,0 +1,45 @@
package view;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;
import model.Captor;
import java.util.List;
public class ImageWindow extends CaptorMonitorWindow {
@FXML
private Button buttonExit;
@FXML
private ImageView imageView;
private Captor capteur;
private List<Captor> listeCapteurs;
public ImageWindow(List<Captor> liste){
this.listeCapteurs = liste;
}
public void update() {
if (capteur.getTemp() <= 0) {
this.imageView.setImage(new javafx.scene.image.Image("/img/froid.png"));
} else if (capteur.getTemp() >= 40) {
this.imageView.setImage(new javafx.scene.image.Image("/img/chaud.png"));
} else {
this.imageView.setImage(new javafx.scene.image.Image("/img/moyen.png"));
}
}
public void initialize(){
this.imageView.setImage(new Image("/img/chaud.png"));
this.update();
}
public void exit(){
Stage stage = (Stage) buttonExit.getScene().getWindow();
stage.close();
}
}

@ -0,0 +1,26 @@
package view;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Spinner;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import model.Captor;
import java.util.ArrayList;
import java.util.List;
public class SpinnerWindow extends CaptorMonitorWindow {
@FXML
private Button buttonExit;
@FXML
private Spinner<Captor> spinner;
@FXML
private TextField textField;
private List<Captor> captorList = new ArrayList<>();
public void exit(){
Stage stage = (Stage) buttonExit.getScene().getWindow();
stage.close();
}
}
Loading…
Cancel
Save