DisplayedInformationPopUp.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package ui.view;
  2. import java.awt.BorderLayout;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import javax.swing.JButton;
  6. import javax.swing.JCheckBox;
  7. import javax.swing.JDialog;
  8. import javax.swing.JPanel;
  9. import javax.swing.border.EmptyBorder;
  10. import ui.controller.Control;
  11. /**
  12. * This Class represents a Popup to edit the shown Information.
  13. *
  14. * @author Gruppe14
  15. */
  16. public class DisplayedInformationPopUp extends JDialog {
  17. private static final long serialVersionUID = 1L;
  18. private final JPanel contentPanel = new JPanel();
  19. private final JButton btnOk = new JButton("OK");
  20. private MyCanvas canvas;
  21. private Control controller;
  22. private JCheckBox objectEnergyCheckbox;
  23. private JCheckBox connectionCheckbox;
  24. private JCheckBox colorizedBorderCheckbox;
  25. private JCheckBox nodeOfnodeConnectionCheckbox;
  26. private JPanel toUpdate;
  27. /**
  28. * Constructor.
  29. *
  30. * @param canvas
  31. * the Canvas
  32. */
  33. public DisplayedInformationPopUp(MyCanvas canvas, JPanel update, Control cont) {
  34. super((java.awt.Frame) null, true);
  35. setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
  36. this.setTitle("Edit Displayed Informations");
  37. setBounds(100, 100, 400, 276);
  38. setLocationRelativeTo(this.getParent());
  39. getContentPane().setLayout(new BorderLayout());
  40. contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
  41. getContentPane().add(contentPanel, BorderLayout.CENTER);
  42. contentPanel.setLayout(null);
  43. this.canvas = canvas;
  44. this.toUpdate = update;
  45. controller = cont;
  46. objectEnergyCheckbox = new JCheckBox("Display Total Energy of Objects");
  47. objectEnergyCheckbox.setBounds(19, 19, 300, 23);
  48. contentPanel.add(objectEnergyCheckbox);
  49. connectionCheckbox = new JCheckBox("Display Connection Properties");
  50. connectionCheckbox.setBounds(19, 57, 300, 23);
  51. contentPanel.add(connectionCheckbox);
  52. objectEnergyCheckbox.setSelected(canvas.getShowedInformation()[1]);
  53. connectionCheckbox.setSelected(canvas.getShowedInformation()[0]);
  54. btnOk.addActionListener(new ActionListener() {
  55. public void actionPerformed(ActionEvent arg0) {
  56. setInformation(connectionCheckbox.isSelected(), objectEnergyCheckbox.isSelected(),
  57. colorizedBorderCheckbox.isSelected(), nodeOfnodeConnectionCheckbox.isSelected());
  58. controller.getSimManager().getFlexiblePane().recalculate();
  59. dispose();
  60. }
  61. });
  62. btnOk.setBounds(174, 193, 82, 23);
  63. contentPanel.add(btnOk);
  64. JButton btnCancel = new JButton(Languages.getLanguage()[34]);
  65. btnCancel.setActionCommand(Languages.getLanguage()[34]);
  66. btnCancel.addActionListener(new ActionListener() {
  67. public void actionPerformed(ActionEvent arg0) {
  68. dispose();
  69. }
  70. });
  71. btnCancel.setBounds(69, 193, 89, 23);
  72. contentPanel.add(btnCancel);
  73. colorizedBorderCheckbox = new JCheckBox("Display colorized Border for Objects");
  74. colorizedBorderCheckbox.setBounds(19, 96, 369, 23);
  75. contentPanel.add(colorizedBorderCheckbox);
  76. colorizedBorderCheckbox.setSelected(canvas.getShowedInformation()[3]);
  77. nodeOfnodeConnectionCheckbox = new JCheckBox("Display outside Connections in gouped Nodes");
  78. nodeOfnodeConnectionCheckbox.setBounds(19, 133, 369, 23);
  79. contentPanel.add(nodeOfnodeConnectionCheckbox);
  80. nodeOfnodeConnectionCheckbox.setSelected(canvas.getShowedInformation()[4]);
  81. }
  82. /**
  83. * Set the Information true or false.
  84. *
  85. * @param connection
  86. * conection Information
  87. * @param object
  88. * Object Information
  89. * @param nodeOfnode
  90. */
  91. private void setInformation(boolean connection, boolean object, boolean borders, boolean nodeOfnode) {
  92. canvas.setShowedInformation(connection, object, borders, nodeOfnode);
  93. canvas.repaint();
  94. toUpdate.updateUI();
  95. }
  96. }