/** * Creates a new filter using the given configuration. * * @param configuration * The configuration to use. * @param projectContext * The project context to use. */ public ComponentDependencyGraphAllocationFilter(final Configuration configuration, final IProjectContext projectContext) { super(configuration, projectContext, new ComponentAllocationDependencyGraph(AllocationRepository.ROOT_ALLOCATION_COMPONENT)); }
private static ConcurrentMap<ExecutionContainer, List<DependencyGraphNode<AllocationComponent>>> groupNodesByComponent( final ComponentAllocationDependencyGraph graph) { final ConcurrentMap<ExecutionContainer, List<DependencyGraphNode<AllocationComponent>>> nodeMap = new ConcurrentHashMap<>(); for (final DependencyGraphNode<AllocationComponent> node : graph.getNodes()) { final ExecutionContainer container = node.getEntity().getExecutionContainer(); List<DependencyGraphNode<AllocationComponent>> nodes = nodeMap.get(container); if (nodes == null) { nodes = new ArrayList<>(); nodeMap.put(container, nodes); } nodes.add(node); } return nodeMap; }
@Override protected String formatDependencyGraph(final ComponentAllocationDependencyGraph graph, final boolean includeWeights, final boolean useShortLabels, final boolean plotLoops) { final StringBuilder builder = new StringBuilder(); this.appendGraphHeader(builder); // Group nodes by execution containers final ConcurrentMap<ExecutionContainer, List<DependencyGraphNode<AllocationComponent>>> nodeMap = ComponentAllocationDependencyGraphFormatter .groupNodesByComponent(graph); for (final Entry<ExecutionContainer, List<DependencyGraphNode<AllocationComponent>>> entry : nodeMap.entrySet()) { this.handleContainerEntry(entry, builder, useShortLabels); } // Format the graph's edges graph.traverseWithVerticesFirst(new EdgeFormattingVisitor(builder, includeWeights, plotLoops, useShortLabels)); this.appendGraphFooter(builder); return builder.toString(); }