@Test public void testArrangeVertices() { final GraphLayer layer1 = mock(GraphLayer.class); final GraphLayer layer2 = mock(GraphLayer.class); final List<GraphLayer> layers = Arrays.asList(layer1, layer2); final ReorderedGraph graph = mock(ReorderedGraph.class); final HashMap hash = mock(HashMap.class); final HashMap layersStartX = mock(HashMap.class); final int largestWidth = 100; final int newY = 17; doReturn(hash).when(tested).createHashForLayersWidth(); doReturn(largestWidth).when(tested).calculateLayersWidth(layers, hash); doReturn(layersStartX).when(tested).getLayersStartX(layers.size(), hash, largestWidth); doReturn(newY).when(tested).distributeVertices(layers, layersStartX, DEFAULT_LAYER_VERTICAL_PADDING, 0, graph); doReturn(newY).when(tested).distributeVertices(layers, layersStartX, newY, 1, graph); tested.arrangeVertices(layers, LayerArrangement.TopDown, graph); final InOrder inOrder = inOrder(tested); inOrder.verify(tested).distributeVertices(layers, layersStartX, DEFAULT_LAYER_VERTICAL_PADDING, 0, graph); inOrder.verify(tested).distributeVertices(layers, layersStartX, newY, 1, graph); }
void arrangeVertices(final List<GraphLayer> layers, final LayerArrangement arrangement, final ReorderedGraph graph) { final HashMap<Integer, Integer> layersWidth = createHashForLayersWidth(); int largestWidth = calculateLayersWidth(layers, layersWidth); final HashMap<Integer, Integer> layersStartX = getLayersStartX(layers.size(), layersWidth, largestWidth); int y = DEFAULT_LAYER_VERTICAL_PADDING; switch (arrangement) { case TopDown: for (int i = 0; i < layers.size(); i++) { y = distributeVertices(layers, layersStartX, y, i, graph); } break; case BottomUp: for (int i = layers.size() - 1; i >= 0; i--) { y = distributeVertices(layers, layersStartX, y, i, graph); } break; } }
DefaultVertexPositioning implements VertexPositioning { void arrangeVertices(final List<GraphLayer> layers, final LayerArrangement arrangement, final ReorderedGraph graph) { final HashMap<Integer, Integer> layersWidth = createHashForLayersWidth(); int largestWidth = calculateLayersWidth(layers, layersWidth); final HashMap<Integer, Integer> layersStartX = getLayersStartX(layers.size(), layersWidth, largestWidth); int y = DEFAULT_LAYER_VERTICAL_PADDING; switch (arrangement) { case TopDown: for (int i = 0; i < layers.size(); i++) { y = distributeVertices(layers, layersStartX, y, i, graph); } break; case BottomUp: for (int i = layers.size() - 1; i >= 0; i--) { y = distributeVertices(layers, layersStartX, y, i, graph); } break; } } }
DefaultVertexPositioning implements VertexPositioning { void arrangeVertices(final List<GraphLayer> layers, final LayerArrangement arrangement, final ReorderedGraph graph) { final HashMap<Integer, Integer> layersWidth = createHashForLayersWidth(); int largestWidth = calculateLayersWidth(layers, layersWidth); final HashMap<Integer, Integer> layersStartX = getLayersStartX(layers.size(), layersWidth, largestWidth); int y = DEFAULT_LAYER_VERTICAL_PADDING; switch (arrangement) { case TopDown: for (int i = 0; i < layers.size(); i++) { y = distributeVertices(layers, layersStartX, y, i, graph); } break; case BottomUp: for (int i = layers.size() - 1; i >= 0; i--) { y = distributeVertices(layers, layersStartX, y, i, graph); } break; } }  }
DefaultVertexPositioning implements VertexPositioning { void arrangeVertices(final List<GraphLayer> layers, final LayerArrangement arrangement, final ReorderedGraph graph) { final HashMap<Integer, Integer> layersWidth = createHashForLayersWidth(); int largestWidth = calculateLayersWidth(layers, layersWidth); final HashMap<Integer, Integer> layersStartX = getLayersStartX(layers.size(), layersWidth, largestWidth); int y = DEFAULT_LAYER_VERTICAL_PADDING; switch (arrangement) { case TopDown: for (int i = 0; i < layers.size(); i++) { y = distributeVertices(layers, layersStartX, y, i, graph); } break; case BottomUp: for (int i = layers.size() - 1; i >= 0; i--) { y = distributeVertices(layers, layersStartX, y, i, graph); } break; } }  @Override void calculateVerticesPositions(final ReorderedGraph graph,
                                           final LayerArrangement arrangement); boolean removeVirtualVertex(final OrientedEdge edge,
                                       final List<OrientedEdge> edges,
                                       final Set<Vertex> vertices); void removeVirtualVertices(final List<OrientedEdge> edges,
                                      final Set<Vertex> vertices); }
DefaultVertexPositioning implements VertexPositioning { void arrangeVertices(final List<GraphLayer> layers, final LayerArrangement arrangement, final ReorderedGraph graph) { final HashMap<Integer, Integer> layersWidth = createHashForLayersWidth(); int largestWidth = calculateLayersWidth(layers, layersWidth); final HashMap<Integer, Integer> layersStartX = getLayersStartX(layers.size(), layersWidth, largestWidth); int y = DEFAULT_LAYER_VERTICAL_PADDING; switch (arrangement) { case TopDown: for (int i = 0; i < layers.size(); i++) { y = distributeVertices(layers, layersStartX, y, i, graph); } break; case BottomUp: for (int i = layers.size() - 1; i >= 0; i--) { y = distributeVertices(layers, layersStartX, y, i, graph); } break; } }  @Override void calculateVerticesPositions(final ReorderedGraph graph,
                                           final LayerArrangement arrangement); boolean removeVirtualVertex(final OrientedEdge edge,
                                       final List<OrientedEdge> edges,
                                       final Set<Vertex> vertices); void removeVirtualVertices(final List<OrientedEdge> edges,
                                      final Set<Vertex> vertices);  }