use of org.opennms.features.topology.api.BoundingBox in project opennms by OpenNMS.
the class TopologyComponent method updateGraph.
public void updateGraph() {
BoundingBox boundingBox = getBoundingBox();
getState().setBoundX(boundingBox.getX());
getState().setBoundY(boundingBox.getY());
getState().setBoundWidth(boundingBox.getWidth());
getState().setBoundHeight(boundingBox.getHeight());
getState().setActiveTool(m_activeTool);
Graph graph = getGraph();
GraphVisitor painter = new GraphPainter(m_graphContainer, graph.getLayout(), m_iconRepoManager, getState());
try {
graph.visit(painter);
} catch (Exception e) {
LoggerFactory.getLogger(getClass()).error(e.getMessage(), e);
}
}
use of org.opennms.features.topology.api.BoundingBox in project opennms by OpenNMS.
the class SavedHistoryTest method verifyCRCIncludesSearchResult.
/**
* This methods tests whether the CRC checksums for {@link SavedHistory} object with {@link SearchResult}s are generated correctly,
* namely that they now take into account the search results
*/
@Test
public void verifyCRCIncludesSearchResult() {
Map<String, String> settings = new HashMap<String, String>();
settings.put("hello", "world");
VertexRef vert1 = new DefaultVertexRef("nodes", "1");
VertexRef vert2 = new DefaultVertexRef("nodes", "2", "HasALabel");
Map<VertexRef, Point> locations = new HashMap<VertexRef, Point>();
locations.put(vert1, new Point(0, 0));
locations.put(vert2, new Point(0, 0));
// Creating SavedHistory object with no search results
SavedHistory history1 = new SavedHistory(1, new BoundingBox(0, 0, 100, 100), locations, Collections.singleton(vert2), Collections.emptySet(), settings, Collections.emptyList());
List<SearchResult> searchResults = new ArrayList<>();
searchResults.add(new SearchResult("alarm", "alarmID", "someLabel", searchQuery, SearchResult.COLLAPSIBLE, !SearchResult.COLLAPSED));
// Creating SavedHistory object with a single search result with ID = "alarmID"
SavedHistory history2 = new SavedHistory(1, new BoundingBox(0, 0, 100, 100), locations, Collections.singleton(vert2), Collections.emptySet(), settings, searchResults);
// Assertion that the SavedHistory with no search results is different from the one with one
Assert.assertNotEquals(history1.getFragment(), history2.getFragment());
// Creating another SavedHistory WITH search result, identical to the 2nd one
SavedHistory history3 = new SavedHistory(1, new BoundingBox(0, 0, 100, 100), locations, Collections.singleton(vert2), Collections.emptySet(), settings, searchResults);
// Assertion that two SavedHistory objects with the same search results are identical
Assert.assertEquals(history2.getFragment(), history3.getFragment());
}
use of org.opennms.features.topology.api.BoundingBox in project opennms by OpenNMS.
the class SavedHistoryTest method testMarshall.
@Test
public void testMarshall() {
Map<String, String> settings = new HashMap<String, String>();
settings.put("hello", "world");
VertexRef vert1 = new DefaultVertexRef("nodes", "1");
VertexRef vert2 = new DefaultVertexRef("nodes", "2", "HasALabel");
Map<VertexRef, Point> locations = new HashMap<VertexRef, Point>();
locations.put(vert1, new Point(0, 0));
locations.put(vert2, new Point(0, 0));
SavedHistory savedHistory = new SavedHistory(0, new BoundingBox(0, 0, 100, 100), locations, Collections.singleton(vert2), Collections.emptySet(), settings, Collections.emptyList());
JAXB.marshal(savedHistory, System.out);
// Specify a focus node
savedHistory = new SavedHistory(0, new BoundingBox(0, 0, 100, 100), locations, Collections.singleton(vert2), Collections.singleton(vert1), settings, Collections.emptyList());
JAXB.marshal(savedHistory, System.out);
}
use of org.opennms.features.topology.api.BoundingBox in project opennms by OpenNMS.
the class BundleContextHistoryManagerTest method setBehaviour.
private void setBehaviour(GraphContainer graphContainerMock) {
MapViewManager mapViewManagerMock = Mockito.mock(MapViewManager.class);
SelectionManager selectionManagerMock = Mockito.mock(SelectionManager.class);
Mockito.when(mapViewManagerMock.getCurrentBoundingBox()).thenReturn(new BoundingBox(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE));
Mockito.when(selectionManagerMock.getSelectedVertexRefs()).thenReturn(new ArrayList<VertexRef>());
Mockito.when(graphContainerMock.getGraph()).thenReturn(graphMock);
Mockito.when(graphContainerMock.getSemanticZoomLevel()).thenReturn(0);
Mockito.when(graphContainerMock.getLayoutAlgorithm()).thenReturn(new CircleLayoutAlgorithm());
Mockito.when(graphContainerMock.getMapViewManager()).thenReturn(mapViewManagerMock);
Mockito.when(graphContainerMock.getSelectionManager()).thenReturn(selectionManagerMock);
Mockito.doAnswer(invocationOnMock -> capturedCriteria.toArray(new Criteria[capturedCriteria.size()])).when(graphContainerMock).getCriteria();
Mockito.doAnswer(invocationOnMock -> {
capturedCriteria.clear();
return null;
}).when(graphContainerMock).clearCriteria();
Mockito.doAnswer(invocation -> {
if (invocation.getArguments()[0] != null && invocation.getArguments()[0] instanceof Criteria) {
capturedCriteria.add((Criteria) invocation.getArguments()[0]);
}
return null;
}).when(graphContainerMock).addCriteria(Matchers.any(Criteria.class));
}
use of org.opennms.features.topology.api.BoundingBox in project opennms by OpenNMS.
the class MapViewPortTest method testPanMap.
@Test
public void testPanMap() {
DefaultMapViewManager viewManager = new DefaultMapViewManager();
viewManager.setMapBounds(new BoundingBox(0, 0, 8000, 4000));
viewManager.setViewPort(400, 300);
BoundingBox box = viewManager.getCurrentBoundingBox();
assertNotNull(box);
assertEquals(4000, box.getCenter().getX(), m_delta);
assertEquals(2000, box.getCenter().getY(), m_delta);
assertEquals(8000, box.getWidth());
assertEquals(6000, box.getHeight());
assertEquals(0, box.getX());
assertEquals(-1000, box.getY());
viewManager.setCenter(new Point(3900, 1900));
box = viewManager.getCurrentBoundingBox();
assertNotNull(box);
assertEquals(3900, box.getCenter().getX(), m_delta);
assertEquals(1900, box.getCenter().getY(), m_delta);
assertEquals(8000, box.getWidth());
assertEquals(6000, box.getHeight());
assertEquals(-100, box.getX());
assertEquals(-1100, box.getY());
}
Aggregations