UIController.java 7.5 KB

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