use of guru.nidi.graphviz.attribute.ForNodeLink in project drools by kiegroup.
the class GraphImageGenerator method convertGraph.
private guru.nidi.graphviz.model.Graph convertGraph(Graph g) {
guru.nidi.graphviz.model.Graph graph = graph(graphName).directed().graphAttr().with(Rank.dir(rankDir).sep(sep));
List<Node> nodeList = g.getNodeMap().values().stream().collect(Collectors.toList());
for (Node n : nodeList) {
guru.nidi.graphviz.model.Node node = node(n.getRuleName());
if (n.getStatus() == Node.Status.CHANGED) {
node = node.with(Color.RED, Style.FILLED);
} else if (n.getStatus() == Node.Status.IMPACTED) {
node = node.with(Color.YELLOW, Style.FILLED);
} else if (n.getStatus() == Node.Status.TARGET) {
node = node.with(Color.ORANGE, Style.FILLED);
} else if (n.getStatus() == Node.Status.IMPACTING) {
node = node.with(Color.LIGHTBLUE, Style.FILLED);
}
for (Link l : n.getOutgoingLinks()) {
if (!nodeList.contains(l.getTarget())) {
// a sub map may have a link to a node which doesn't exist in the sub map
continue;
}
Style<ForNodeLink> style;
if (l.getReactivityType() == ReactivityType.POSITIVE) {
style = Style.SOLID;
} else if (l.getReactivityType() == ReactivityType.NEGATIVE) {
style = Style.DASHED;
} else {
// UNKNOWN
style = Style.DOTTED;
}
node = node.link(to(node(l.getTarget().getRuleName())).with(style));
}
graph = graph.with(node);
}
return graph;
}
Aggregations