コード例 #1
0
 private void removeHopCriteria(GraphContainer container) {
   Criteria[] currentCriteria = container.getCriteria();
   for (Criteria c : Arrays.copyOf(currentCriteria, currentCriteria.length)) {
     if (c instanceof DefaultVertexHopCriteria) {
       container.removeCriteria(c);
     }
   }
 }
コード例 #2
0
  @Override
  public void execute(List<VertexRef> targets, OperationContext operationContext) {
    if (targets == null || targets.isEmpty()) {
      return;
    }

    final GraphContainer graphContainer = operationContext.getGraphContainer();
    graphContainer.clearCriteria();

    new AddFocusVerticesOperation().execute(targets, operationContext);
  }
コード例 #3
0
ファイル: SaveToXmlTest.java プロジェクト: GuanglinDu/opennms
  @Test
  public void testSave() throws Exception {

    final SimpleGraphProvider simpleTopo = new SimpleGraphProvider();
    simpleTopo.load("test-graph.xml");

    SaveToXmlOperation saver = new SaveToXmlOperation();

    GraphContainer graphContainer = EasyMock.createMock(GraphContainer.class);
    EasyMock.expect(graphContainer.getBaseTopology()).andReturn(simpleTopo).anyTimes();
    EasyMock.replay(graphContainer);

    saver.execute(null, new TestOperationContext(graphContainer));
  }
コード例 #4
0
  private void focusOnVertices(
      VertexRef target, Set<GraphVertex> graphVerticesToFocus, GraphContainer container) {
    // add to focus
    removeHopCriteria(container);
    graphVerticesToFocus.forEach(
        graphVertex ->
            container.addCriteria(new DefaultVertexHopCriteria(createTopologyVertex(graphVertex))));
    // add the context vertex because it is missing in the root cause result
    container.addCriteria(new DefaultVertexHopCriteria(target));
    container.setSemanticZoomLevel(0);

    // Remove the current selection before redrawing the layout in order
    // to avoid centering on the current vertex
    container.getSelectionManager().setSelectedVertexRefs(Collections.emptyList());
    container.getSelectionManager().setSelectedEdgeRefs(Collections.emptyList());
    container.redoLayout();
  }