HolarchyWindow.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package ui.view.holarchy;
  2. import javax.swing.JFrame;
  3. import javax.swing.JScrollPane;
  4. import javax.swing.JSeparator;
  5. import javax.swing.JSplitPane;
  6. import javax.swing.SwingConstants;
  7. import classes.Holon;
  8. import util.ImageImport;
  9. public class HolarchyWindow extends JFrame {
  10. JFrame parentFrame;
  11. JSeparator sep;
  12. HolarchyPanel holarchyPanel;
  13. HolonInfoPanel infoPanel;
  14. HolarchyTreePanel treePanel;
  15. ui.controller.Control controller;
  16. public boolean isClosed = false;
  17. JScrollPane scrollPane;
  18. public HolarchyWindow(JFrame parentFrame, ui.controller.Control controller){
  19. this.controller = controller;
  20. setBounds(0, 0, parentFrame.getWidth()-200, parentFrame.getHeight()-100);
  21. this.setIconImage(ImageImport.loadImage("/Images/Holeg.png", 30, 30));
  22. this.setTitle("Holarchy");
  23. setLocationRelativeTo(parentFrame);
  24. this.setVisible(true);
  25. this.addWindowListener(new java.awt.event.WindowAdapter() {
  26. @Override
  27. public void windowClosing(java.awt.event.WindowEvent windowEvent) {
  28. isClosed = true;
  29. }
  30. });
  31. this.sep = new JSeparator(SwingConstants.HORIZONTAL);
  32. this.sep.setBounds(0, 0, this.getWidth(), 1);
  33. this.add(this.sep);
  34. this.holarchyPanel = new HolarchyPanel(this, controller);
  35. this.holarchyPanel.setBounds(66, 0, this.getWidth()*4/5-66, this.getHeight());
  36. this.infoPanel = new HolonInfoPanel(this, controller);
  37. // this.infoPanel.setBounds(this.getWidth()*4/5+1, 0, this.getWidth()*1/5-1, this.getHeight());
  38. this.treePanel = new HolarchyTreePanel(this, controller);
  39. scrollPane = new JScrollPane(this.infoPanel);
  40. scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
  41. scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  42. JSplitPane infoSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPane, new JScrollPane(this.treePanel));
  43. infoSplit.setDividerLocation(this.getHeight()/2);
  44. infoSplit.setEnabled(false);
  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. public void update() {
  61. if(this.holarchyPanel != null)
  62. this.holarchyPanel.update();
  63. if(this.infoPanel != null)
  64. this.infoPanel.update();
  65. if(this.treePanel != null)
  66. this.treePanel.update();
  67. }
  68. }