UIController.java 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. package ui;
  2. import javafx.fxml.FXML;
  3. import javafx.fxml.FXMLLoader;
  4. import javafx.scene.Parent;
  5. import javafx.scene.Scene;
  6. import javafx.scene.control.Label;
  7. import javafx.scene.image.Image;
  8. import javafx.scene.image.ImageView;
  9. import javafx.stage.Stage;
  10. import java.io.IOException;
  11. public class UIController {
  12. private Parent root;
  13. private Stage stage;
  14. public UIController() {
  15. try {
  16. root = FXMLLoader.load(getClass().getResource("InformationWindow.fxml"));
  17. stage = new Stage();
  18. stage.setResizable(false);
  19. stage.setScene(new Scene(root, 450, 450));
  20. }
  21. catch (IOException e) {
  22. e.printStackTrace();
  23. }
  24. }
  25. private void setLegend() {
  26. Image imgBlue = new Image(getClass().getResource("/pictures/lightBlue.PNG").toString()); //Was blue
  27. ImageView imgViewBlue = new ImageView(imgBlue);
  28. imgViewBlue.setFitWidth(20);
  29. imgViewBlue.setFitHeight(20);
  30. ((Label) root.lookup("#blueText")).setGraphic(imgViewBlue);
  31. Image imgRed = new Image(getClass().getResource("/pictures/red.PNG").toString());
  32. ImageView imgViewRed = new ImageView(imgRed);
  33. imgViewRed.setFitWidth(20);
  34. imgViewRed.setFitHeight(20);
  35. ((Label) root.lookup("#redText")).setGraphic(imgViewRed);
  36. Image imgGreen = new Image(getClass().getResource("/pictures/gray.PNG").toString()); //was green
  37. ImageView imgViewGreen = new ImageView(imgGreen);
  38. imgViewGreen.setFitWidth(20);
  39. imgViewGreen.setFitHeight(20);
  40. ((Label) root.lookup("#greenText")).setGraphic(imgViewGreen);
  41. Image imgIce = new Image(getClass().getResource("/pictures/cyan.PNG").toString()); //delete?
  42. ImageView imgViewIce = new ImageView(imgIce);
  43. imgViewIce.setFitWidth(20);
  44. imgViewIce.setFitHeight(20);
  45. ((Label) root.lookup("#iceText")).setGraphic(imgViewIce);
  46. }
  47. @FXML
  48. protected void openSettings() {
  49. Parent root;
  50. try {
  51. root = FXMLLoader.load(getClass().getResource("SettingsWindow.fxml"));
  52. Stage stage = new Stage();
  53. stage.setResizable(false);
  54. stage.setTitle("Settings");
  55. stage.setScene(new Scene(root, 450, 450));
  56. stage.show();
  57. stage.toFront();
  58. SettingsWindow.getWindow().setUpListener();
  59. SettingsWindow.getWindow().setStage(stage);
  60. }
  61. catch (IOException e) {
  62. e.printStackTrace();
  63. }
  64. }
  65. @FXML
  66. protected void openAccelInfo() {
  67. stage.setTitle("Acceleration Information");
  68. stage.show();
  69. stage.setWidth(800);
  70. stage.setHeight(300);
  71. stage.toFront();
  72. setLegend();
  73. ImageView img = ((ImageView) root.lookup("#image"));
  74. img.setImage(new Image(getClass().getResource("/pictures/simpleAcceleration.png").toString()));
  75. img.setFitWidth(480);
  76. img.setFitHeight(350);
  77. ((Label) root.lookup("#text1")).setText("This object changes its state when a specific acceleration is reached.\n" +
  78. "The specific acceleration is dependend on the wall height between the two chambers. " +
  79. "The acceleration can be either in the opposite direction of the small chamber or breaking after accelerating in the same direction as the small chamber.\n" +
  80. "Tab water needs to be filled into the right chamber. " +
  81. "When accelerating the object the water will swap over the wall into the small chamber where it can be detected.");
  82. }
  83. @FXML
  84. protected void openWeightInfo() {
  85. stage.setTitle("Load Information");
  86. stage.show();
  87. stage.setWidth(800);
  88. stage.setHeight(300);
  89. stage.toFront();
  90. setLegend();
  91. ImageView img = ((ImageView) root.lookup("#image"));
  92. img.setImage(new Image(getClass().getResource("/pictures/simpleWeight.png").toString()));
  93. img.setFitWidth(480);
  94. img.setFitHeight(350);
  95. ((Label) root.lookup("#text1")).setText("This object changes its state when a specific load lays on it." +
  96. "\nThe specific load is dependend on the number of supports between the panels." +
  97. " When enough weight lays on this object the supports will bend, leading to less space between the panels.");
  98. }
  99. @FXML
  100. protected void openTemperatureUpInfo() {
  101. stage.setTitle("Rising Temperature Information");
  102. stage.show();
  103. stage.setWidth(800);
  104. stage.setHeight(300);
  105. stage.toFront();
  106. setLegend();
  107. ImageView img = ((ImageView) root.lookup("#image"));
  108. img.setImage(new Image(getClass().getResource("/pictures/simpleTemperatureMelt.png").toString()));
  109. img.setFitWidth(480);
  110. img.setFitHeight(350);
  111. ((Label) root.lookup("#text1")).setText("This object changes its state when it is stored above 0°C for some minutes." +
  112. "\nTab water or ice is used for this object. You have to freeze this object to make it work." +
  113. " When stored above 0°C the ice starts to melt and reaches the other chamber where it can be detected. Otherwise it will stay in the first chamber." +
  114. " When checking for this object's state, the object will be fliped and warmed up for 30 minutes.");
  115. }
  116. @FXML
  117. protected void openTemperatureDownInfo() {
  118. stage.setTitle("Falling Temperature Information");
  119. stage.show();
  120. stage.setWidth(800);
  121. stage.setHeight(300);
  122. stage.toFront();
  123. setLegend();
  124. ImageView img = ((ImageView) root.lookup("#image"));
  125. img.setImage(new Image(getClass().getResource("/pictures/simpleTemperatureFreeze.png").toString()));
  126. img.setFitWidth(480);
  127. img.setFitHeight(350);
  128. ((Label) root.lookup("#text1")).setText("This object changes its state when it is stored under 0°C for a while." +
  129. "\nTab water is filled into the right chamber" +
  130. " When stored under 0°C the water will freeze and the resulting ice will break the conductive wall." +
  131. " After melting, water will flow through the crack." +
  132. " When checking for this object's state, the object has to be placed on a touchscreen after letting it warm up for at least 30 minutes.");
  133. }
  134. @FXML
  135. protected void openTiltInfo() {
  136. stage.setTitle("Rotate by 90° Information");
  137. stage.show();
  138. stage.setWidth(800);
  139. stage.setHeight(350);
  140. stage.toFront();
  141. setLegend();
  142. ImageView img = ((ImageView) root.lookup("#image"));
  143. img.setImage(new Image(getClass().getResource("/pictures/simpleTilt.png").toString()));
  144. img.setFitWidth(480);
  145. img.setFitHeight(350);
  146. ((Label) root.lookup("#text1")).setText("This object changes its state when it gets tilted by around 90° in the right direction." +
  147. "\nWhen tilted the water flows into the next chamber where it can be detected.");
  148. }
  149. @FXML
  150. protected void openFlipInfo() {
  151. stage.setTitle("Flip Over by 180° Information");
  152. stage.show();
  153. stage.setWidth(800);
  154. stage.setHeight(380);
  155. stage.toFront();
  156. setLegend();
  157. ImageView img = ((ImageView) root.lookup("#image"));
  158. img.setImage(new Image(getClass().getResource("/pictures/simpleFlip.png").toString()));
  159. img.setFitWidth(480);
  160. img.setFitHeight(350);
  161. ((Label) root.lookup("#text1")).setText("This object changes its state when it gets fliped (rotated by around 180°)." +
  162. "\nThe water in the middle chamber will then flow into the outer chamber where it can be detected.");
  163. }
  164. @FXML
  165. protected void openSqueezeInfo() {
  166. stage.setTitle("Pressure Information");
  167. stage.show();
  168. stage.setWidth(800);
  169. stage.setHeight(350);
  170. stage.toFront();
  171. setLegend();
  172. ImageView img = ((ImageView) root.lookup("#image"));
  173. img.setImage(new Image(getClass().getResource("/pictures/simpleSqueeze.png").toString()));
  174. img.setFitWidth(480);
  175. img.setFitHeight(350);
  176. ((Label) root.lookup("#text1")).setText("This object changes its state when the lower half gets squeezed." +
  177. "\nThe lower chamber has to be filled with tab water." +
  178. " The water will then be pressed from the lower chamber onto the cone where it then can be detected.");
  179. }
  180. }