package ui.view.holarchy; import java.awt.Color; import java.awt.Dimension; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import javax.swing.JLabel; import javax.swing.JPanel; import classes.Holon; import ui.controller.Control; public class HolonInfoPanel extends JPanel { Control control; int offset, offsetLabels = 110; HolarchyWindow parentFrame; Holon h = null; JPanel[] panels = { new JPanel(), new JPanel(), new JPanel()}; JLabel[] labels1 = {new JLabel("Name: "), new JLabel("UUID: "), new JLabel("State: "), new JLabel("Optimization Scheme: "), new JLabel("Parent: ")}; String[] labels2 = {"Subholons", "Virtual neighbors", "Physical neighbors"}; Set toRemove = new HashSet(); public HolonInfoPanel(HolarchyWindow parentFrame, Control control) { this.control = control; this.parentFrame = parentFrame; this.setBounds(0, 0, parentFrame.getWidth()*1/5-21, (parentFrame.getHeight()-100)/2); this.setPreferredSize(new Dimension(parentFrame.getWidth()*1/5-21, parentFrame.getHeight()/2-20)); this.offset = parentFrame.getWidth()*4/5+1; this.setLayout(null); this.setVisible(true); this.setBackground(Color.white); for(int i=0; i holons = h.holonControlUnit.getHierarchyController().getVirtualNeighbors(); for(String s : holons) { Holon c = this.control.getModel().getHolonsByID().get(s); JLabel l = new JLabel(c.name+" "+c.getUniqueID()); l.setBounds(5, offset, this.getWidth(), 20); this.add(l); this.toRemove.add(l); offset += 21; } //display physical neighbors this.panels[2].setLocation(5, offset); offset += 21; holons = h.holonControlUnit.getHierarchyController().getPhysicalNeighbors(); for(String s : holons) { JLabel l; if(s.contains("Switch") || s.contains("Node")) { l = new JLabel(s); } else { Holon c = this.control.getModel().getHolonsByID().get(s); l = new JLabel(c.name+" "+c.getUniqueID()); } l.setBounds(5, offset, this.getWidth(), 20); this.add(l); this.toRemove.add(l); offset += 21; } this.setPreferredSize(new Dimension(this.getWidth()*1/5-1, offset+21)); } public void clearInfos() { this.labels1[0].setText("Name: "); this.labels1[1].setText("UUID: "); this.labels1[2].setText("State: "); this.labels1[3].setText("Optimization scheme: "); this.labels1[4].setText("Parent holon: "); for(JLabel l : this.toRemove) { this.remove(l); } for(int i=0; i