HolarchyWindow.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package ui.view.holarchy;
  2. import javax.swing.JFrame;
  3. import javax.swing.JLabel;
  4. import javax.swing.JPanel;
  5. import javax.swing.JScrollPane;
  6. import javax.swing.JSeparator;
  7. import javax.swing.JSlider;
  8. import javax.swing.JSplitPane;
  9. import javax.swing.SwingConstants;
  10. import javax.swing.event.ChangeEvent;
  11. import javax.swing.event.ChangeListener;
  12. import classes.Holon;
  13. import util.ImageImport;
  14. public class HolarchyWindow extends JFrame {
  15. JFrame parentFrame;
  16. JSeparator sep;
  17. HolarchyPanel holarchyPanel;
  18. HolonInfoPanel infoPanel;
  19. HolarchyTreePanel treePanel;
  20. ui.controller.Control controller;
  21. public boolean isClosed = false;
  22. public HolarchyWindow(JFrame parentFrame, ui.controller.Control controller){
  23. this.controller = controller;
  24. setBounds(0, 0, parentFrame.getWidth()-200, parentFrame.getHeight()-100);
  25. this.setIconImage(ImageImport.loadImage("/Images/Holeg.png", 30, 30));
  26. this.setTitle("Holarchy");
  27. setLocationRelativeTo(parentFrame);
  28. this.setVisible(true);
  29. this.addWindowListener(new java.awt.event.WindowAdapter() {
  30. @Override
  31. public void windowClosing(java.awt.event.WindowEvent windowEvent) {
  32. isClosed = true;
  33. }
  34. });
  35. this.sep = new JSeparator(SwingConstants.HORIZONTAL);
  36. this.sep.setBounds(0, 0, this.getWidth(), 1);
  37. this.add(this.sep);
  38. this.holarchyPanel = new HolarchyPanel(this, controller);
  39. this.holarchyPanel.setBounds(66, 0, this.getWidth()*4/5-66, this.getHeight());
  40. this.infoPanel = new HolonInfoPanel(this, controller);
  41. // this.infoPanel.setBounds(this.getWidth()*4/5+1, 0, this.getWidth()*1/5-1, this.getHeight());
  42. this.treePanel = new HolarchyTreePanel(this, controller);
  43. JSplitPane infoSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, this.infoPanel, new JScrollPane(this.treePanel));
  44. infoSplit.setDividerLocation(this.getHeight()/2);
  45. JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.holarchyPanel, infoSplit);
  46. splitPane.setDividerLocation(this.getWidth()*4/5);
  47. splitPane.setEnabled(false);
  48. this.add(splitPane);
  49. }
  50. public void displayHolonInfos(Holon h) {
  51. if(this.infoPanel == null)
  52. return;
  53. this.infoPanel.displayInfos(h);
  54. }
  55. public void clearInfos() {
  56. if(this.infoPanel == null)
  57. return;
  58. this.infoPanel.clearInfos();
  59. }
  60. }