use of com.github.sevntu.checkstyle.dot.domain.Node in project methods-distance by sevntu-checkstyle.
the class DependencyInfoGraphSerializer method createNode.
private static Node createNode(Method method) {
final Node node = new Node(method.getSignature());
node.setColor(getColorForMethod(method));
node.setShape(getShapeForMethod(method));
return node;
}
use of com.github.sevntu.checkstyle.dot.domain.Node in project methods-distance by sevntu-checkstyle.
the class DependencyInfoGraphSerializer method createEdge.
private static Edge createEdge(Method caller, Method callee, Map<Method, Node> methodToNode, MethodOrder methodOrder) {
final Node callerNode = methodToNode.get(caller);
final Node calleeNode = methodToNode.get(callee);
final Edge edge = new Edge(callerNode, calleeNode);
final int indexDistance = methodOrder.getMethodsIndexDifference(caller, callee);
final int lineDistance = methodOrder.getMethodsLineDifference(caller, callee);
edge.setLabel(getFormattedEdgeLabel(indexDistance, lineDistance));
return edge;
}
use of com.github.sevntu.checkstyle.dot.domain.Node in project methods-distance by sevntu-checkstyle.
the class DependencyInfoGraphSerializer method serializeInfo.
public static String serializeInfo(Dependencies dependencies) {
final MethodOrder info = new MethodOrder(dependencies);
final Graph graph = new Graph("dependencies");
graph.setRankdir(Rankdirs.LR);
final Cluster simpleMethods = new Cluster("simple");
final Map<Method, Node> methodToNode = info.getMethods().stream().filter(method -> !info.isInterfaceMethod(method)).collect(Collectors.toMap(Function.identity(), DependencyInfoGraphSerializer::createNode));
methodToNode.entrySet().stream().forEach(methodAndNode -> {
if (info.hasMethodDependencies(methodAndNode.getKey())) {
graph.addComponent(methodAndNode.getValue());
} else {
simpleMethods.addComponent(methodAndNode.getValue());
}
});
graph.addComponent(simpleMethods);
for (final Method caller : methodToNode.keySet()) {
for (final Method callee : info.getMethodDependenciesInAppearanceOrder(caller)) {
graph.addComponent(createEdge(caller, callee, methodToNode, info));
}
}
final Comment comment = new Comment(getDescription());
graph.addComponent(comment);
return serialize(graph);
}
Aggregations