コード例 #1
0
ファイル: NetworkLayout.cs プロジェクト: senfo/snaglV2
        /// <summary>
        /// Performs the actual layout algorithm.
        /// </summary>
        /// <param name="graph">The object containing the graph data</param>
        /// <param name="rootNode">Root node</param>
        protected override void PerformLayout(GraphMapData graph, INode rootNode)
        {
            // this ensures that the end result will remain the same across multiple runs
            // because each node will have the same starting position
            new GridLayout().CalculateLayout(graph);

            System.Diagnostics.Debug.WriteLine("");
            foreach (Delegate d in ContextMenuManager.Instance.GetContextMenuOpeningInvocationList())
            {
                System.Diagnostics.Debug.WriteLine((d.Target as GraphComponents).Scope);
            }

            // Create a GraphComponents instance that is a partitioned
            // representation of the original graph. Each node in this
            // graph is a partition node.
            GraphComponents connectedGraphComponents = GraphManager.Instance.GetConnectedComponents(GraphManager.Instance.DefaultGraphComponentsInstance.Scope);
            IEnumerable<INodeShape> connectedComponents = connectedGraphComponents.GetNodeViewModels();

            System.Diagnostics.Debug.WriteLine("");
            foreach (Delegate d in ContextMenuManager.Instance.GetContextMenuOpeningInvocationList())
            {
                System.Diagnostics.Debug.WriteLine((d.Target as GraphComponents).Scope);
            }

            foreach (PartitionNode connectedComponent in connectedComponents)
            {
                using (GraphComponents connectedGraph = connectedComponent.GetGraph())
                {
                    LayoutByClusters(graph, connectedGraph);
                }
            }

            // Layout the overall graph
            GraphMapData connectedGraphMapData = GetClusteredGraph(graph, connectedGraphComponents);
            IDictionary<string, Point> originalPositions = GetOriginalPositions(connectedGraphMapData);
            GridLayout gridLayout = new GridLayout();
            gridLayout.CalculateLayout(connectedGraphMapData);
            ApplyOffsetToSubGraphs(graph, connectedGraphComponents, originalPositions, connectedGraphMapData);

            connectedGraphComponents.Dispose();

            System.Diagnostics.Debug.WriteLine("");
            foreach (Delegate d in ContextMenuManager.Instance.GetContextMenuOpeningInvocationList())
            {
                System.Diagnostics.Debug.WriteLine((d.Target as GraphComponents).Scope);
            }
        }
コード例 #2
0
ファイル: NetworkLayout.cs プロジェクト: senfo/snaglV2
        /// <summary>
        /// Instantiates an appropriate layout instance
        /// </summary>
        /// <param name="isAttributeCluster">Indicates whether we have attribute similarity clusters or not</param>
        /// <returns>a new, appropriate, LayoutBase instance</returns>
        private static AsynchronousLayoutBase GetClusterLayout(bool isAttributeCluster)
        {
            AsynchronousLayoutBase clusterLayout;

            // Check if our clusters are based on attribute similarity
            if (isAttributeCluster)
            {
                clusterLayout = new GridLayout();
            }
            else
            {
                clusterLayout = new FRLayout();
            }

            return clusterLayout;
        }