Search in sources :

Example 6 with BoundingBox

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);
    }
}
Also used : Graph(org.opennms.features.topology.api.Graph) GraphVisitor(org.opennms.features.topology.api.GraphVisitor) BoundingBox(org.opennms.features.topology.api.BoundingBox)

Example 7 with BoundingBox

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());
}
Also used : DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) HashMap(java.util.HashMap) BoundingBox(org.opennms.features.topology.api.BoundingBox) ArrayList(java.util.ArrayList) SearchResult(org.opennms.features.topology.api.topo.SearchResult) Point(org.opennms.features.topology.api.Point) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef) Test(org.junit.Test)

Example 8 with BoundingBox

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);
}
Also used : DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) HashMap(java.util.HashMap) BoundingBox(org.opennms.features.topology.api.BoundingBox) Point(org.opennms.features.topology.api.Point) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef) Test(org.junit.Test)

Example 9 with BoundingBox

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));
}
Also used : SelectionManager(org.opennms.features.topology.api.SelectionManager) BoundingBox(org.opennms.features.topology.api.BoundingBox) MapViewManager(org.opennms.features.topology.api.MapViewManager) CategoryHopCriteria(org.opennms.features.topology.app.internal.support.CategoryHopCriteria) SearchCriteria(org.opennms.features.topology.api.topo.SearchCriteria) Criteria(org.opennms.features.topology.api.topo.Criteria) IpLikeHopCriteria(org.opennms.features.topology.app.internal.support.IpLikeHopCriteria) AlarmHopCriteria(org.opennms.features.topology.app.internal.support.AlarmHopCriteria) VertexRef(org.opennms.features.topology.api.topo.VertexRef) CircleLayoutAlgorithm(org.opennms.features.topology.app.internal.jung.CircleLayoutAlgorithm)

Example 10 with BoundingBox

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());
}
Also used : BoundingBox(org.opennms.features.topology.api.BoundingBox) Point(org.opennms.features.topology.api.Point) Test(org.junit.Test)

Aggregations

BoundingBox (org.opennms.features.topology.api.BoundingBox)12 Point (org.opennms.features.topology.api.Point)7 Test (org.junit.Test)4 VertexRef (org.opennms.features.topology.api.topo.VertexRef)3 HashMap (java.util.HashMap)2 DefaultVertexRef (org.opennms.features.topology.api.topo.DefaultVertexRef)2 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 Graph (org.opennms.features.topology.api.Graph)1 GraphVisitor (org.opennms.features.topology.api.GraphVisitor)1 Layout (org.opennms.features.topology.api.Layout)1 MapViewManager (org.opennms.features.topology.api.MapViewManager)1 SelectionManager (org.opennms.features.topology.api.SelectionManager)1 Criteria (org.opennms.features.topology.api.topo.Criteria)1 SearchCriteria (org.opennms.features.topology.api.topo.SearchCriteria)1 SearchResult (org.opennms.features.topology.api.topo.SearchResult)1 Vertex (org.opennms.features.topology.api.topo.Vertex)1 CircleLayoutAlgorithm (org.opennms.features.topology.app.internal.jung.CircleLayoutAlgorithm)1 AlarmHopCriteria (org.opennms.features.topology.app.internal.support.AlarmHopCriteria)1 CategoryHopCriteria (org.opennms.features.topology.app.internal.support.CategoryHopCriteria)1