diff options
Diffstat (limited to 'structure/Graph.java')
| -rw-r--r-- | structure/Graph.java | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/structure/Graph.java b/structure/Graph.java index fd26653..3092a4f 100644 --- a/structure/Graph.java +++ b/structure/Graph.java @@ -43,7 +43,13 @@ public class MyGraph extends SingleGraph{ public void buildEdges(){ - + + /*Iterator<Edge> edges=this.getEdgeIterator(); + while(edges.hasNext()){ + Edge edge=edges.next(); + this.removeEdge(edge); + }*/ + for(Router r : this.grid.getGrid()){ String current=r.name; @@ -54,22 +60,11 @@ public class MyGraph extends SingleGraph{ Iterator<Router> 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);"); - - /* if(g.isEdgeOfLink(bestLink, r, currentRouter)){ - toAdd=graph.addEdge(current+currentRouterName, current, currentRouterName); + Edge toAdd=this.addEdge(current+currentRouterName, current, currentRouterName); toAdd.setAttribute("ui.label", relier.get(currentRouter)); - toAdd.setAttribute("ui.style", "fill-color:red;"); - - }else{*/ - this.addEdge(current+currentRouterName, current, currentRouterName).setAttribute("ui.label", relier.get(currentRouter)); - - //} - - - } catch(Exception e){ // System.out.println("Bug de merde."); @@ -104,5 +99,37 @@ public class MyGraph extends SingleGraph{ } } + public void update(){ + // Reset color + Iterator<Edge> edges=this.getEdgeIterator(); + while(edges.hasNext()){ + Edge edge=edges.next(); + edge.setAttribute("ui.style", "fill-color:black;"); + } + // Update label + edges=this.getEdgeIterator(); + while(edges.hasNext()){ + Edge edge=edges.next(); + for(Router r : this.grid.getGrid()){ + String current=r.name; + + HashMap<Router, Integer> relier=r.getLinks(); + Set<Router> k=relier.keySet(); + Iterator<Router> i=k.iterator(); + while(i.hasNext()){ + Router currentRouter=i.next(); + + String currentRouterName=currentRouter.name; + if(edge.getId().equals(current+currentRouterName)||edge.getId().equals(currentRouterName+current)){ + edge.setAttribute("ui.label", relier.get(currentRouter)); + } + } + } + + } + + //Build bestLink + this.showBestLink(); + } } |
