UIController.java 7.7 KB

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