Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.75 KB | None | 0 0
  1. //graphicGUI is the ID of AnchorPane in FXML
  2.  
  3. graphicGUI.getChildren().clear();
  4.  
  5. //============= graphicGrid ================
  6.  
  7. graphicGrid = new GridPane();
  8.  
  9. String available;
  10.  
  11. graphicGrid.setPadding(new Insets(2, 2, 2, 2));
  12.  
  13. //Setting the vertical and horizontal gaps between the columns
  14. graphicGrid.setVgap(5);
  15. graphicGrid.setHgap(5);
  16.  
  17. graphicGrid.setAlignment(Pos.CENTER_LEFT);
  18.  
  19. //Set Column Constraints
  20. ColumnConstraints col1 = new ColumnConstraints();
  21. col1.setPercentWidth(14);
  22. ColumnConstraints col2 = new ColumnConstraints();
  23. col2.setPercentWidth(16);
  24. ColumnConstraints col3 = new ColumnConstraints();
  25. col3.setPercentWidth(14);
  26. ColumnConstraints col4 = new ColumnConstraints();
  27. col4.setPercentWidth(14);
  28. ColumnConstraints col5 = new ColumnConstraints();
  29. col5.setPercentWidth(14);
  30. ColumnConstraints col6 = new ColumnConstraints();
  31. col6.setPercentWidth(14);
  32. ColumnConstraints col7 = new ColumnConstraints();
  33. col7.setPercentWidth(14);
  34. graphicGrid.getColumnConstraints().addAll(col1, col2, col3, col4, col5, col6, col7);
  35.  
  36. //Set Row Constraints
  37. int maxRow = 0;
  38. for(int i = 0; i < 7; i++) {
  39. if (airport.getParking().get(i + 1) != null) {
  40. if( airport.getParking().get(i+1).size() > maxRow){
  41. maxRow = airport.getParking().get(i+1).size();
  42. }
  43. }
  44. }
  45.  
  46. for(int i = 0; i <= maxRow; i++){
  47. RowConstraints r = new RowConstraints();
  48. r.setPercentHeight(graphicGUI.getHeight() / maxRow);
  49. graphicGrid.getRowConstraints().add(r);
  50.  
  51. }
  52.  
  53. //Set 1st Line with the names of parking categories
  54. Label label = new Label("Gate");
  55. label.setStyle("-fx-font-weight: bold;");
  56. graphicGrid.add(label, 0, 0);
  57. GridPane.setHalignment(label, HPos.CENTER);
  58.  
  59. label = new Label("PassGate");
  60. label.setStyle("-fx-font-weight: bold;");
  61. graphicGrid.add(label, 1, 0);
  62. GridPane.setHalignment(label, HPos.CENTER);
  63.  
  64. label = new Label("Zone A");
  65. label.setStyle("-fx-font-weight: bold;");
  66. graphicGrid.add(label, 2, 0);
  67. GridPane.setHalignment(label, HPos.CENTER);
  68.  
  69. label = new Label("Zone B");
  70. label.setStyle("-fx-font-weight: bold;");
  71. graphicGrid.add(label, 3, 0);
  72. GridPane.setHalignment(label, HPos.CENTER);
  73.  
  74. label = new Label("Zone C");
  75. label.setStyle("-fx-font-weight: bold;");
  76. graphicGrid.add(label, 4, 0);
  77. GridPane.setHalignment(label, HPos.CENTER);
  78.  
  79. label = new Label("General");
  80. label.setStyle("-fx-font-weight: bold;");
  81. graphicGrid.add(label, 5, 0);
  82. GridPane.setHalignment(label, HPos.CENTER);
  83.  
  84. label = new Label("Long");
  85. label.setStyle("-fx-font-weight: bold;");
  86. graphicGrid.add(label, 6, 0);
  87. GridPane.setHalignment(label, HPos.CENTER);
  88.  
  89. for(int i = 0; i < 7; i++) {
  90.  
  91. if( airport.getParking().get(i+1) != null){
  92.  
  93. int row = airport.getParking().get(i+1).size();
  94. for (int j = 1; j <= row; j++) {
  95.  
  96. if(airport.getParking().get(i + 1).get(j - 1).getStatus().equals("parked")){
  97. available = "-fx-background-color: red";
  98. }
  99. else{
  100. available = "-fx-background-color: green";
  101. }
  102.  
  103. VBox vbox = new VBox();
  104. vbox.setStyle(available);
  105. vbox.setAlignment(Pos.CENTER);
  106.  
  107.  
  108. Text text = new Text(" " + airport.getParking().get(i+1).get(j-1).getParkingSeatID()+ " ");
  109.  
  110. vbox.getChildren().add(text);
  111.  
  112. graphicGrid.add(vbox, i, j); // (child, columnIndex, rowIndex)
  113.  
  114.  
  115. }
  116.  
  117. }
  118.  
  119. }
  120.  
  121. graphicGrid.setMinWidth(480);
  122. graphicGrid.setMaxWidth(480);
  123. graphicGrid.setMinHeight(286);
  124. graphicGrid.setMaxHeight(286);
  125.  
  126.  
  127. graphicGUI.getChildren().add(graphicGrid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement