guru.nidi.graphviz.model.Node Java Examples

The following examples show how to use guru.nidi.graphviz.model.Node. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlanImpl.java    From jesterj with Apache License 2.0 6 votes vote down vote up
private void linkUp(Map<String, Node> nodes, List<String> knownSteps, StepImpl step) {
  LinkedHashMap<String, Step> nextSteps = step.getNextSteps();
  Node node = nodes.computeIfAbsent(step.getName(), Factory::node);
  if (step instanceof Scanner) {
    node= node.with(Color.BLUE,Style.lineWidth(3));
    nodes.replace(step.getName(), node);
  }
  knownSteps.add(step.getName());
  if (nextSteps.size() == 0) {
    return;
  }
  for (Step subsequentStep : nextSteps.values()) {
    if (!knownSteps.contains(subsequentStep.getName())) {
      // new node, need to recurse
      linkUp(nodes, knownSteps, (StepImpl) subsequentStep);  // yuck but I don't really want to expose next steps in interface either
    }
    Node nextNode = nodes.get(subsequentStep.getName());
    node = node.link(nextNode);
    // link returns an immutable copy of the node we just created, so we need
    // to throw out the original and keep the copy
    nodes.put(step.getName(), node);
  }
}
 
Example #2
Source File: GraphvizTest.java    From graphviz-java with Apache License 2.0 5 votes vote down vote up
@Test
void validating() {
    final List<ValidatorMessage> messages = new ArrayList<>();
    final Node a = node("a").with("c", "d").link("b");
    Graphviz.fromGraph(graph().with(a)).validating(messages::add).render(SVG).toString();
    assertEquals(asList(new ValidatorMessage(ERROR, "c", "is unknown.", null, new Location(NODE, a))), messages);
}