internal static GeometryGraph CreateAndLayoutGraph()
        {
            double        w     = 40;
            double        h     = 10;
            GeometryGraph graph = new GeometryGraph();
            // columns
            var col0 = new[] { "a", "b", "c" };
            var col1 = new[] { "d", "e", "f", "g" };
            var col2 = new[] { "k", "l", "m", "n" };
            var col3 = new[] { "w", "y", "z" };

            var settings = new SugiyamaLayoutSettings();

            foreach (var id in col0)
            {
                DrawingUtilsForSamples.AddNode(id, graph, w, h);
            }
            foreach (var id in col1)
            {
                DrawingUtilsForSamples.AddNode(id, graph, w, h);
            }
            foreach (var id in col2)
            {
                DrawingUtilsForSamples.AddNode(id, graph, w, h);
            }
            foreach (var id in col3)
            {
                DrawingUtilsForSamples.AddNode(id, graph, w, h);
            }

            //pinning columns
            settings.PinNodesToSameLayer(col0.Select(s => graph.FindNodeByUserData(s)).ToArray());
            settings.PinNodesToSameLayer(col1.Select(s => graph.FindNodeByUserData(s)).ToArray());
            settings.PinNodesToSameLayer(col2.Select(s => graph.FindNodeByUserData(s)).ToArray());
            settings.PinNodesToSameLayer(col3.Select(s => graph.FindNodeByUserData(s)).ToArray());

            AddEdgesBetweenColumns(col0, col1, graph);
            AddEdgesBetweenColumns(col1, col2, graph);
            AddEdgesBetweenColumns(col2, col3, graph);
            // rotate layer to columns
            settings.Transformation  = PlaneTransformation.Rotation(Math.PI / 2);
            settings.NodeSeparation  = 5;
            settings.LayerSeparation = 100;
            var ll = new LayeredLayout(graph, settings);

            ll.Run();
            return(graph);
        }
Beispiel #2
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);
     }
 }