Added my application (Vue + Model) and added the class diagram in the README

master
Emre KARTAL 2 years ago
parent 5c1d02a65c
commit 203f4b732c

@ -4,15 +4,165 @@
> <u>Une fenêtre avec un thermostat</u> : un spinner qui affiche et changer la température du capteur
<br>
<u>Une fenêtre avec une image</u> : représentant la température du capteur (pour les valeurs < 0°c on à une image de neige/glace, entre 0°c et 22°c une image de nuageux etc)
<u>Une fenêtre avec une image</u> : représentant la température du capteur (pour les valeurs < 0°c on a une image de neige/glace, entre 0°c et 25°c une image de nuageux etc.)
<br>
De plus si la fenêtre principale se ferme, tout les autres fenêtres se ferme
De plus, si la fenêtre principale se ferme, toutes les autres fenêtres se ferment.
## Fonctionnement
```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
class Stage {}
class Thread {}
package view {
class FXMLWindow {
+FXMLWindow(title : String, pathFxmlRessource : String)
}
class CaptorMonitorWindow {
+CaptorMonitorWindow(title : String, pathFxmlRessource : String, captor : Captor)
+getCaptor()
+setCaptor(captor : Captor)
}
class ImageWindow {
- IMAGES : NavigableMap<Double,image>
+imageWindow(captor : Captor)
+update()
}
class ThermostatWindow {
-spinner : Spinner
+ThermostaWindow(captor : Captor)
+update()
}
class CaptorWindow {
+openWindow(type : String, captor : Captor)
}
}
package model {
class VisitorCaptor {
+visit(captor : CaptorArea) : TreeItem<Captor>
+visit(captor : CaptorBasic) : TreeItem<Captor>
}
class CaptorStationStub {
+getCaptors()
}
class Captor {
-id : UUID
-name : string
-value : double
-time : double
+Captor(name : String)
+getId() : UUID
+getTime() : double
+getName() : String
+getStrategy() : GenerationStrategy
+setStrategy(strategy : GenerationStrategy)
+addCaptor(captor : Captor)
+getTemperature() : double
+accept(visitorCaptor : VisitorCaptor) : TreeItem<Captor>
}
interface GenerationStrategy {
+generate()
}
class GenBoundedRandom {
+genRandom()
+GenBoundedRandom(min : double, max : double)
}
class GenFloatingBound {}
class GenCPU {}
interface Observable {
+attach(observer : Observer<T>)
+detach(observer : Observer<T>)
+notify()
}
interface Observer {
+update()
}
class CaptorBasic {
+CaptorBasic(name : String, genStrategy : GenerationStrategy)
+addCaptor(captor : Captor) <<exception>>
}
class CaptorArea {
+Captor(name : String, captors : Map<Captor,Double>)
+getTemperature() : double
+addCaptor(captor : Captor)
}
class Double{}
CaptorWindow --> "-captors" CaptorStationStub
CaptorWindow ..> "Use" CaptorMonitorWindow
FXMLWindow --|> "Extends" Stage
CaptorMonitorWindow --|> FXMLWindow
CaptorMonitorWindow --> "-captor" Captor
CaptorMonitorWindow ..|> Observer
ImageWindow --|> CaptorMonitorWindow
ThermostaWindow --|> CaptorMonitorWindow
CaptorStationStub --> "*-captors" Captor
GenBoundedRandom ..|> GenerationStrategy
GenFloatingBound ..|> GenerationStrategy
GenCPU ..|> GenerationStrategy
Captor --|> Observable
Captor --> "-generationStrategy" GenerationStrategy
CaptorBasic --|> Thread
CaptorBasic --|> Captor
CaptorArea --|> Captor
CaptorArea --> "dictionnary<Captor,poids>" Double
Observable --> "-observers" Observer
}
@enduml
```
## Répartition du Gitlab
La racine de mon gitlab est composée de deux doissers essentiels au projet :
[**src**](src) : **Toute la partie codage de l'application**
[**doc**](doc) : **Documentation de l'application**
## Environnement de Travail
L'environnement de travail se base sur plusieurs outils :👇
L'environnement de travail se base sur un outil en particulier :👇
<div align = center>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

@ -0,0 +1,11 @@
<?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$/untitled/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -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$/TPCapteur.iml" filepath="$PROJECT_DIR$/TPCapteur.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="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>

@ -0,0 +1,25 @@
<?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="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://$PATH_TO_JAVAFX$" />
</CLASSES>
<JAVADOC />
<NATIVE>
<root url="file://$PATH_TO_JAVAFX$" />
</NATIVE>
<SOURCES />
<jarDirectory url="file://$PATH_TO_JAVAFX$" recursive="false" />
</library>
</orderEntry>
</component>
</module>

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Text?>
<BorderPane xmlns:fx="http://javafx.com/fxml" style="-fx-background-color: skyblue;" minWidth="500" fx:controller="view.CaptorWindow">
<left>
<BorderPane style="-fx-background-color: white;">
<top>
<TreeView fx:id="lvCaptors" maxWidth="200"/>
</top>
<bottom>
<Button style="-fx-background-color: transparent; -fx-font-weight: bold;" mnemonicParsing="false" onAction="#buttonExit" text="Fermer" BorderPane.alignment="CENTER" />
</bottom>
</BorderPane>
</left>
<center>
<BorderPane fx:id="master">
<top>
<VBox>
<HBox>
<Text text="UUID :" style="-fx-fill: white; -fx-font-weight: bold;"/>
<Label fx:id="id" maxWidth="250"/>
</HBox>
<HBox>
<Text text="NOM :" style="-fx-fill: white; -fx-font-weight: bold;" />
<TextField fx:id="nom" maxWidth="250"/>
</HBox>
</VBox>
</top>
<bottom>
<HBox>
<Button mnemonicParsing="false" text="Image" onAction="#openWindowImage"/>
<Button mnemonicParsing="false" text="Thermostat" onAction="#openWindowThermosta"/>
</HBox>
</bottom>
</BorderPane>
</center>
</BorderPane>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.StackPane?>
<BorderPane prefHeight="250.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/18"
xmlns:fx="http://javafx.com/fxml/1">
<top>
<Label fx:id="nom" style="-fx-font-weight: bold; -fx-font-size: 22;" BorderPane.alignment="CENTER"/>
</top>
<center>
<StackPane>
<ImageView fx:id="image" fitHeight="350.0" fitWidth="500.0" pickOnBounds="true" preserveRatio="true" BorderPane.alignment="CENTER"/>
<Label fx:id="labelTemp" style="-fx-font-weight: bold;" BorderPane.alignment="CENTER"/>
</StackPane>
</center>
<bottom>
<Button style="-fx-background-color: transparent; -fx-font-weight: bold;" mnemonicParsing="false" onAction="#buttonExit" text="Fermer" BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets bottom="30.0" top="50.0"/>
</BorderPane.margin>
</Button>
</bottom>
</BorderPane>

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Slider?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>
<BorderPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/18"
xmlns:fx="http://javafx.com/fxml/1">
<center>
<Slider orientation="VERTICAL" BorderPane.alignment="CENTER" fx:id="slider" onMouseClicked="#onChange"
onMouseDragged="#onChange" showTickLabels="true" showTickMarks="true" min="-30" max="70" value="0">
<BorderPane.margin>
<Insets/>
</BorderPane.margin>
</Slider>
</center>
<bottom>
<Button style="-fx-background-color: transparent; -fx-font-weight: bold;" mnemonicParsing="false" onAction="#buttonExit" text="Fermer" BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets bottom="30.0" top="50.0"/>
</BorderPane.margin>
</Button>
</bottom>
<top>
<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
prefHeight="50.0" prefWidth="100.0" BorderPane.alignment="CENTER">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Thermostat"/>
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Température :">
<HBox.margin>
<Insets right="5.0"/>
</HBox.margin>
</Text>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="XXX" fx:id="valTemperature"/>
</children>
</HBox>
</children>
<BorderPane.margin>
<Insets top="20.0"/>
</BorderPane.margin>
</VBox>
</top>
</BorderPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Text?>
<BorderPane xmlns:fx="http://javafx.com/fxml" style="-fx-background-color: skyblue;" minWidth="500" fx:controller="view.CaptorWindow">
<left>
<BorderPane style="-fx-background-color: white;">
<top>
<TreeView fx:id="lvCaptors" maxWidth="200"/>
</top>
<bottom>
<Button style="-fx-background-color: transparent; -fx-font-weight: bold;" mnemonicParsing="false" onAction="#buttonExit" text="Fermer" BorderPane.alignment="CENTER" />
</bottom>
</BorderPane>
</left>
<center>
<BorderPane fx:id="master">
<top>
<VBox>
<HBox>
<Text text="UUID :" style="-fx-fill: white; -fx-font-weight: bold;"/>
<Label fx:id="id" maxWidth="250"/>
</HBox>
<HBox>
<Text text="NOM :" style="-fx-fill: white; -fx-font-weight: bold;" />
<TextField fx:id="nom" maxWidth="250"/>
</HBox>
</VBox>
</top>
<bottom>
<HBox>
<Button mnemonicParsing="false" text="Image" onAction="#openWindowImage"/>
<Button mnemonicParsing="false" text="Thermostat" onAction="#openWindowThermosta"/>
</HBox>
</bottom>
</BorderPane>
</center>
</BorderPane>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.StackPane?>
<BorderPane prefHeight="250.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/18"
xmlns:fx="http://javafx.com/fxml/1">
<top>
<Label fx:id="nom" style="-fx-font-weight: bold; -fx-font-size: 22;" BorderPane.alignment="CENTER"/>
</top>
<center>
<StackPane>
<ImageView fx:id="image" fitHeight="350.0" fitWidth="500.0" pickOnBounds="true" preserveRatio="true" BorderPane.alignment="CENTER"/>
<Label fx:id="labelTemp" style="-fx-font-weight: bold;" BorderPane.alignment="CENTER"/>
</StackPane>
</center>
<bottom>
<Button style="-fx-background-color: transparent; -fx-font-weight: bold;" mnemonicParsing="false" onAction="#buttonExit" text="Fermer" BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets bottom="30.0" top="50.0"/>
</BorderPane.margin>
</Button>
</bottom>
</BorderPane>

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Slider?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>
<BorderPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/18"
xmlns:fx="http://javafx.com/fxml/1">
<center>
<Slider orientation="VERTICAL" BorderPane.alignment="CENTER" fx:id="slider" onMouseClicked="#onChange"
onMouseDragged="#onChange" showTickLabels="true" showTickMarks="true" min="-30" max="70" value="0">
<BorderPane.margin>
<Insets/>
</BorderPane.margin>
</Slider>
</center>
<bottom>
<Button style="-fx-background-color: transparent; -fx-font-weight: bold;" mnemonicParsing="false" onAction="#buttonExit" text="Fermer" BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets bottom="30.0" top="50.0"/>
</BorderPane.margin>
</Button>
</bottom>
<top>
<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
prefHeight="50.0" prefWidth="100.0" BorderPane.alignment="CENTER">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Thermostat"/>
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Température :">
<HBox.margin>
<Insets right="5.0"/>
</HBox.margin>
</Text>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="XXX" fx:id="valTemperature"/>
</children>
</HBox>
</children>
<BorderPane.margin>
<Insets top="20.0"/>
</BorderPane.margin>
</VBox>
</top>
</BorderPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

@ -0,0 +1,29 @@
package launcher;
import model.*;
import java.util.HashMap;
public class Console {
public static void main(String[] args) throws Exception {
// Captor with GenCPU
Captor captor1 = new CaptorBasic("France", new GenCPU());
System.out.println(captor1.getId() + ": " + captor1.getName() + ", temperature : " + captor1.getTemperature());
// Captor with GenRandom
Captor captor2 = new CaptorBasic("Italie", new GenBoundedRandom(-10, 60));
System.out.println(captor2.getId() + ": " + captor2.getName() + ", temperature : " + captor2.getTemperature());
// CaptorArea
Captor captorZone = new CaptorArea("Europe", new HashMap<>());
captorZone.addCaptor(captor1, 20.0);
captorZone.addCaptor(captor2, 40.0);
System.out.println(captorZone.getId() + ": " + captorZone.getName() + ", temperature : " + captorZone.getTemperature());
}
}

@ -0,0 +1,33 @@
package launcher;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import model.CaptorBasic;
import model.GenCPU;
import view.FXMLWindow;
import view.ImageWindow;
import java.util.Objects;
public class main extends Application {
@Override
public void start(Stage stage) throws Exception {
/*FXMLWindow fxmlWindow = new FXMLWindow("/fxml/CaptorWindow.fxml", "Home");
fxmlWindow.show();*/
Parent page = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/CaptorWindow.fxml")));
Scene scene = new Scene(page);
stage.setScene(scene);
stage.setResizable(false);
stage.setTitle("Home");
stage.show();
}
}

@ -0,0 +1,68 @@
package model;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.control.TreeItem;
import java.util.List;
import java.util.UUID;
public abstract class Captor extends Observable {
private UUID id;
private StringProperty name;
private double value;
private double time;
public Captor(String name) {
this.id = UUID.randomUUID();
this.name = new SimpleStringProperty(name);
this.time = 4;
}
public UUID getId() {
return this.id;
}
public StringProperty getName() {
return this.name;
}
public void setName(String name) {
this.name = new SimpleStringProperty(name);
}
public abstract double getTemperature();
public abstract List<Captor> getCaptors() throws Exception;
public abstract GenStrategy getGenStrategy() throws Exception;
public abstract void setGenStrategy(GenStrategy genStrategy) throws Exception;
public abstract void addCaptor(Captor captor, double weight) throws Exception;
@Override
public String toString() {
return this.name.getValue();
}
public double getTime() {
return time;
}
public void setTime(double time) {
this.time = time;
}
public double getValue() {
return value;
}
public void setValue(double value) {
this.value = value;
this.notifyAllObservers();
}
public abstract TreeItem<Captor> accept(VisitorCaptor visitorCaptor) throws Exception;
}

@ -0,0 +1,62 @@
package model;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.control.TreeItem;
import java.util.*;
public class CaptorArea extends Captor {
Map<Captor, Double> captors = new HashMap<>();
public CaptorArea(String name, Map<Captor, Double> captors) {
super(name);
this.captors = captors;
}
@Override
public GenStrategy getGenStrategy() throws Exception {
throw new Exception("Impossible de renvoyer la strategie");
}
@Override
public void setGenStrategy(GenStrategy genStrategy) throws Exception {
throw new Exception("Impossible de renvoyer la strategie");
}
@Override
public double getTemperature() {
double temperatureSum = 0.0;
double weightSum = 0.0;
for (Map.Entry<Captor, Double> entry : captors.entrySet()) {
Captor captor = entry.getKey();
double weight = entry.getValue();
temperatureSum += captor.getTemperature() * weight;
weightSum += weight;
}
return temperatureSum / weightSum;
}
@Override
public List<Captor> getCaptors() throws Exception {
List<Captor> captor = new ArrayList<>();
for (Map.Entry<Captor, Double> entry : captors.entrySet()) {
captor.add(entry.getKey());
}
return captor;
}
@Override
public void addCaptor(Captor captor, double weight) throws Exception {
captors.put(captor, weight);
}
@Override
public TreeItem<Captor> accept(VisitorCaptor visitorCaptor) throws Exception {
return visitorCaptor.visit(this);
}
}

@ -0,0 +1,67 @@
package model;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.control.TreeItem;
import javafx.util.Duration;
import java.util.List;
import java.util.Map;
public class CaptorBasic extends Captor implements Runnable {
private GenStrategy genStrategie;
public CaptorBasic(String name, GenStrategy genStrategie) {
super(name);
this.genStrategie = genStrategie;
setValue(this.getTemperature());
run();
}
@Override
public double getTemperature() {
return this.genStrategie.generate();
}
@Override
public List<Captor> getCaptors() throws Exception {
throw new Exception("Impossible de retourner la liste des capteurs");
}
@Override
public GenStrategy getGenStrategy() {
return this.genStrategie;
}
@Override
public void setGenStrategy(GenStrategy genStrategie) {
this.genStrategie = genStrategie;
}
@Override
public void addCaptor(Captor captor, double weight) throws Exception {
throw new Exception("Impossible d'ajouter un capteur dans cette classe");
}
@Override
public void run() {
Timeline time = new Timeline(
new KeyFrame(Duration.seconds(this.getTime()), event -> {
if (getGenStrategy() != null) {
this.setValue(this.getGenStrategy().generate());
}
}
));
time.setCycleCount(Animation.INDEFINITE);
time.play();
}
@Override
public TreeItem<Captor> accept(VisitorCaptor visitorCaptor) {
return visitorCaptor.visit(this);
}
}

@ -0,0 +1,37 @@
package model;
import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import java.util.HashMap;
import java.util.List;
public class CaptorStationStub {
private ObservableList<Captor> captors = FXCollections.observableArrayList();
private ListProperty<Captor> groupe = new SimpleListProperty<>(captors);
public CaptorStationStub() throws Exception {
Captor captor1 = new CaptorBasic("France", new GenCPU());
Captor captor2 = new CaptorBasic("Italie", new GenBoundedRandom(-10, 60));
// CaptorArea
Captor captorZone = new CaptorArea("Europe", new HashMap<>()){{
addCaptor(captor1, 20.0);
addCaptor(captor2, 40.0);
}};
this.captors.add(captor1);
this.captors.add(captor2);
this.captors.add(captorZone);
}
public ObservableList<Captor> getGroupe() {
return groupe.get();
}
}

@ -0,0 +1,29 @@
package model;
import java.util.Random;
public class GenBoundedRandom implements GenStrategy {
private double min;
private double max;
public GenBoundedRandom(double min, double max) {
this.min = min;
this.max = max;
}
public void setMax(double max) {
this.max = max;
}
public void setMin(double min) {
this.min = min;
}
@Override
public double generate() {
Random random = new Random();
return random.nextDouble(min, max);
}
}

@ -0,0 +1,31 @@
package model;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class GenCPU implements GenStrategy {
@Override
public double generate() {
File file = new File("/sys/class/thermal/thermal_zone2/temp");
Scanner scanner = null;
String line = null;
try {
scanner = new Scanner(file);
while (scanner.hasNextLine()) {
line = scanner.nextLine();
while (line.length() > 0 && line.charAt(line.length() - 1) == '0') {
line = line.substring(0, line.length() - 1);
}
}
scanner.close();
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
return Double.parseDouble(line);
}
}

@ -0,0 +1,9 @@
package model;
public interface GenStrategy {
public default double generate() {
return (int) (Math.random() * (100 + 1));
}
}

@ -0,0 +1,24 @@
package model;
import java.util.ArrayList;
import java.util.List;
public abstract class Observable {
private List<Observer> observers = new ArrayList<>();
public void add(Observer o) {
observers.add(o);
}
public void remove(Observer o) {
observers.remove(o);
}
public void notifyAllObservers() {
for(Observer o : observers) {
o.update();
}
}
}

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

@ -0,0 +1,24 @@
package model;
import javafx.scene.control.TreeItem;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
public class VisitorCaptor {
public TreeItem<Captor> visit(CaptorArea captor) throws Exception {
TreeItem<Captor> itemCaptor = new TreeItem<>(captor, new ImageView(new Image(getClass().getResourceAsStream("/images/multi_captor_icon.png"))));
itemCaptor.setExpanded(true);
for (Captor c : captor.getCaptors()) {
itemCaptor.getChildren().add(c.accept(this));
}
return itemCaptor;
}
public TreeItem<Captor> visit(CaptorBasic captor){
TreeItem<Captor> itemCaptor = new TreeItem<>(captor, new ImageView(new Image(getClass().getResourceAsStream("/images/captor_icon.png"))));
return itemCaptor;
}
}

@ -0,0 +1,31 @@
package view;
import model.Captor;
import model.Observer;
public class CaptorMonitorWindow extends FXMLWindow implements Observer {
private Captor captor;
public CaptorMonitorWindow(String title, String pathFxmlRessource, Captor captor) {
super(title, pathFxmlRessource);
this.captor = captor;
this.captor.add(this);
}
public Captor getCaptor() {
return this.captor;
}
public void setCaptor(Captor captor) {
this.captor = captor;
}
@Override
public void update() {
}
}

@ -0,0 +1,84 @@
package view;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;
import model.Captor;
import model.CaptorStationStub;
import model.VisitorCaptor;
public class CaptorWindow {
@FXML
private TreeView<Captor> lvCaptors;
@FXML
private Label id;
@FXML
private TextField nom;
@FXML
private BorderPane master;
private CaptorStationStub captors = new CaptorStationStub();
public CaptorWindow() throws Exception {
}
@FXML
private void initialize() throws Exception {
TreeItem<Captor> root = new TreeItem<>();
root.setExpanded(true);
VisitorCaptor visitorCaptor = new VisitorCaptor();
for (Captor captor : captors.getGroupe()) {
root.getChildren().add(captor.accept(visitorCaptor));
//root.getChildren().add(toTreeItem(captor));
}
lvCaptors.setRoot(root);
lvCaptors.setShowRoot(false);
master.setVisible(false);
lvCaptors.getSelectionModel().selectedItemProperty().addListener((obs, oldV, newV) -> {
if(oldV != null) {
id.textProperty().unbind();
nom.textProperty().unbindBidirectional(oldV.getValue().getName());
master.setVisible(false);
}
if(newV != null) {
id.setText(newV.getValue().getId().toString());
nom.textProperty().bindBidirectional(newV.getValue().getName());
master.setVisible(true);
}
});
}
/*
public TreeItem<Captor> toTreeItem(Captor captor) throws Exception {
TreeItem<Captor> itemCaptor = new TreeItem<>(captor);
if (captor instanceof CaptorArea) {
itemCaptor.setExpanded(true);
for (Captor c : captor.getCaptors()) {
itemCaptor.getChildren().add(toTreeItem(c));
}
}
return itemCaptor;
}*/
public void openWindowImage(ActionEvent actionEvent) {
Captor selectedCaptor = lvCaptors.getSelectionModel().getSelectedItem().getValue();
ImageWindow imageWindow = new ImageWindow(selectedCaptor);
imageWindow.setResizable(false);
imageWindow.show();
}
public void openWindowThermosta(ActionEvent actionEvent) {
Captor selectedCaptor = lvCaptors.getSelectionModel().getSelectedItem().getValue();
ThermostatWindow thermostaWindow = new ThermostatWindow(selectedCaptor);
thermostaWindow.setResizable(false);
thermostaWindow.show();
}
public void buttonExit(ActionEvent actionEvent) {
Platform.exit();
}
}

@ -0,0 +1,26 @@
package view;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.stage.Stage;
import javafx.scene.Scene;
import java.io.IOException;
import java.util.Objects;
public class FXMLWindow extends Stage {
public FXMLWindow(String title, String pathFxmlRessource) {
try {
//Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource(pathFxmlRessource)));
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(pathFxmlRessource));
fxmlLoader.setController(this);
Parent root = fxmlLoader.load();
setTitle(title);
setScene(new Scene(root));
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,48 @@
package view;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import model.Captor;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import java.util.Map;
import java.util.NavigableMap;
import java.util.TreeMap;
public class ImageWindow extends CaptorMonitorWindow {
@FXML
private ImageView image;
@FXML
private Label nom;
@FXML
private Label labelTemp;
private static NavigableMap<Double, String> Images = new TreeMap<>();
public ImageWindow(Captor captor) {
super("Image", "/fxml/ImageWindow.fxml", captor);
Images.put(25.0, "soleil");
Images.put(0.0, "nuage");
nom.textProperty().bind(this.getCaptor().getName());
Images.put(-Double.MAX_VALUE, "neige");
update();
}
@FXML
public void buttonExit() {
Stage stage = (Stage) image.getScene().getWindow();
stage.close();
}
public void update() {
Map.Entry<Double, String> entry = Images.floorEntry(this.getCaptor().getValue());
if (entry != null && entry.getValue() != null) {
image.setImage(new Image("/images/" + entry.getValue() + ".jpg"));
}
labelTemp.setText(String.format("%.2f°C", this.getCaptor().getValue()));
}
}

@ -0,0 +1,36 @@
package view;
import javafx.fxml.FXML;
import javafx.scene.control.Slider;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import model.Captor;
public class ThermostatWindow extends CaptorMonitorWindow{
@FXML
private Text valTemperature;
@FXML
private Slider slider;
public ThermostatWindow(Captor captor) {
super("Thermosta", "/fxml/ThermostatWindow.fxml", captor);
}
public void initialize() {
//slider.valueProperty().bindBidirectional(getCaptor().getValue());
//valTemperature.textProperty().bind(getCaptor().getValue().asString());
}
@FXML
public void onChange() {
}
@FXML
public void buttonExit() {
Stage stage = (Stage) slider.getScene().getWindow();
stage.close();
}
}
Loading…
Cancel
Save