private static void applySavedLocations(Map<VertexRef, Point> locations, Layout layout) { for(VertexRef ref : locations.keySet()) { layout.setLocation(ref, locations.get(ref)); } }
private static void applySavedLocations(Map<VertexRef, Point> locations, Layout layout) { for(VertexRef ref : locations.keySet()) { layout.setLocation(ref, locations.get(ref)); } }
private static void applySavedLocations(Map<VertexRef, Point> locations, Layout layout) { for(VertexRef ref : locations.keySet()) { layout.setLocation(ref, locations.get(ref)); } }
private void applyLayoutPositions(final Collection<? extends Vertex> vertices, final HierarchyLayout<VertexRef, Edge> layout, final Layout graphLayout) { final List<VertexRef> displayVertices = vertices.stream() .map(v -> (VertexRef)v) .collect(Collectors.toList()); layout.horizontalSqueeze(displayVertices); for(VertexRef v : displayVertices) { Point2D p = layout.transform(v); graphLayout.setLocation(v, new Point(p.getX(), p.getY())); } }
private void applyLayoutPositions(final Collection<? extends Vertex> vertices, final HierarchyLayout<VertexRef, Edge> layout, final Layout graphLayout) { final List<VertexRef> displayVertices = vertices.stream() .map(v -> (VertexRef)v) .collect(Collectors.toList()); layout.horizontalSqueeze(displayVertices); for(VertexRef v : displayVertices) { Point2D p = layout.transform(v); graphLayout.setLocation(v, new Point(p.getX(), p.getY())); } }
@Override public void updateLayout(Graph graph) { Layout layout = graph.getLayout(); int r = 100; int cx = 500; int cy = 500; int i = 0; for(Vertex vertex : graph.getDisplayVertices()) { s_log.debug("Laying out vertex id : {}", vertex); if(i == 0) { layout.setLocation(vertex, new Point(cx, cy)); } else { int n = i - 1; double a = (2*Math.PI)/(graph.getDisplayVertices().size() -1); int x = (int) (r * Math.cos(n*a) + cx); int y = (int) (r * Math.sin(n*a) + cy); layout.setLocation(vertex, new Point(x, y)); } i++; } }
private void updateVertex(String vertexUpdate) { String[] vertexProps = vertexUpdate.split("\\|"); String id = vertexProps[0].split(",")[1]; int x = (int) Double.parseDouble(vertexProps[1].split(",")[1]); int y = (int) Double.parseDouble(vertexProps[2].split(",")[1]); boolean selected = vertexProps[3].split(",")[1].equals("true"); Vertex vertex = getGraph().getVertexByKey(id); getGraph().getLayout().setLocation(vertex, new Point(x, y)); if (selected) { m_graphContainer.getSelectionManager().selectVertexRefs(Collections.singleton(vertex)); } else { m_graphContainer.getSelectionManager().deselectVertexRefs(Collections.singleton(vertex)); } }
@Override public void updateLayout(Graph graph) { Layout layout = graph.getLayout(); int r = 100; int cx = 500; int cy = 500; int i = 0; for(Vertex vertex : graph.getDisplayVertices()) { s_log.debug("Laying out vertex id : {}", vertex); if(i == 0) { layout.setLocation(vertex, new Point(cx, cy)); } else { int n = i - 1; double a = (2*Math.PI)/(graph.getDisplayVertices().size() -1); int x = (int) (r * Math.cos(n*a) + cx); int y = (int) (r * Math.sin(n*a) + cy); layout.setLocation(vertex, new Point(x, y)); } i++; } }
private void updateVertex(String vertexUpdate) { String[] vertexProps = vertexUpdate.split("\\|"); String id = vertexProps[0].split(",")[1]; int x = (int) Double.parseDouble(vertexProps[1].split(",")[1]); int y = (int) Double.parseDouble(vertexProps[2].split(",")[1]); boolean selected = vertexProps[3].split(",")[1].equals("true"); Vertex vertex = getGraph().getVertexByKey(id); getGraph().getLayout().setLocation(vertex, new Point(x, y)); if (selected) { m_graphContainer.getSelectionManager().selectVertexRefs(Collections.singleton(vertex)); } else { m_graphContainer.getSelectionManager().deselectVertexRefs(Collections.singleton(vertex)); } }
private static void doFRLayout(final Layout graphLayout, SparseGraph<VertexRef, EdgeRef> jungGraph, Dimension size, final int xOffset, final int yOffset) { FRLayout<VertexRef, EdgeRef> layout = new FRLayout<VertexRef, EdgeRef>(jungGraph); layout.setInitializer(initializer(graphLayout, xOffset, yOffset)); layout.setSize(size); while(!layout.done()) { layout.step(); } for(VertexRef v : jungGraph.getVertices()) { graphLayout.setLocation(v, new Point(layout.getX(v)+xOffset, layout.getY(v)+yOffset)); } }
private static void doFRLayout(final Layout graphLayout, SparseGraph<VertexRef, EdgeRef> jungGraph, Dimension size, final int xOffset, final int yOffset) { FRLayout<VertexRef, EdgeRef> layout = new FRLayout<VertexRef, EdgeRef>(jungGraph); layout.setInitializer(initializer(graphLayout, xOffset, yOffset)); layout.setSize(size); while(!layout.done()) { layout.step(); } for(VertexRef v : jungGraph.getVertices()) { graphLayout.setLocation(v, new Point(layout.getX(v)+xOffset, layout.getY(v)+yOffset)); } }
private static void doISOMLayout(final Layout graphLayout, SparseGraph<VertexRef, EdgeRef> jungGraph, Dimension size) { NonStupidISOMLayout layout = new NonStupidISOMLayout(jungGraph, graphLayout); layout.setInitializer(initializer(graphLayout)); layout.setSize(size); while(!layout.done()) { layout.step(); } for(VertexRef v : jungGraph.getVertices()) { graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v))); } } }
@Override public void updateLayout(final Graph graph) { final Layout graphLayout = graph.getLayout(); SparseGraph<VertexRef, EdgeRef> jungGraph = new SparseGraph<VertexRef, EdgeRef>(); Collection<Vertex> vertices = graph.getDisplayVertices(); for(Vertex v : vertices) { jungGraph.addVertex(v); } Collection<Edge> edges = graph.getDisplayEdges(); for(Edge e : edges) { jungGraph.addEdge(e, e.getSource().getVertex(), e.getTarget().getVertex()); } FRLayout<VertexRef, EdgeRef> layout = new FRLayout<VertexRef, EdgeRef>(jungGraph); // Initialize the vertex positions to the last known positions from the layout Dimension size = selectLayoutSize(graph); layout.setInitializer(initializer(graphLayout, (int)size.getWidth()/2, (int)size.getHeight()/2)); // Resize the graph to accommodate the number of vertices layout.setSize(size); while(!layout.done()) { layout.step(); } // Store the new positions in the layout for(Vertex v : vertices) { graphLayout.setLocation(v, new Point(layout.getX(v) - (size.getWidth()/2), (int)layout.getY(v) - (size.getHeight()/2))); } }
private static void doISOMLayout(final Layout graphLayout, SparseGraph<VertexRef, EdgeRef> jungGraph, Dimension size) { NonStupidISOMLayout layout = new NonStupidISOMLayout(jungGraph, graphLayout); layout.setInitializer(initializer(graphLayout)); layout.setSize(size); while(!layout.done()) { layout.step(); } for(VertexRef v : jungGraph.getVertices()) { graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v))); } } }
private static void doSpringLayout(final Layout graphLayout, SparseGraph<VertexRef, EdgeRef> jungGraph, Dimension size, int repulsion) { SpringLayout<VertexRef, EdgeRef> layout = new SpringLayout<VertexRef, EdgeRef>(jungGraph); layout.setForceMultiplier(SPRING_FORCE_MULTIPLIER); layout.setRepulsionRange(repulsion); layout.setInitializer(initializer(graphLayout)); layout.setSize(size); int count = 0; while(!layout.done() && count < 700) { layout.step(); count++; } for(VertexRef v : jungGraph.getVertices()) { graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v))); } }
private static void doSpringLayout(final Layout graphLayout, SparseGraph<VertexRef, EdgeRef> jungGraph, Dimension size, int repulsion) { SpringLayout<VertexRef, EdgeRef> layout = new SpringLayout<VertexRef, EdgeRef>(jungGraph); layout.setForceMultiplier(SPRING_FORCE_MULTIPLIER); layout.setRepulsionRange(repulsion); layout.setInitializer(initializer(graphLayout)); layout.setSize(size); int count = 0; while(!layout.done() && count < 700) { layout.step(); count++; } for(VertexRef v : jungGraph.getVertices()) { graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v))); } }
@Override public void updateLayout(final Graph graph) { final Layout graphLayout = graph.getLayout(); SparseGraph<VertexRef, Edge> jungGraph = new SparseGraph<VertexRef, Edge>(); Collection<? extends Vertex> vertices = graph.getDisplayVertices(); for(VertexRef v : vertices) { jungGraph.addVertex(v); } for(Edge e : graph.getDisplayEdges()) { jungGraph.addEdge(e, e.getSource().getVertex(), e.getTarget().getVertex()); } CircleLayout<VertexRef, Edge> layout = new CircleLayout<VertexRef, Edge>(jungGraph); layout.setInitializer(initializer(graphLayout)); layout.setSize(selectLayoutSize(graph)); for(VertexRef v : vertices) { graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v))); } }
@Override public void updateLayout(final Graph graph) { final Layout graphLayout = graph.getLayout(); SparseGraph<VertexRef, Edge> jungGraph = new SparseGraph<VertexRef, Edge>(); Collection<? extends Vertex> vertices = graph.getDisplayVertices(); for(VertexRef v : vertices) { jungGraph.addVertex(v); } for(Edge e : graph.getDisplayEdges()) { jungGraph.addEdge(e, e.getSource().getVertex(), e.getTarget().getVertex()); } CircleLayout<VertexRef, Edge> layout = new CircleLayout<VertexRef, Edge>(jungGraph); layout.setInitializer(initializer(graphLayout)); layout.setSize(selectLayoutSize(graph)); for(VertexRef v : vertices) { graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v))); } }
graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v)));
graphLayout.setLocation(v, new Point(layout.getX(v), layout.getY(v)));