From 70a86a818529cf5adf3980e3b450351ef15f7ab2 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Sun, 3 Jun 2018 18:24:06 -0400 Subject: [PATCH] Updated graph to apply force to shake out graph after all nodes have been added. --- src/main/java/net/jrtechs/www/server/Client.java | 15 +++++++++++++-- website/graph.html | 11 +++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/jrtechs/www/server/Client.java b/src/main/java/net/jrtechs/www/server/Client.java index 7c8cea5..95f1464 100644 --- a/src/main/java/net/jrtechs/www/server/Client.java +++ b/src/main/java/net/jrtechs/www/server/Client.java @@ -97,6 +97,17 @@ public class Client extends Thread 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 @@ -180,7 +191,6 @@ public class Client extends Thread 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(); } + this.sendFinished(); + this.client.close(); } } \ No newline at end of file diff --git a/website/graph.html b/website/graph.html index 0f2baa9..48f00b5 100644 --- a/website/graph.html +++ b/website/graph.html @@ -107,6 +107,7 @@ .muted { fill-opacity: 0.1; stroke-opacity: 0.1; + font-size: 0; }
@@ -225,12 +226,22 @@ { 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 s.bind('clickNode doubleClickNode rightClickNode', function(e) {