Details Button working (display only ImageView for now)
continuous-integration/drone/push Build is passing Details

master
dohodin 2 years ago
parent 2382b869ac
commit 4eebe3278f

@ -14,4 +14,3 @@ steps:
when:
branch:
- master
depends_on: [ build ]

@ -0,0 +1,10 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="76" name="Java" />
</Languages>
</inspection_tool>
</profile>
</component>

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<writeAnnotations>
<writeAnnotation name="javafx.fxml.FXML" />
</writeAnnotations>
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="liberica-18" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/Source/out" />
</component>

@ -4,7 +4,7 @@
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<SplitPane dividerPositions="0.29797979797979796" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.MainPage">
<SplitPane dividerPositions="0.29797979797979796" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.MainPage">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<ImageView fitHeight="73.0" fitWidth="73.0" layoutX="8.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="311.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="94.0" AnchorPane.topAnchor="14.0">
<Image url="@../img/th.png" />
@ -21,6 +21,7 @@
</ImageView>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<VBox fx:id="vb1" prefHeight="398.0" prefWidth="417.0" />
<VBox fx:id="vb1" prefHeight="366.0" prefWidth="417.0" />
<Pane fx:id="bottom" layoutX="14.0" layoutY="420.0" prefHeight="26.0" prefWidth="102.0" />
</AnchorPane>
</SplitPane>

@ -4,7 +4,7 @@
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<SplitPane dividerPositions="0.29797979797979796" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.MainPage">
<SplitPane dividerPositions="0.29797979797979796" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="view.MainPage">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<ImageView fitHeight="73.0" fitWidth="73.0" layoutX="8.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="311.0" AnchorPane.leftAnchor="8.0" AnchorPane.rightAnchor="94.0" AnchorPane.topAnchor="14.0">
<Image url="@../img/th.png" />
@ -21,6 +21,7 @@
</ImageView>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<VBox fx:id="vb1" prefHeight="398.0" prefWidth="417.0" />
<VBox fx:id="vb1" prefHeight="366.0" prefWidth="417.0" />
<Pane fx:id="bottom" layoutX="14.0" layoutY="420.0" prefHeight="26.0" prefWidth="102.0" />
</AnchorPane>
</SplitPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

@ -6,7 +6,7 @@ import javafx.beans.property.SimpleDoubleProperty;
import java.io.*;
public class CPUTemp implements GenererTemperature, Runnable {
public class CPUTemp implements Runnable {
DoubleProperty temperature = new SimpleDoubleProperty(0.0);
@ -16,7 +16,6 @@ public class CPUTemp implements GenererTemperature, Runnable {
this.name=nom;
genererTemperature();
}
@Override
public void genererTemperature(){
try{
File temp = new File("/sys/devices/virtual/thermal/thermal_zone6/temp");

@ -9,7 +9,7 @@ import javafx.beans.property.StringProperty;
import javafx.collections.*;
import java.util.*;
public class CapteurVirtuel extends Sujet implements Runnable {
public class CapteurVirtuel implements Runnable {
private final StringProperty nom;
private final DoubleProperty tempMoyenne = new SimpleDoubleProperty(0);
@ -54,7 +54,7 @@ public class CapteurVirtuel extends Sujet implements Runnable {
while (true){
Platform.runLater(this::updateData);
try{
Thread.sleep(1000);
Thread.sleep(2000);
}
catch (InterruptedException e){
break;

@ -1,9 +0,0 @@
package model;
import java.io.IOException;
public interface GenererTemperature {
abstract void genererTemperature() throws IOException;
}

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

@ -1,18 +0,0 @@
package model;
import java.util.ArrayList;
public abstract class Sujet {
public ArrayList<Observateur> observateur = new ArrayList<Observateur>();
public void attacher(Observateur o){
this.observateur.add(o);
}
public void notifier(){
for (Observateur o : observateur) {
o.update();
}
}
}

@ -1,22 +0,0 @@
package view;
import model.CapteurVirtuel;
import model.Observateur;
public class Image implements Observateur {
public float temperature;
/*
public void __construct(float temperature){
this.temperature = new Capteur("Test").getTemperature();
}
*/
public void initialize(){
}
public void update() {
}
}

@ -0,0 +1,128 @@
package view;
import javafx.beans.value.ObservableValue;
import javafx.collections.*;
import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import model.CapteurVirtuel;
import model.Captor;
import javafx.scene.image.Image;
import static javafx.application.Platform.exit;
public class ImageVue {
@FXML private ImageView img = new ImageView(new Image("https://media.istockphoto.com/id/1125717763/fr/vectoriel/ic%C3%B4ne-de-chargement-design-plat-de-vector-illustration.jpg?s=612x612&w=0&k=20&c=3bkStusySjnEyXtfik1gyjWJqKKd-xOhhMizNy9F-W8="));
@FXML private Label imgLabel = new Label();
@FXML private Button fermer = new Button("Fermer");
public void setDisplayWindowsCaptorVirtual(CapteurVirtuel cv){
setDisplayBothDisplay();
ObservableList<CapteurVirtuel> VirtualCaptor = FXCollections.observableArrayList(
TrueCaptor->new ObservableValue[]{
TrueCaptor.getTempMoyenneProperty()
}
);
VirtualCaptor.addListener((ListChangeListener.Change<? extends CapteurVirtuel> c) ->{
while (c.next()){
if (c.wasUpdated()){
try {
Double temp = cv.getTempMoyenne();
if (temp < 0) {
img.setImage(new javafx.scene.image.Image("https://static.vecteezy.com/ti/vecteur-libre/p1/1555350-montagne-enneigee-paysage-d-hiver-avec-flocons-de-neige-gratuit-vectoriel.jpg"));
} else if (temp > 30) {
img.setImage(new javafx.scene.image.Image("https://png.pngtree.com/thumb_back/fw800/background/20220515/pngtree-cartoon-landscape-with-house-and-summer-nature-scene-image_1367386.jpg"));
} else {
img.setImage(new javafx.scene.image.Image("https://www.tunisienumerique.com/wp-content/uploads/2023/01/meteo-nuage-1-compressed-1.jpg"));
}
imgLabel.textProperty().set(Math.round(temp * 10.0) / 10.0 + "°C");
}catch (NullPointerException ignored){}
}
}
});
VirtualCaptor.add(cv);
}
public void setDisplayWindow(Captor cap){
setDisplayBothDisplay();
ObservableList<Captor> CaptorObs = FXCollections.observableArrayList(
TrueCaptor->new ObservableValue[]{
TrueCaptor.getTemperatureProperty()
}
);
CaptorObs.addListener((ListChangeListener.Change<? extends Captor> c) ->{
while (c.next()){
if (c.wasUpdated()){
try {
Double temp = cap.getTemperature();
if (temp < 0) {
img.setImage(new javafx.scene.image.Image("https://static.vecteezy.com/ti/vecteur-libre/p1/1555350-montagne-enneigee-paysage-d-hiver-avec-flocons-de-neige-gratuit-vectoriel.jpg"));
} else if (temp > 30) {
img.setImage(new javafx.scene.image.Image("https://png.pngtree.com/thumb_back/fw800/background/20220515/pngtree-cartoon-landscape-with-house-and-summer-nature-scene-image_1367386.jpg"));
} else {
img.setImage(new javafx.scene.image.Image("https://www.tunisienumerique.com/wp-content/uploads/2023/01/meteo-nuage-1-compressed-1.jpg"));
}
imgLabel.textProperty().set(Math.round(temp * 10.0) / 10.0 + "°C");
}catch (NullPointerException ignored){}
}
}
});
CaptorObs.add(cap);
}
private void setDisplayBothDisplay() {
VBox vue = new VBox();
vue.setMinSize(600,400);
img.setFitWidth(600);
img.setFitHeight(400);
imgLabel.setFont(new Font("Arial", 25));
vue.getChildren().add(img);
vue.getChildren().add(imgLabel);
vue.getChildren().add(fermer);
fermer.setOnAction(e -> exit());
Scene SecondScene = new Scene(vue);
Stage Image = new Stage();
Image.setTitle("Image");
Image.setScene(SecondScene);
Image.show();
}
}

@ -10,9 +10,13 @@ import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.scene.text.Font;
import model.*;
import java.util.Objects;
import static java.lang.Integer.parseInt;
import static java.lang.Integer.valueOf;
public class MainPage {
@FXML private Pane bottom;
@FXML private Button FirstButton;
@FXML private Button SecondButton;
@FXML private VBox vb1;
@ -20,13 +24,19 @@ public class MainPage {
@FXML private ImageView open;
@FXML private final Button FirstCaptorButton = new Button();
@FXML private final Button SecondCaptorButton = new Button();
@FXML private final TextField coefCaptor1 = new TextField();
@FXML private final TextField coefCaptor2 = new TextField();
@FXML private final Button submitButton1 = new Button("Submit");
@FXML private final Button submitButton2 = new Button("Submit");
@FXML private final Label errorLabel = new Label("mich");
@FXML private final Button DetailsButtonVirtual = new Button("Détails");
@FXML private final Button DetailsButtonC1 = new Button("Détails");
@FXML private final Button DetailsButtonC2 = new Button("Détails");
CPUTemp cpuTemp = new CPUTemp("CPU Captor");
CapteurVirtuel cV1 = new CapteurVirtuel("CaptVirt1");
Captor c1 = new Captor("c1");
Captor c2 = new Captor("c2");
static CapteurVirtuel cV1 = new CapteurVirtuel("CaptVirt1");
static Captor c1 = new Captor("c1");
static Captor c2 = new Captor("c2");
@FXML
public void initialize() {
@ -40,6 +50,7 @@ public class MainPage {
FirstButton.setOnAction(e -> {
bottom.getChildren().clear();
vb1.getChildren().clear();
vb1.getChildren().add(setDisplayCPUCaptor());
@ -47,16 +58,18 @@ public class MainPage {
SecondButton.setOnAction(e -> {
bottom.getChildren().clear();
vb1.getChildren().clear();
vb1.getChildren().add(setDisplayVirtualCaptor());
bottom.getChildren().add(DetailsButtonVirtual);
if (!vb2.getChildren().isEmpty()){
open.setImage(new Image("https://www.citypng.com/public/uploads/preview/download-black-right-triangle-png-31629764954y0662peplm.png"));
vb2.getChildren().clear();
vb1.getChildren().clear();
}else{
vb1.getChildren().clear();
vb1.getChildren().add(setDisplayVirtualCaptor());
open.setImage(new Image("https://cdn-icons-png.flaticon.com/512/0/159.png"));
vb2.getChildren().add(setDisplayFirstCaptor());
vb2.getChildren().add(setDisplaySecondCaptor());
@ -66,19 +79,78 @@ public class MainPage {
FirstCaptorButton.setOnAction(e -> {
bottom.getChildren().clear();
vb1.getChildren().clear();
errorLabel.textProperty().set("");
vb1.getChildren().add(setDisplayCaptor(c1));
bottom.getChildren().add(DetailsButtonC1);
});
SecondCaptorButton.setOnAction(e -> {
bottom.getChildren().clear();
vb1.getChildren().clear();
errorLabel.textProperty().set("");
vb1.getChildren().add(setDisplayCaptor(c2));
bottom.getChildren().add(DetailsButtonC2);
});
submitButton1.setOnAction(e -> {
try {
if (!(parseInt(coefCaptor1.getText()) >= 0 && parseInt(coefCaptor1.getText()) <= 10)) {
errorLabel.textProperty().set("Mettez un coef valide");
} else {
errorLabel.textProperty().set("Opération validée");
c1.setCoef(parseInt(coefCaptor1.getText()));
}
}
catch (NumberFormatException n){
errorLabel.textProperty().set("Mettez un coef valide");
}
});
submitButton2.setOnAction(e -> {
try{
if (!(parseInt(coefCaptor2.getText()) >= 0 && parseInt(coefCaptor2.getText()) <= 10)) {
errorLabel.textProperty().set(String.valueOf(valueOf(parseInt(coefCaptor2.getText()))));
}else {
errorLabel.textProperty().set("Opération validée");
c2.setCoef(parseInt(coefCaptor2.getText()));
}
}catch (NumberFormatException n){
errorLabel.textProperty().set("Mettez un coef valide");
}
});
DetailsButtonC1.setOnAction(e -> {
ImageVue display = new ImageVue();
display.setDisplayWindow(c1);
});
DetailsButtonC2.setOnAction(e -> {
ImageVue display = new ImageVue();
display.setDisplayWindow(c2);
});
DetailsButtonVirtual.setOnAction(e -> {
ImageVue display = new ImageVue();
display.setDisplayWindowsCaptorVirtual(cV1);
});
}
private VBox setDisplayCPUCaptor() {
@ -149,7 +221,6 @@ public class MainPage {
FirstCaptorButton.setMaxWidth(Double.MAX_VALUE);
FirstCaptorButton.setAlignment(Pos.CENTER_LEFT);
Captor1.getChildren().add(FirstCaptorImage);
Captor1.getChildren().add(FirstCaptorButton);
@ -245,6 +316,8 @@ public class MainPage {
VBox Captor = new VBox();
HBox submitCoef = new HBox();
Label ViewTempCaptor = new Label("Temperature du capteur " + cap.getName() + " : " + Math.round(cap.getTemperature()*10.0)/10.0 + "°C");
ViewTempCaptor.setFont(new Font("Arial",25));
@ -258,9 +331,24 @@ public class MainPage {
CaptorImage.setFitHeight(300);
Label coefLabel = new Label("Changez le coef (de 1 à 10) : ");
coefLabel.setFont(new Font("Arial",20));
submitCoef.getChildren().add(coefLabel);
if (Objects.equals(cap.getName(), "c1")) {
submitCoef.getChildren().add(coefCaptor1);
submitCoef.getChildren().add(submitButton1);
} else if (Objects.equals(cap.getName(), "c2")) {
submitCoef.getChildren().add(coefCaptor2);
submitCoef.getChildren().add(submitButton2);
}
Captor.getChildren().add(CaptorImage);
Captor.getChildren().add(ViewTempCaptor);
Captor.getChildren().add(submitCoef);
Captor.getChildren().add(errorLabel);
ObservableList<Captor> CaptorObs = FXCollections.observableArrayList(
TrueCaptor->new ObservableValue[]{

@ -1,22 +1,5 @@
package view;
import model.CapteurVirtuel;
import model.Observateur;
public class Spinner {
public class Spinner implements Observateur {
public float temperature ;
/*
public void __construct(float temperature){
this.temperature = new Capteur("Test").getTemperature();
}
*/
public void initialize(){
}
public void update() {
}
}

Loading…
Cancel
Save