コード例 #1
0
 static void TransferVerticalConstraints(VerticalConstraintsForLayeredLayout verticalConstraints,
                                         SugiyamaLayoutSettings sugiyamaLayoutSettings)
 {
     foreach (Node node in verticalConstraints._minLayerOfDrawingGraph)
     {
         CheckGeomNode(node);
         sugiyamaLayoutSettings.PinNodesToMinLayer(node.GeometryNode);
     }
     foreach (Node node in verticalConstraints._maxLayerOfDrawingGraph)
     {
         CheckGeomNode(node);
         sugiyamaLayoutSettings.PinNodesToMaxLayer(node.GeometryNode);
     }
     foreach (var couple in verticalConstraints.SameLayerConstraints)
     {
         CheckGeomNode(couple.Item1); CheckGeomNode(couple.Item2);
         sugiyamaLayoutSettings.PinNodesToSameLayer(couple.Item1.GeometryNode,
                                                    couple.Item2.GeometryNode);
     }
     foreach (var couple in verticalConstraints.UpDownConstraints)
     {
         CheckGeomNode(couple.Item1); CheckGeomNode(couple.Item2);
         sugiyamaLayoutSettings.AddUpDownConstraint(couple.Item1.GeometryNode,
                                                    couple.Item2.GeometryNode);
     }
 }
コード例 #2
0
        public void ConstraintWithTransformation()
        {
            Random random = new Random(999);

            GeometryGraph graph = GraphGenerator.GenerateOneSimpleGraph();

            GraphGenerator.SetRandomNodeShapes(graph, random);
            SugiyamaLayoutSettings settings = new SugiyamaLayoutSettings();

            //layer direction to be left to right
            settings.Transformation = PlaneTransformation.Rotation(Math.PI / 2);

            List <Node> nodes = graph.Nodes.ToList();

            settings.AddUpDownConstraint(nodes[0], nodes[1]);
            settings.AddLeftRightConstraint(nodes[3], nodes[4]);
            settings.AddUpDownVerticalConstraint(nodes[0], nodes[3]);
            settings.AddSameLayerNeighbors(nodes[2], nodes[4]);

            LayeredLayout layeredLayout = new LayeredLayout(graph, settings);

            layeredLayout.Run();

            ShowGraphInDebugViewer(graph);

            SugiyamaValidation.ValidateUpDownConstraint(nodes[0], nodes[1]);
            SugiyamaValidation.ValidateLeftRightConstraint(nodes[3], nodes[4]);
            SugiyamaValidation.ValidateUpDownVerticalConstraint(nodes[0], nodes[3]);
            SugiyamaValidation.ValidateNeighborConstraint(graph, nodes[2], nodes[4], settings);
        }
コード例 #3
0
        static void TestGraphWithConstraints()
        {
            var graph = new GeometryGraph();

            var closed    = new Node(CreateEllipse(), "closed");
            var line      = new Node(CreateEllipse(), "line");
            var bezier    = new Node(CreateEllipse(), "bezier");
            var arc       = new Node(CreateEllipse(), "arc");
            var rectangle = new Node(CreateEllipse(), "rectangle");
            var ellipse   = new Node(CreateEllipse(), "ellipse");
            var polygon   = new Node(CreateEllipse(), "polygon");
            var shapes    = new Node(CreateEllipse(), "shapes");
            var open      = new Node(CreateEllipse(), "open");

            graph.Nodes.Add(closed);
            graph.Nodes.Add(line);
            graph.Nodes.Add(bezier);
            graph.Nodes.Add(arc);
            graph.Nodes.Add(rectangle);
            graph.Nodes.Add(ellipse);
            graph.Nodes.Add(polygon);
            graph.Nodes.Add(shapes);
            graph.Nodes.Add(open);

            var so = new Edge(shapes, open);
            var sc = new Edge(shapes, closed);
            var ol = new Edge(open, line);
            var ob = new Edge(open, bezier);
            var oa = new Edge(open, arc);
            var cr = new Edge(closed, rectangle);
            var ce = new Edge(closed, ellipse);
            var cp = new Edge(closed, polygon);

            graph.Edges.Add(so);
            graph.Edges.Add(sc);
            graph.Edges.Add(ol);
            graph.Edges.Add(ob);
            graph.Edges.Add(oa);
            graph.Edges.Add(cr);
            graph.Edges.Add(ce);
            graph.Edges.Add(cp);

            var settings = new SugiyamaLayoutSettings();

            settings.AddUpDownVerticalConstraint(closed, ellipse);
            settings.AddUpDownVerticalConstraint(open, bezier);
            settings.AddUpDownConstraint(closed, open);
            settings.AddSameLayerNeighbors(polygon, open);
            settings.AddLeftRightConstraint(closed, open);
            settings.AddLeftRightConstraint(open, closed);

            ////To verify 444585, just turn on this following commented line
            settings.AddLeftRightConstraint(ellipse, rectangle);
            settings.AddLeftRightConstraint(ellipse, bezier);

            var layeredLayout = new LayeredLayout(graph, settings);

            layeredLayout.Run();
#if TEST_MSAGL
            DisplayGeometryGraph.ShowGraph(graph);
#endif
        }
コード例 #4
0
        public void TreeWithConstraints()
        {
            var graph = new GeometryGraph();

            var closed    = new Node(CreateEllipse(), "closed");
            var line      = new Node(CreateEllipse(), "line");
            var bezier    = new Node(CreateEllipse(), "bezier");
            var arc       = new Node(CreateEllipse(), "arc");
            var rectangle = new Node(CreateEllipse(), "rectangle");
            var ellipse   = new Node(CreateEllipse(), "ellipse");
            var polygon   = new Node(CreateEllipse(), "polygon");
            var shapes    = new Node(CreateEllipse(), "shapes");
            var open      = new Node(CreateEllipse(), "open");

            graph.Nodes.Add(closed);
            graph.Nodes.Add(line);
            graph.Nodes.Add(bezier);
            graph.Nodes.Add(arc);
            graph.Nodes.Add(rectangle);
            graph.Nodes.Add(ellipse);
            graph.Nodes.Add(polygon);
            graph.Nodes.Add(shapes);
            graph.Nodes.Add(open);

            var so = new Edge(shapes, open);
            var sc = new Edge(shapes, closed);
            var ol = new Edge(open, line);
            var ob = new Edge(open, bezier);
            var oa = new Edge(open, arc);
            var cr = new Edge(closed, rectangle);
            var ce = new Edge(closed, ellipse);
            var cp = new Edge(closed, polygon);

            graph.Edges.Add(so);
            graph.Edges.Add(sc);
            graph.Edges.Add(ol);
            graph.Edges.Add(ob);
            graph.Edges.Add(oa);
            graph.Edges.Add(cr);
            graph.Edges.Add(ce);
            graph.Edges.Add(cp);

            var settings = new SugiyamaLayoutSettings();

            settings.AddUpDownVerticalConstraint(closed, ellipse);
            settings.AddUpDownVerticalConstraint(open, bezier);
            settings.AddUpDownConstraint(closed, open);
            settings.AddSameLayerNeighbors(polygon, open);
            settings.AddLeftRightConstraint(closed, open);

            //To verify 444585, just turn on this following commented line
            settings.AddLeftRightConstraint(ellipse, rectangle);
            settings.AddLeftRightConstraint(ellipse, bezier);

            LayeredLayout layeredLayout = new LayeredLayout(graph, settings);

            layeredLayout.Run();

            ShowGraphInDebugViewer(graph);

            Assert.IsTrue(Math.Abs(closed.Center.X - ellipse.Center.X) < 0.01);
            Assert.IsTrue(Math.Abs(open.Center.X - bezier.Center.X) < 0.01);

            foreach (var n0 in graph.Nodes)
            {
                foreach (var n1 in graph.Nodes)
                {
                    if (n0 == n1)
                    {
                        continue;
                    }
                    Assert.IsFalse(n0.BoundingBox.Intersects(n1.BoundingBox));
                }
            }

            SugiyamaValidation.ValidateUpDownVerticalConstraint(closed, ellipse);
            SugiyamaValidation.ValidateUpDownVerticalConstraint(open, bezier);
            SugiyamaValidation.ValidateUpDownConstraint(closed, open);
            SugiyamaValidation.ValidateNeighborConstraint(graph, polygon, open, settings);
            SugiyamaValidation.ValidateLeftRightConstraint(closed, open);

            //To verify 444585, also turn on this following commented line
            //SugiyamaValidation.ValidateLeftRightConstraint(ellipse, rectangle);
            SugiyamaValidation.ValidateLeftRightConstraint(ellipse, bezier);
        }