Browse Source

Updated graph to apply force to shake out graph after all nodes have been added.

pull/8/head
Jeffery Russell 6 years ago
parent
commit
70a86a8185
2 changed files with 24 additions and 2 deletions
  1. +13
    -2
      src/main/java/net/jrtechs/www/server/Client.java
  2. +11
    -0
      website/graph.html

+ 13
- 2
src/main/java/net/jrtechs/www/server/Client.java View File

@ -97,6 +97,17 @@ public class Client extends Thread
this.sendJSON(request); this.sendJSON(request);
} }
/**
* Tells the tells the js on the client side to start
* the force applied to the graph
*/
private void sendFinished()
{
JSONObject request = new JSONObject();
request.put("action", 3);
this.sendJSON(request);
}
/** /**
* sends a json object to the client * sends a json object to the client
@ -180,7 +191,6 @@ public class Client extends Thread
currentStep += radianStep; currentStep += radianStep;
} }
this.client.close();
} }
@ -210,7 +220,6 @@ public class Client extends Thread
} }
} }
} }
this.client.close();
} }
@ -228,5 +237,7 @@ public class Client extends Thread
{ {
friendsWithFriends(); friendsWithFriends();
} }
this.sendFinished();
this.client.close();
} }
} }

+ 11
- 0
website/graph.html View File

@ -107,6 +107,7 @@
.muted { .muted {
fill-opacity: 0.1; fill-opacity: 0.1;
stroke-opacity: 0.1; stroke-opacity: 0.1;
font-size: 0;
} }
</style> </style>
<div id="graph-container" style="width:100%; height:100%"></div> <div id="graph-container" style="width:100%; height:100%"></div>
@ -225,12 +226,22 @@
{ {
addEdgeToGraph(request); addEdgeToGraph(request);
} }
else if(request.action == 3)
{
s.startForceAtlas2({worker: true, barnesHutOptimize: false, scalingRatio: 0.5, slowDown: 5, gravity: 20});
setTimeout(function ()
{
s.stopForceAtlas2();
}, 30000);
}
}; };
//jquery stuff for hiding and displaying users when clicked //jquery stuff for hiding and displaying users when clicked
s.bind('clickNode doubleClickNode rightClickNode', function(e) s.bind('clickNode doubleClickNode rightClickNode', function(e)
{ {

Loading…
Cancel
Save