@Test public void hasLayoutInformation() { when(n1.getUUID()).thenReturn(UUID.uuid()); when(n2.getUUID()).thenReturn(UUID.uuid()); final GraphNodeStoreImpl store = new GraphNodeStoreImpl(); store.add(n2); store.add(n1); doCallRealMethod().when(layoutService).hasLayoutInformation(graph); doCallRealMethod().when(layoutService).getLayoutInformationThreshold(graph); when(graph.nodes()).thenReturn(store); assertFalse(layoutService.hasLayoutInformation(graph)); final Bounds bounds = Bounds.create(10, 10, 10, 10); final Bounds noBounds = Bounds.create(0, 0, 0, 0); when(n1.getContent()).thenReturn(hasBounds1); when(hasBounds1.getBounds()).thenReturn(noBounds); when(n2.getContent()).thenReturn(hasBounds2); when(hasBounds2.getBounds()).thenReturn(bounds); assertTrue(layoutService.hasLayoutInformation(graph)); }
@Override public boolean hasLayoutInformation(final Graph<?, ?> graph) { final double threshold = getLayoutInformationThreshold(graph); int nodesWithLayout = 0; for (final Node n : graph.nodes()) { final Object content = n.getContent(); if (content instanceof HasBounds) { if (!isNullOrCloseToZero(((HasBounds) content).getBounds())) { nodesWithLayout++; } } if (nodesWithLayout >= threshold) { return true; } } return false; }
AbstractLayoutService implements LayoutService { @Override public boolean hasLayoutInformation(final Graph<?, ?> graph) { final double threshold = getLayoutInformationThreshold(graph); int nodesWithLayout = 0; for (final Node n : graph.nodes()) { final Object content = n.getContent(); if (content instanceof HasBounds) { if (!isNullOrCloseToZero(((HasBounds) content).getBounds())) { nodesWithLayout++; } } if (nodesWithLayout >= threshold) { return true; } } return false; } }
AbstractLayoutService implements LayoutService { @Override public boolean hasLayoutInformation(final Graph<?, ?> graph) { final double threshold = getLayoutInformationThreshold(graph); int nodesWithLayout = 0; for (final Node n : graph.nodes()) { final Object content = n.getContent(); if (content instanceof HasBounds) { if (!isNullOrCloseToZero(((HasBounds) content).getBounds())) { nodesWithLayout++; } } if (nodesWithLayout >= threshold) { return true; } } return false; }  }
AbstractLayoutService implements LayoutService { @Override public boolean hasLayoutInformation(final Graph<?, ?> graph) { final double threshold = getLayoutInformationThreshold(graph); int nodesWithLayout = 0; for (final Node n : graph.nodes()) { final Object content = n.getContent(); if (content instanceof HasBounds) { if (!isNullOrCloseToZero(((HasBounds) content).getBounds())) { nodesWithLayout++; } } if (nodesWithLayout >= threshold) { return true; } } return false; }  @Override boolean hasLayoutInformation(final Graph<?, ?> graph); @Override abstract Layout createLayout(Graph<?, ?> graph); }
AbstractLayoutService implements LayoutService { @Override public boolean hasLayoutInformation(final Graph<?, ?> graph) { final double threshold = getLayoutInformationThreshold(graph); int nodesWithLayout = 0; for (final Node n : graph.nodes()) { final Object content = n.getContent(); if (content instanceof HasBounds) { if (!isNullOrCloseToZero(((HasBounds) content).getBounds())) { nodesWithLayout++; } } if (nodesWithLayout >= threshold) { return true; } } return false; }  @Override boolean hasLayoutInformation(final Graph<?, ?> graph); @Override abstract Layout createLayout(Graph<?, ?> graph);  }