@Test public void testGetLayersStartX() { final int largestWidth = 600; final int layersCount = 3; final HashMap<Integer, Integer> layersWidth = new HashMap<>(); layersWidth.put(0, 200); layersWidth.put(1, 600); layersWidth.put(2, 300); final HashMap<Integer, Integer> startX = tested.getLayersStartX(layersCount, layersWidth, largestWidth); assertEquals(200 + DEFAULT_LAYER_HORIZONTAL_PADDING, (int) startX.get(0)); assertEquals(0 + DEFAULT_LAYER_HORIZONTAL_PADDING, (int) startX.get(1)); assertEquals(150 + DEFAULT_LAYER_HORIZONTAL_PADDING, (int) startX.get(2)); }
HashMap<Integer, Integer> getLayersStartX(final int layersCount, final HashMap<Integer, Integer> layersWidth, final int largestWidth) { final HashMap<Integer, Integer> layersStartX = new HashMap<>(); for (int i = 0; i < layersCount; i++) { final int middle = largestWidth / 2; final int layerWidth = layersWidth.get(i); final int firstHalf = layerWidth / 2; int startPoint = middle - firstHalf; startPoint += DEFAULT_LAYER_HORIZONTAL_PADDING; layersStartX.put(i, startPoint); } return layersStartX; }
DefaultVertexPositioning implements VertexPositioning { HashMap<Integer, Integer> getLayersStartX(final int layersCount, final HashMap<Integer, Integer> layersWidth, final int largestWidth) { final HashMap<Integer, Integer> layersStartX = new HashMap<>(); for (int i = 0; i < layersCount; i++) { final int middle = largestWidth / 2; final int layerWidth = layersWidth.get(i); final int firstHalf = layerWidth / 2; int startPoint = middle - firstHalf; startPoint += DEFAULT_LAYER_HORIZONTAL_PADDING; layersStartX.put(i, startPoint); } return layersStartX; } }
DefaultVertexPositioning implements VertexPositioning { HashMap<Integer, Integer> getLayersStartX(final int layersCount, final HashMap<Integer, Integer> layersWidth, final int largestWidth) { final HashMap<Integer, Integer> layersStartX = new HashMap<>(); for (int i = 0; i < layersCount; i++) { final int middle = largestWidth / 2; final int layerWidth = layersWidth.get(i); final int firstHalf = layerWidth / 2; int startPoint = middle - firstHalf; startPoint += DEFAULT_LAYER_HORIZONTAL_PADDING; layersStartX.put(i, startPoint); } return layersStartX; }  }
DefaultVertexPositioning implements VertexPositioning { HashMap<Integer, Integer> getLayersStartX(final int layersCount, final HashMap<Integer, Integer> layersWidth, final int largestWidth) { final HashMap<Integer, Integer> layersStartX = new HashMap<>(); for (int i = 0; i < layersCount; i++) { final int middle = largestWidth / 2; final int layerWidth = layersWidth.get(i); final int firstHalf = layerWidth / 2; int startPoint = middle - firstHalf; startPoint += DEFAULT_LAYER_HORIZONTAL_PADDING; layersStartX.put(i, startPoint); } return layersStartX; }  @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 { HashMap<Integer, Integer> getLayersStartX(final int layersCount, final HashMap<Integer, Integer> layersWidth, final int largestWidth) { final HashMap<Integer, Integer> layersStartX = new HashMap<>(); for (int i = 0; i < layersCount; i++) { final int middle = largestWidth / 2; final int layerWidth = layersWidth.get(i); final int firstHalf = layerWidth / 2; int startPoint = middle - firstHalf; startPoint += DEFAULT_LAYER_HORIZONTAL_PADDING; layersStartX.put(i, startPoint); } return layersStartX; }  @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);  }