ShowedInformationPopUp.java 3.4 KB

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