예제 #1
0
        /// <summary>
        /// Apply the appropriate layout to the specified cluster
        /// </summary>
        /// <param name="cluster">the root of the cluster hierarchy to lay out</param>
        /// <returns>list of edges external to the cluster</returns>
        void LayoutCluster(Cluster cluster)
        {
            ProgressStep();
            cluster.UnsetInitialLayoutState();
            FastIncrementalLayoutSettings settings = null;
            LayoutAlgorithmSettings       s        = clusterSettings(cluster);
            Directions layoutDirection             = Directions.None;

            if (s is SugiyamaLayoutSettings)
            {
                var ss = s as SugiyamaLayoutSettings;
                settings = ss.FallbackLayoutSettings != null
                    ? new FastIncrementalLayoutSettings((FastIncrementalLayoutSettings)ss.FallbackLayoutSettings)
                    : new FastIncrementalLayoutSettings();
                layoutDirection = LayeredLayoutEngine.GetLayoutDirection(ss);
            }
            else
            {
                settings = new FastIncrementalLayoutSettings((FastIncrementalLayoutSettings)s);
            }

            settings.ApplyForces          = true;
            settings.MinorIterations      = 10;
            settings.AvoidOverlaps        = true;
            settings.InterComponentForces = false;
            settings.IdealEdgeLength      = new IdealEdgeLengthSettings {
                EdgeDirectionConstraints  = layoutDirection,
                ConstrainedEdgeSeparation = 30
            };
            settings.EdgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.Spline;

            HashSet <Node> addedNodes;

            if (addedNodesByCluster.TryGetValue(cluster, out addedNodes))
            {
                // if the structure of the cluster has changed then we apply unconstrained layout first,
                // then introduce structural constraints, and then all constraints
                settings.MinConstraintLevel = 0;
                settings.MaxConstraintLevel = 2;
            }
            else
            {
                settings.MinConstraintLevel = 2;
            }

            GeometryGraph newGraph = GetShallowCopyGraphUnderCluster(cluster);

            LayoutAlgorithmHelpers.ComputeDesiredEdgeLengths(settings.IdealEdgeLength, newGraph);

            // orthogonal ordering constraints preserve the left-of, above-of relationships between existing nodes
            // (we do not apply these to the newly added nodes)
            GenerateOrthogonalOrderingConstraints(
                newGraph.Nodes.Where(v => !addedNodes.Contains(v.UserData as Node)).ToList(), settings);

            LayoutComponent(newGraph, settings);
            //LayoutAlgorithmSettings.ShowGraph(newGraph);
            InitialLayoutByCluster.FixOriginalGraph(newGraph, true);

            cluster.UpdateBoundary(newGraph.BoundingBox);
        }
예제 #2
0
        void CreateLayerEdgesUnderIntEdge(IntEdge ie)
        {
            int source = ie.Source;
            int target = ie.Target;

            int span = LayeredLayoutEngine.EdgeSpan(initialLayering, ie);

            ie.LayerEdges = new LayerEdge[span];
            Debug.Assert(span > 0);
            if (span == 1)
            {
                ie.LayerEdges[0] = new LayerEdge(ie.Source, ie.Target, ie.CrossingWeight);
            }
            else
            {
                ie.LayerEdges[0] = new LayerEdge(source, numberOfNodesOfProperGraph, ie.CrossingWeight);
                for (int i = 0; i < span - 2; i++)
                {
                    ie.LayerEdges[i + 1] = new LayerEdge(numberOfNodesOfProperGraph++, numberOfNodesOfProperGraph,
                                                         ie.CrossingWeight);
                }

                ie.LayerEdges[span - 1] = new LayerEdge(numberOfNodesOfProperGraph++, target, ie.CrossingWeight);
            }
        }
        internal void Calculate()
        {
            AllocateXPositions();
            var originalGraph = intGraph.Nodes[0].GeometryParent as GeometryGraph;

            LayeredLayoutEngine.CalculateAnchorSizes(database, out database.anchors, ProperLayeredGraph, originalGraph, intGraph, settings);
            LayeredLayoutEngine.CalcInitialYAnchorLocations(LayerArrays, 500, geometryGraph, database, intGraph, settings, LayersAreDoubled);
            Order();
        }
예제 #4
0
        /// <summary>
        /// adaptes to the node boundary curve change
        /// </summary>
        public static void IncrementalLayout(GeometryGraph geometryGraph, Node node)
        {
            ValidateArg.IsNotNull(geometryGraph, "geometryGraph");

            LayeredLayoutEngine engine = geometryGraph.AlgorithmData as LayeredLayoutEngine;

            if (engine == null)
            {
                return;
            }
            PreRunTransform(geometryGraph, engine.SugiyamaSettings.Transformation);
            engine.IncrementalRun(node);
            PostRunTransform(geometryGraph, engine.SugiyamaSettings.Transformation);
        }
예제 #5
0
        internal static LayeredLayoutEngine CalculateLayout(GeometryGraph msaglGraph, SugiyamaLayoutSettings settings, CancelToken cancelToken)
        {
            var engine = new LayeredLayoutEngine(msaglGraph, settings);

#if USE_PHYLOTREE
            PhyloTree phyloTree = msaglGraph as PhyloTree;
            if (phyloTree != null)
            {
                var pc = new PhyloTreeLayoutCalclulation(phyloTree, settings, engine.IntGraph, engine.Database);
                pc.Run();
            }
            else
#endif
            engine.Run(cancelToken);
            return(engine);
        }
예제 #6
0
 /// <summary>
 /// Layered layout arranged the given graph on layers inferred from the directed edge structure
 /// </summary>
 /// <param name="geometryGraph">graph to be laid out</param>
 /// <param name="settings">The settings for the algorithm.</param>
 public LayeredLayout(GeometryGraph geometryGraph, SugiyamaLayoutSettings settings)
 {
     this.geometryGraph = geometryGraph;
     this.settings      = settings;
     this.engine        = new LayeredLayoutEngine(geometryGraph, settings);
 }