1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| public class FXMLPlateauController implements Initializable {
/**
* Initializes the controller class.
*/
@FXML
private GridPane gridPane;
private MapProperty<Point,Case> map;
private Graphe g;
private Jeux jeux;
private ObjectProperty<GridPane> selectedRegion = new SimpleObjectProperty<>();
@Override
public void initialize(URL url, ResourceBundle rb) {
jeux= Jeux.getInstance();
g= jeux.getG();
for(int i =0 ;i<gridPane.getColumnConstraints().size();i++){
for(int j = 0 ;j<gridPane.getRowConstraints().size();j++){
addCase(i, j);
}
}
}
private void addCase(int colIndex, int rowIndex) {
CaseGraphique caseGraphique = new CaseGraphique("region");
caseGraphique.setOnMouseClicked(e -> {
if (e.isPopupTrigger()) {
System.out.println("Click droit");
System.out.printf("Mouse enetered cell [%d, %d]%n", colIndex, rowIndex);
caseGraphique.setSkinCase("regionIa");
}
else {
System.out.println("click gauche");
System.out.printf("Mouse enetered cell [%d, %d]%n", colIndex, rowIndex);
caseGraphique.setSkinCase("regionMurh");
}
});
gridPane.add(caseGraphique, colIndex, adaptationDonneesGridPaneAvecGraphe(rowIndex));
}
public int adaptationDonneesGridPaneAvecGraphe(int y){
int resultat = 0;
switch (y) {
case 0:
return resultat=8;
case 1:
return resultat=7;
case 2:
return resultat=6;
case 3:
return resultat=5;
case 4:
return resultat=4;
case 5:
return resultat=3;
case 6:
return resultat=2;
case 7:
return resultat=1;
case 8:
return resultat=0;
default:
break;
}
return resultat;
}
} |
Partager