package main; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Set; import org.graphstream.graph.Graph; import org.graphstream.graph.implementations.SingleGraph; import structure.Grid; import structure.Router; public class Main { public static void main(String[] args) { Grid g=new Grid(); System.setProperty("gs.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); Graph graph = new SingleGraph("Tutorial 1"); graph.addAttribute("ui.stylesheet", "url('resources/style.css')"); ArrayList grid=g.getGrid(); for(Router r : grid){ graph.addNode(r.name); } for(Router r : grid){ String current=r.name; HashMap relier=r.getLinks(); Set k=relier.keySet(); Iterator i=k.iterator(); while(i.hasNext()){ Router currentRouter=i.next(); String currentRouterName=currentRouter.name; try{ //graph.addEdge(current+currentRouter, current, currentRouter).addAttribute("ui.style", "fill-color: rgb(0,100,255);"); graph.addEdge(current+currentRouterName, current, currentRouterName).setAttribute("ui.label", relier.get(currentRouter)); } catch(Exception e){ // System.out.println("Bug de merde."); } } } graph.display(); } }