Пример #1
0
        /// <summary>
        /// Creates a new <see cref="FilteredGraphWrapper"/> that shows the currently visible original nodes.
        /// </summary>
        /// <remarks>
        /// Nodes without currently visible edges are also filtered out.
        /// </remarks>
        private FilteredGraphWrapper CreateFilteredView()
        {
            // create a new FilteredGraphWrapper that filters the original graph and shows only the currently visible nodes
            var filteredGraph = new FilteredGraphWrapper(OriginalGraph,
                                                         node => {
                node = aggregationHelper.GetPlaceholder(node);
                if (!AggregateGraph.Contains(node))
                {
                    return(false);
                }
                // also filter nodes without edges
                return(AggregateGraph.EdgesAt(node).Count(edge => !aggregationHelper.IsHierarchyEdge(edge)) > 0);
            });

            // set the node layouts for a smooth transition
            foreach (var node in filteredGraph.Nodes)
            {
                filteredGraph.SetNodeLayout(node, aggregationHelper.GetPlaceholder(node).Layout.ToRectD());
            }

            // reset any rotated labels
            foreach (var label in filteredGraph.Labels)
            {
                filteredGraph.SetLabelLayoutParameter(label, FreeNodeLabelModel.Instance.CreateDefaultParameter());
            }

            return(filteredGraph);
        }