1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
public class ContactView extends JFrame {
private Graph effectiveGraph;
private Graph authGraph;
private Collection<String> allVertices;
private Collection<String> allEdges;
private JFrame jf;
DAGLayout<String,String> layoutEffectiveGraphe;
CircleLayout<String,String> layoutAuthGraph;
BasicVisualizationServer<String,String> effectiveVv;
BasicVisualizationServer<String,String> authVv;
JPanel authPanel;
JPanel effectivePanel;
JTabbedPane mainPanel;
public ContactView(String title, String agentPath, String resPath){
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { end(); }
});
effectiveGraph = new DirectedSparseGraph<String,String>();
authGraph = new DirectedSparseGraph<String,String>();
layoutEffectiveGraphe = new DAGLayout(effectiveGraph);
layoutEffectiveGraphe.setSize(new Dimension(500,500));
layoutAuthGraph = new CircleLayout(authGraph);
layoutAuthGraph.setSize(new Dimension(500,500));
authGraph.addVertex("contact1");
authGraph.addVertex("contact2");
authGraph.addVertex("contact3");
authGraph.addVertex("contact4");
authGraph.addEdge("lien1", "contact1", "contact2");
authGraph.addEdge("lien2", "contact2", "contact4");
authGraph.addEdge("lien3", "contact1", "contact4");
authGraph.addEdge("lien4", "contact1", "contact3");
authGraph.addEdge("lien5", "contact3", "contact1");
effectiveVv = new BasicVisualizationServer(layoutEffectiveGraphe);
effectiveVv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
effectiveVv.setBackground(Color.WHITE);
authVv = new BasicVisualizationServer(layoutAuthGraph);
authVv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
authVv.setBackground(Color.WHITE);
/*Initialisation GUI*/
jf = new JFrame(title);
jf.setSize(800, 600);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainPanel = new JTabbedPane();
authPanel = new JPanel();
effectivePanel = new JPanel();
effectivePanel.setBackground(Color.WHITE);
effectivePanel.add(effectiveVv);
authPanel.setBackground(Color.WHITE);
authPanel.add(authVv);
mainPanel.addTab("Authorized contacts", authPanel);
mainPanel.addTab("Effective contacts", effectivePanel);
jf.getContentPane().add(mainPanel);
jf.setVisible(true);
}
} |
Partager