Skip to content
Snippets Groups Projects
Commit 99243fce authored by Théo PIRKL's avatar Théo PIRKL
Browse files

Merge branch 'gui' into 'devel'

Basic GUI

See merge request !5
parents 1ebdd7c5 6042f915
Branches gui
No related tags found
2 merge requests!21*poof* final version,!5Basic GUI
package ch.hepia;
import ch.hepia.config.AppConfig;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
/**
* Starts up the app.
*/
public class Main extends Application {
/**
* Mein starter
* @param args The passed arguments
*/
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws IOException {
Parent root = FXMLLoader.load(Main.class.getResource("/fxml/ConnectionWindow.fxml"));
Scene scene = new Scene(root, AppConfig.APP_WIDTH, AppConfig.APP_HEIGHT);
stage.setScene(scene);
stage.show();
}
}
package ch.hepia.config;
/**
* The variables of the app
*/
public final class AppConfig {
public static final String APP_NAME = "TransportWave";
public static final Integer APP_WIDTH = 1000;
public static final Integer APP_HEIGHT = 565;
public static final String RABBITMQ_HOSTNAME = "redgrave.science";
public static final Integer RABBITMQ_PORT = 5672;
}
package ch.hepia.models;
import java.util.Objects;
/**
* Represents an user.
*/
public class User {
private String username;
public User(String username){
this.username = username;
}
public String getUsername(){
return username;
}
}
package ch.hepia.ui;
import ch.hepia.Main;
import ch.hepia.config.AppConfig;
import javafx.animation.FadeTransition;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javafx.util.Duration;
import java.net.URL;
import java.util.ResourceBundle;
public class ConnectionController implements Initializable {
@FXML
private Label appNameLabel;
@FXML
private Label appConnectionStatusLabel;
@FXML
private TextField usernameSelectionTextField;
@FXML
private Label errorLabel;
@FXML
private Button handleConfirmButton;
@FXML
public void handleConfirmButton(ActionEvent event) throws Exception {
handleConfirmButton.setDisable(true);
String oldText = handleConfirmButton.getText();
handleConfirmButton.setText("Veuillez patienter...");
if (usernameSelectionTextField.getText().isEmpty()){
FadeTransition fadeIn = new FadeTransition(Duration.millis(3000));
errorLabel.setText("Veuillez rentrer un nom d'utilisateur.");
errorLabel.setVisible(true);
fadeIn.setNode(errorLabel);
fadeIn.setFromValue(1.0);
fadeIn.setToValue(0.0);
fadeIn.setCycleCount(1);
fadeIn.setAutoReverse(false);
fadeIn.playFromStart();
} else {
// User user = new User(UsernameSelectionTextField.getText());
Stage stage = (Stage) handleConfirmButton.getScene().getWindow();
Parent root = FXMLLoader.load(Main.class.getResource("/fxml/MainWindow.fxml"));
Scene scene = new Scene(root, AppConfig.APP_WIDTH, AppConfig.APP_HEIGHT);
stage.close();
stage.setScene(scene);
stage.show();
}
handleConfirmButton.setText(oldText);
handleConfirmButton.setDisable(false);
}
@Override
public void initialize(URL location, ResourceBundle resources) {
// Faire les initialisations avant affichage ici.
appNameLabel.setText(AppConfig.APP_NAME);
appConnectionStatusLabel.setText("Merci de rentrer votre nom. Il permettra de vous identifier.");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="565.0" prefWidth="1000.0" style="-fx-background-color: #bababa;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.hepia.ui.ConnectionController">
<top>
<Label id="AppNameLabel" fx:id="appNameLabel" alignment="CENTER" contentDisplay="CENTER" prefHeight="80.0" prefWidth="1000.0" style="-fx-background-color: #35B1EE;" text="AppNameLabel" textAlignment="CENTER" textFill="WHITE" BorderPane.alignment="CENTER">
<font>
<Font size="35.0" />
</font>
</Label>
</top>
<center>
<GridPane BorderPane.alignment="CENTER">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label id="AppConnectionStatusLabel" fx:id="appConnectionStatusLabel" alignment="CENTER" text="AppConnectionStatusLabel" textAlignment="CENTER" textFill="WHITE" wrapText="true" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="BASELINE">
<GridPane.margin>
<Insets top="10.0" />
</GridPane.margin></Label>
<Button mnemonicParsing="false" fx:id="handleConfirmButton" onAction="#handleConfirmButton" text="Se connecter" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="1">
<GridPane.margin>
<Insets right="10.0" />
</GridPane.margin>
</Button>
<TextField fx:id="usernameSelectionTextField" maxWidth="205.0" GridPane.columnIndex="1" GridPane.rowIndex="1">
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin>
</TextField>
<Label id="AppConnectionStatusLabel" fx:id="errorLabel" alignment="CENTER" text="ErrorLabel" textAlignment="CENTER" textFill="RED" visible="false" wrapText="true" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="BOTTOM">
<GridPane.margin>
<Insets bottom="40.0" />
</GridPane.margin>
</Label>
</children>
</GridPane>
</center>
</BorderPane>
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.collections.FXCollections?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="565.0" prefWidth="1000.0" style="-fx-background-color: #fafafa;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<top>
<Pane maxHeight="48.0" maxWidth="1000.0" minHeight="48.0" minWidth="32.0" prefHeight="48.0" prefWidth="32.0" style="-fx-background-color: #35B1EE;" BorderPane.alignment="CENTER">
<children>
<ComboBox id="stopComboBox" fx:id="stopComboBox" editable="true" layoutX="12.0" layoutY="10.0" prefHeight="27.0" prefWidth="275.0" promptText="Tapez le nom d'un arrêt..." />
<Line endY="48.0" layoutX="300.0" startY="1.0">
<stroke>
<LinearGradient>
<stops>
<Stop color="#35b1ee" />
<Stop color="#004dff" offset="1.0" />
</stops>
</LinearGradient>
</stroke>
</Line>
<ComboBox id="directionComboBox" fx:id="directionComboBox" editable="true" layoutX="310.0" layoutY="10.0" prefHeight="27.0" prefWidth="282.0" promptText="Choisissez votre destination..." />
<Line endY="48.0" layoutX="603.0" layoutY="-1.0" startY="1.0">
<stroke>
<LinearGradient>
<stops>
<Stop color="#35b1ee" />
<Stop color="#004dff" offset="1.0" />
</stops>
</LinearGradient>
</stroke>
</Line>
</children>
</Pane>
</top>
<right>
<Pane prefHeight="517.0" prefWidth="326.0" BorderPane.alignment="CENTER" />
</right>
<center>
<Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<Label id="StopLabel" fx:id="StopLabel" layoutX="14.0" layoutY="14.0" text="Arrêt : CHANGEZ-MOI" textFill="#4c7ba8">
<font>
<Font size="28.0" />
</font>
</Label>
<Line endX="100.0" layoutX="115.0" layoutY="49.0" startX="-100.0" stroke="#4c7ba8" />
</children>
</Pane>
</center>
</BorderPane>
src/main/resources/img/close.png

1.16 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment