aboutsummaryrefslogtreecommitdiff
path: root/structure/Graph.java
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-21 18:02:31 +0100
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-21 18:02:31 +0100
commit0e1704bbcb3279e4779f09c06127a7c76cc8fb04 (patch)
treef84e7d18e76df053c9bcb194da163f278873eada /structure/Graph.java
parentf453154938a0e1a3ba387ff1d7c0630e54b23855 (diff)
Add live
Diffstat (limited to 'structure/Graph.java')
-rw-r--r--structure/Graph.java55
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();
+ }
}