Ajouts : classe Données pour gerer les données en runtime ,evenement du menu principal; refractor: les ressources en discipline dans le fxml de fenetre pricipal et son controller; Changements : ScreenController est passé en static
This commit is contained in:
parent
54dbb4d45a
commit
82755c9015
35
src/main/java/fr/univ_amu/iut/Donnees.java
Normal file
35
src/main/java/fr/univ_amu/iut/Donnees.java
Normal file
@ -0,0 +1,35 @@
|
||||
package fr.univ_amu.iut;
|
||||
|
||||
import fr.univ_amu.iut.model.Academie;
|
||||
import fr.univ_amu.iut.model.Discipline;
|
||||
import fr.univ_amu.iut.model.Thematique;
|
||||
|
||||
public class Donnees {
|
||||
private static Academie academieSelectionee = null;
|
||||
private static Thematique thematiqueSelectionee = null;
|
||||
private static Discipline disciplineSelectionee = Discipline.Toutes;
|
||||
|
||||
public static Academie getAcademieSelectionee() {
|
||||
return academieSelectionee;
|
||||
}
|
||||
public static void setAcademieSelectionee(Academie academieSelectionee) {
|
||||
System.out.println("Academie Selectionée : %s".formatted(academieSelectionee.getNom()));
|
||||
Donnees.academieSelectionee = academieSelectionee;
|
||||
}
|
||||
public static Thematique getThematiqueSelectionee() {
|
||||
return thematiqueSelectionee;
|
||||
}
|
||||
public static void setThematiqueSelectionee(Thematique thematiqueSelectionee) {
|
||||
System.out.println("Thematique selectionée : %s".formatted((thematiqueSelectionee == null)? "Aucune Thematique" : thematiqueSelectionee.getNom()));
|
||||
Donnees.thematiqueSelectionee = thematiqueSelectionee;
|
||||
}
|
||||
public static Discipline getDisciplineSelectionee() {
|
||||
return disciplineSelectionee;
|
||||
}
|
||||
public static void setDisciplineSelectionee(Discipline disciplineSelectionee) {
|
||||
System.out.println("Discipline Selectionee : %s".formatted(disciplineSelectionee.getNom()));
|
||||
Donnees.disciplineSelectionee = disciplineSelectionee;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -8,42 +8,36 @@ import fr.univ_amu.iut.view.map.France;
|
||||
import fr.univ_amu.iut.view.map.FranceBuilder;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Background;
|
||||
import javafx.scene.layout.BackgroundFill;
|
||||
import javafx.scene.layout.CornerRadii;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class Main extends Application {
|
||||
France france;
|
||||
private Scene scene = new Scene(new Pane());
|
||||
private ScreenController gestionnaireDePages = new ScreenController(scene);
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
public void init() throws IOException {
|
||||
france = FranceBuilder.create()
|
||||
// .backgroundColor(Color.web("#4aa9d7"))
|
||||
// .fillColor(Color.web("#dcb36c"))
|
||||
// .strokeColor(Color.web("#987028"))
|
||||
// .hoverColor(Color.web("#fec47e"))
|
||||
// .pressedColor(Color.web("#6cee85"))
|
||||
// .selectedColor(Color.MAGENTA)
|
||||
// .mousePressHandler(evt -> {
|
||||
// AcademiePath academiePath = (AcademiePath) evt.getSource();
|
||||
// System.out.println("On vient de cliquer sur l'"+academiePath.getAcademie().getNom());
|
||||
// })
|
||||
.selectedColor(Color.MAGENTA)
|
||||
.mousePressHandler(evt -> {
|
||||
AcademiePath academiePath = (AcademiePath) evt.getSource();
|
||||
Donnees.setAcademieSelectionee(academiePath.getAcademie());
|
||||
})
|
||||
.selectionEnabled(true)
|
||||
.build();
|
||||
|
||||
|
||||
ScreenController.addScreen("Acceuil",FXMLLoader.load(getClass().getResource("/fr/univ_amu/iut/fp/fp.fxml")));
|
||||
ScreenController.addScreen("Resultats",FXMLLoader.load(getClass().getResource("/fr/univ_amu/iut/fResultat/FResultat.fxml")));;
|
||||
ScreenController.activate("Acceuil");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
Scene scene = new Scene(new Pane());
|
||||
ScreenController gestionnaireDePages = new ScreenController(scene);
|
||||
gestionnaireDePages.addScreen("Acceuil",FXMLLoader.load(getClass().getResource("/fr/univ_amu/iut/fp/fp.fxml")));
|
||||
gestionnaireDePages.addScreen("Resultats",FXMLLoader.load(getClass().getResource("/fr/univ_amu/iut/fResultat/FResultat.fxml")));;
|
||||
gestionnaireDePages.activate("Resultats");
|
||||
public void start(Stage stage){
|
||||
stage.setTitle("Carte des académie");
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
|
@ -1,24 +0,0 @@
|
||||
package fr.univ_amu.iut.fResultat;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
|
||||
|
||||
public class Main extends Application {
|
||||
|
||||
public static void main(String[] args) {launch(args);}
|
||||
@Override
|
||||
public void start(Stage stage) throws Exception {
|
||||
try {
|
||||
AnchorPane root = FXMLLoader.load(getClass().getResource("/fr/univ_amu/iut/fResultat/FResultat.fxml"));
|
||||
stage.setScene(new Scene(root));
|
||||
stage.show();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
package fr.univ_amu.iut.fp;
|
||||
|
||||
import fr.univ_amu.iut.Donnees;
|
||||
import fr.univ_amu.iut.dao.DAODiscipline;
|
||||
import fr.univ_amu.iut.dao.DAORessource;
|
||||
import fr.univ_amu.iut.dao.DAOThematique;
|
||||
import fr.univ_amu.iut.dao.factory.DAOFactory;
|
||||
import fr.univ_amu.iut.dao.factory.DAOFactoryProducer;
|
||||
import fr.univ_amu.iut.dao.factory.DAOType;
|
||||
import fr.univ_amu.iut.model.Ressource;
|
||||
import fr.univ_amu.iut.model.Discipline;
|
||||
import fr.univ_amu.iut.model.Thematique;
|
||||
import fr.univ_amu.iut.view.map.France;
|
||||
import fr.univ_amu.iut.view.map.FranceBuilder;
|
||||
@ -15,7 +17,8 @@ import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.event.ActionEvent;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
@ -25,14 +28,14 @@ public class Controller implements Initializable {
|
||||
|
||||
|
||||
DAOFactory daoFactory;
|
||||
DAORessource daoRessource;
|
||||
DAODiscipline daoDiscipline;
|
||||
DAOThematique daoThematique;
|
||||
|
||||
@FXML
|
||||
private Pane stackPaneFrance;
|
||||
|
||||
@FXML
|
||||
private AnchorPane ressource;
|
||||
private AnchorPane discipline;
|
||||
|
||||
@FXML
|
||||
private AnchorPane thematique;
|
||||
@ -58,29 +61,57 @@ public class Controller implements Initializable {
|
||||
<Button layoutX="332.0" layoutY="30.0" mnemonicParsing="false" prefHeight="115.0" prefWidth="235.0" style="-fx-background-radius: 30; -fx-background-color: #ff6e40#ff6e40;" text="Button" />*/
|
||||
|
||||
|
||||
private Button initButton(String ressource,int x,int y){
|
||||
Button bt = new Button(ressource);
|
||||
private Button initButton(Object obj,int x,int y){
|
||||
String nom = "";
|
||||
EventHandler<ActionEvent> handler;
|
||||
if ( obj instanceof Discipline ){
|
||||
Discipline disciplineActuelle = (Discipline) obj;
|
||||
nom = disciplineActuelle.getNom();
|
||||
handler = event -> {
|
||||
if (Donnees.getDisciplineSelectionee().equals(disciplineActuelle)){
|
||||
Donnees.setDisciplineSelectionee(Discipline.Toutes);
|
||||
}
|
||||
else{
|
||||
Donnees.setDisciplineSelectionee(disciplineActuelle);
|
||||
}
|
||||
};
|
||||
}
|
||||
else{
|
||||
Thematique thematiqueActuelle = (Thematique) obj;
|
||||
handler = event -> {
|
||||
if (Donnees.getThematiqueSelectionee() == null || !(Donnees.getThematiqueSelectionee().equals(obj))){
|
||||
Donnees.setThematiqueSelectionee(thematiqueActuelle);
|
||||
}
|
||||
else{
|
||||
Donnees.setThematiqueSelectionee(null);
|
||||
}
|
||||
};
|
||||
nom = thematiqueActuelle.getNom();
|
||||
}
|
||||
|
||||
Button bt = new Button(nom);
|
||||
bt.setMnemonicParsing(false);
|
||||
bt.setMinSize(235,115);
|
||||
bt.layoutXProperty().setValue(x);
|
||||
bt.layoutYProperty().setValue(y);
|
||||
bt.setId(ressource);
|
||||
bt.setId(nom);
|
||||
bt.prefHeight(115);
|
||||
bt.prefWidth(235);
|
||||
bt.setText(ressource);
|
||||
bt.setText(nom);
|
||||
bt.setBackground(new Background(new BackgroundFill(Color.rgb(255,110,64), new CornerRadii(30), Insets.EMPTY)));
|
||||
bt.setOnAction(handler);
|
||||
return bt;
|
||||
}
|
||||
|
||||
private Void placeButtonRessource(){
|
||||
List<Ressource> ressources = daoRessource.findAll();
|
||||
ressource.setMinHeight(ressources.size()*65);
|
||||
for (int i = 0;i<ressources.size();++i){
|
||||
private Void placeButtonDiscipline(){
|
||||
List<Discipline> disciplines = daoDiscipline.findAll();
|
||||
discipline.setMinHeight(disciplines.size()*65);
|
||||
for (int i = 0;i<disciplines.size();++i){
|
||||
if (i%2 == 0){
|
||||
ressource.getChildren().add(initButton(ressources.get(i).getNomRessource(),38,i/2*130));
|
||||
discipline.getChildren().add(initButton(disciplines.get(i),38,i/2*130));
|
||||
}
|
||||
else {
|
||||
ressource.getChildren().add(initButton(ressources.get(i).getNomRessource(),332,i/2*130));
|
||||
discipline.getChildren().add(initButton(disciplines.get(i),332,i/2*130));
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,10 +123,10 @@ public class Controller implements Initializable {
|
||||
thematique.setMinHeight(thematiques.size()*65);
|
||||
for (int i = 0;i<thematiques.size();++i){
|
||||
if (i%2 == 0){
|
||||
thematique.getChildren().add(initButton(thematiques.get(i).getNom(),38,i/2*130));
|
||||
thematique.getChildren().add(initButton(thematiques.get(i),38,i/2*130));
|
||||
}
|
||||
else {
|
||||
thematique.getChildren().add(initButton(thematiques.get(i).getNom(),332,i/2*130));
|
||||
thematique.getChildren().add(initButton(thematiques.get(i),332,i/2*130));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -108,15 +139,16 @@ public class Controller implements Initializable {
|
||||
|
||||
// init
|
||||
daoFactory = DAOFactoryProducer.getFactory(DAOType.TEST);
|
||||
daoRessource = daoFactory.createDAORessource();
|
||||
daoDiscipline = daoFactory.createDAODiscipline();
|
||||
daoThematique = daoFactory.createDAOThematique();
|
||||
|
||||
// a chaque fois
|
||||
List<Ressource> l = daoRessource.findAll();
|
||||
|
||||
List<Discipline> d = daoDiscipline.findAll();
|
||||
List<Thematique> t = daoThematique.findAll();
|
||||
|
||||
placeButtonThematique();
|
||||
placeButtonRessource();
|
||||
placeButtonDiscipline();
|
||||
// matiere.getChildren().add(initButton(t.get(0).getNom(),38,30));
|
||||
// matiere.getChildren().add(initButton("test",38,160));
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
package fr.univ_amu.iut.fp;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
|
||||
|
||||
public class Main extends Application {
|
||||
|
||||
public static void main(String[] args) {launch(args);}
|
||||
@Override
|
||||
public void start(Stage stage) throws Exception {
|
||||
try {
|
||||
AnchorPane root = FXMLLoader.load(getClass().getResource("/fr/univ_amu/iut/fp/fp.fxml"));
|
||||
stage.setScene(new Scene(root));
|
||||
stage.show();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
<children>
|
||||
<ScrollPane hbarPolicy="NEVER" prefHeight="471.0" prefWidth="347.0" style="-fx-background-color: #f5f0e1;">
|
||||
<content>
|
||||
<AnchorPane id="ressource" fx:id="ressource" minHeight="0.0" minWidth="0.0" prefHeight="442.0" prefWidth="620.0" style="-fx-background-color: #f5f0e1#f5f0e1;">
|
||||
<AnchorPane id="discipline" fx:id="discipline" minHeight="0.0" minWidth="0.0" prefHeight="442.0" prefWidth="620.0" style="-fx-background-color: #f5f0e1#f5f0e1;">
|
||||
<children>
|
||||
|
||||
</children>
|
||||
|
@ -6,18 +6,18 @@ import javafx.scene.*;
|
||||
import javafx.scene.layout.Pane;
|
||||
|
||||
public class ScreenController {
|
||||
private HashMap<String, Pane> screenMap = new HashMap<>();
|
||||
private Scene main;
|
||||
private static HashMap<String, Pane> screenMap = new HashMap<>();
|
||||
private static Scene main;
|
||||
|
||||
public ScreenController(Scene main) {
|
||||
this.main = main;
|
||||
ScreenController.main = main;
|
||||
}
|
||||
|
||||
public void addScreen(String name, Pane pane){
|
||||
screenMap.put(name, pane);
|
||||
public static void addScreen(String name, Pane pane){
|
||||
screenMap.put(name, pane);
|
||||
}
|
||||
|
||||
public void activate(String name){
|
||||
public static void activate(String name){
|
||||
main.setRoot( screenMap.get(name) );
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class DAODisciplineTest implements DAODiscipline {
|
||||
|
||||
@Override
|
||||
public List<Discipline> findAll() {
|
||||
return null;
|
||||
return Discipline.toutes();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,7 +17,7 @@ public class DAOFactoryTest implements DAOFactory {
|
||||
|
||||
@Override
|
||||
public DAODiscipline createDAODiscipline() {
|
||||
return null;
|
||||
return new DAODisciplineTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user