private void repositionTopology(String containerName) {
Graph<String, String> graph = new SparseMultigraph<String, String>();
metaCache.get(containerName).clear();
metaCache.get(containerName).putAll(stagedNodes);
metaCache.get(containerName).putAll(newNodes);
for (Map<String, Object> on : metaCache.get(containerName).values()) {
graph.addVertex(on.toString());
List<Map<String, Object>> adjacencies = (List<Map<String, Object>>) on.get("adjacencies");
for (Map<String, Object> adj : adjacencies) {
graph.addEdge(
adj.toString(), adj.get("nodeFrom").toString(),
adj.get("nodeTo").toString()
);
}
}
CircleLayout<String, String> layout = new CircleLayout<String, String>(graph);
layout.setSize(new Dimension(1200, 365));
for (Map.Entry<String, Map<String, Object>> v : newNodes.entrySet()) {
Double x = layout.transform(v.getKey()).getX();
Double y = layout.transform(v.getKey()).getY();
Map<String, String> nodeData = (HashMap<String, String>) v.getValue().get("data");
nodeData.put("$x", (x - 600) + "");
nodeData.put("$y", (y - 225) + "");
newNodes.get(v.getKey()).put("data", nodeData);
}
}