ShowedInformationPopUp.java 3.0 KB

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