Search in sources :

Example 1 with ForNodeLink

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;
}
Also used : ForNodeLink(guru.nidi.graphviz.attribute.ForNodeLink) Node(org.drools.impact.analysis.graph.Node) ForNodeLink(guru.nidi.graphviz.attribute.ForNodeLink) Link(org.drools.impact.analysis.graph.Link)

Aggregations

ForNodeLink (guru.nidi.graphviz.attribute.ForNodeLink)1 Link (org.drools.impact.analysis.graph.Link)1 Node (org.drools.impact.analysis.graph.Node)1