use of org.opennms.features.topology.api.topo.GraphProvider in project opennms by OpenNMS.
the class DefaultTopologyService method getPreferredLayoutAlgorithm.
// Determines default layout
@Override
public LayoutAlgorithm getPreferredLayoutAlgorithm(String metaTopologyId, String namespace) {
Objects.requireNonNull(metaTopologyId);
Objects.requireNonNull(namespace);
final GraphProvider graphProvider = getGraphProvider(metaTopologyId, namespace);
final String preferredLayout = graphProvider.getDefaults().getPreferredLayout();
final LayoutAlgorithm preferredLayoutAlgorithm = serviceLocator != null ? findLayoutAlgorithm(preferredLayout) : DEFAULT_LAYOUT_ALGORITHM;
return preferredLayoutAlgorithm;
}
use of org.opennms.features.topology.api.topo.GraphProvider in project opennms by OpenNMS.
the class ManualLayoutAlgorithmTest method verifyLayoutCoordinatesHavePriority.
/*
* If persisted layout is defined, verify that it has priority.
*/
@Test
public void verifyLayoutCoordinatesHavePriority() {
final GraphProvider graphProvider = new SimpleGraphBuilder("dummy").vertex("vertex1").vX(1).vY(1).get();
final ManualTest test = new ManualTest(graphProvider);
final LayoutEntity persistedLayout = new LayoutEntity();
int x = 5;
int y = 5;
for (VertexRef eachVertex : graphProvider.getVertices()) {
VertexPositionEntity vertexPositionEntity = new VertexPositionEntity();
vertexPositionEntity.setVertexRef(LayoutManager.toVertexRefEntity(eachVertex));
vertexPositionEntity.setPosition(new PointEntity(x++, y++));
persistedLayout.addVertexPosition(vertexPositionEntity);
}
Mockito.when(test.layoutManager.loadLayout(test.graph)).thenReturn(persistedLayout);
new ManualLayoutAlgorithm(test.layoutManager).updateLayout(test.graph);
Assert.assertEquals(ImmutableMap.builder().put(new DefaultVertexRef("dummy", "vertex1"), new Point(5, 5)).build(), test.layout.getLocations());
}
Aggregations