Skip to content
Snippets Groups Projects
Commit 1928d5dd authored by Masson Lea's avatar Masson Lea
Browse files

slider instead of textfield for seuil

parent dc1f8286
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.control.Slider?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="401.0" prefWidth="440.0" style="-fx-background-color: white;" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Vue.FXMLVueController">
<columnConstraints>
......@@ -193,19 +194,22 @@
<Label text="Seuil d'humidité minimum tolérable: " wrapText="true">
<font>
<Font size="14.0" />
</font></Label>
<TextField fx:id="seuil" alignment="CENTER_RIGHT" promptText="&lt;100" text="50"/>
</font>
</Label>
<Slider fx:id="seuil" blockIncrement="10" minorTickCount="10" majorTickUnit="10" min="10" max="90" value="50"
showTickLabels="true" showTickMarks="true" snapToTicks="true"/>
<!--TextField fx:id="seuil" alignment="CENTER_RIGHT" promptText="&lt;100" text="50"/-->
<Label text=" %" wrapText="true" />
</children>
<GridPane.margin>
<Insets />
</GridPane.margin>
</HBox>
<Label fx:id="seuilError" textFill="#c70606" wrapText="true" GridPane.halignment="RIGHT" GridPane.rowIndex="1" GridPane.valignment="TOP">
<!--Label fx:id="seuilError" textFill="#c70606" wrapText="true" GridPane.halignment="RIGHT" GridPane.rowIndex="1" GridPane.valignment="TOP">
<GridPane.margin>
<Insets right="40.0" />
</GridPane.margin>
</Label>
</Label-->
<HBox prefHeight="100.0" prefWidth="200.0" spacing="10.0" GridPane.rowIndex="2">
<children>
<Label text="Activer l'arrosage automatique : " wrapText="true">
......
......@@ -15,6 +15,8 @@ import java.util.Formatter;
import java.util.Locale;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.beans.InvalidationListener;
import javafx.beans.binding.Bindings;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
......@@ -29,6 +31,7 @@ import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
......@@ -62,7 +65,7 @@ public class FXMLVueController implements Initializable, Observer {
@FXML
private GridPane configuration;
@FXML
private TextField seuil;
private Slider seuil;
@FXML
private Label seuilError;
@FXML
......@@ -106,7 +109,6 @@ public class FXMLVueController implements Initializable, Observer {
private boolean isConnected = false;
private BluetoothManager bluetoothManager;
/**
* Initializes the controller class.
......@@ -120,22 +122,18 @@ public class FXMLVueController implements Initializable, Observer {
currentGridPane = accueil;
currentButton = buttonAccueil;
openPage(accueil, buttonAccueil);
//Only allow integers as a value for the seuil
seuil.textProperty().addListener(new ChangeListener<String>() {
seuil.valueProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if (!newValue.matches("\\d*")) {
seuil.setText(newValue.replaceAll("[^\\d]", ""));
}
seuilError.setText("");
if (!(seuil.getText().isEmpty()) && !(Integer.parseInt(seuil.getText())<100)){
seuilError.setText("La valeur du seuil doit être inférieure à 100%");
}
public void changed(ObservableValue<? extends Number> obs, Number oldval, Number newVal) {
int intVal = ((int) Math.round(newVal.doubleValue())/10)*10;
seuil.setValue(intVal);
humiditySeuil.setText(""+intVal);
}
});
//Bind the label for the senewValueuil in Accueil and the value in configurations
humiditySeuil.textProperty().bind(seuil.textProperty());
//humiditySeuil.textProperty().bind(Bindings.convert(seuil.valueProperty()));
humidityPlante.textProperty().addListener(new ChangeListener<String>() {
@Override
......@@ -264,7 +262,5 @@ public class FXMLVueController implements Initializable, Observer {
currentButton.setStyle("-fx-background-color: #d5d5d5ff");
currentButton = justClicked;
currentButton.setStyle("-fx-background-color: #7fca5eff");
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment