Exemplo n.º 1
0
        internal static GeometryGraph CreateAndLayoutGraph()
        {
            double w = 30;
            double h = 20;
            GeometryGraph graph = new GeometryGraph();
            Node a = new Node( new Ellipse(w, h, new P()),"a");
            Node b = new Node( CurveFactory.CreateRectangle(w, h, new P()),"b");
            Node c = new Node( CurveFactory.CreateRectangle(w, h, new P()),"c");
            Node d = new Node(CurveFactory.CreateRectangle(w, h, new P()), "d");

            graph.Nodes.Add(a);
            graph.Nodes.Add(b);
            graph.Nodes.Add(c);
            graph.Nodes.Add(d);
            Edge e = new Edge(a, b) { Length = 10 };
            graph.Edges.Add(e);
            graph.Edges.Add(new Edge(b, c) { Length = 3 });
            graph.Edges.Add(new Edge(b, d) { Length = 4 });

            //graph.Save("c:\\tmp\\saved.msagl");
            var settings = new Microsoft.Msagl.Layout.MDS.MdsLayoutSettings();
            LayoutHelpers.CalculateLayout(graph, settings, null);

            return graph;
        }
Exemplo n.º 2
0
        /// <summary>
        /// displays the graph
        /// </summary>
        /// <param name="useCase">the use case to display</param>
        /// <returns>true, if the graph could be displayed</returns>
        public bool UpdateGraphView(UseCase useCase)
        {
            this.useCase = useCase;
            this.graph   = new Microsoft.Msagl.Drawing.Graph("graph");

            var layoutSettings = (Microsoft.Msagl.Layout.Layered.SugiyamaLayoutSettings) this.graph.LayoutAlgorithmSettings;

            layoutSettings.EdgeRoutingSettings.EdgeRoutingMode = Microsoft.Msagl.Core.Routing.EdgeRoutingMode.SplineBundling;

            // if no graph should be displayed
            if (this.useCase == null)
            {
                this.viewer.Graph = this.graph;

                return(false);
            }

            for (int n1 = 0; n1 < useCase.Nodes.Count; n1++)
            {
                for (int n2 = 0; n2 < useCase.Nodes.Count; n2++)
                {
                    if (IsConnected(n1, n2, useCase))
                    {
                        this.GenerateNodes(n1, n2, useCase);
                    }
                }
            }

            var layout = new Microsoft.Msagl.Layout.MDS.MdsLayoutSettings();

            this.viewer.Graph     = this.graph;
            this.initialTransform = this.GetTransformMatrix();

            return(true);
        }
Exemplo n.º 3
0
        private static void LayoutGraph(GeometryGraph geometryGraph)
        {
            var settings = new Microsoft.Msagl.Layout.MDS.MdsLayoutSettings();

            settings.EdgeRoutingSettings.EdgeRoutingMode = Microsoft.Msagl.Core.Routing.EdgeRoutingMode.StraightLine;
            LayoutHelpers.CalculateLayout(geometryGraph, settings, null);
            Console.WriteLine("layout done");
        }
Exemplo n.º 4
0
        static internal GeometryGraph CreateAndLayoutGraph()
        {
            double        w     = 30;
            double        h     = 20;
            GeometryGraph graph = new GeometryGraph();
            Node          a     = new Node(new Ellipse(w, h, new P()), "a");
            Node          b     = new Node(CurveFactory.CreateRectangle(w, h, new P()), "b");
            Node          c     = new Node(CurveFactory.CreateRectangle(w, h, new P()), "c");
            Node          d     = new Node(CurveFactory.CreateRectangle(w, h, new P()), "d");

            graph.Nodes.Add(a);
            graph.Nodes.Add(b);
            graph.Nodes.Add(c);
            graph.Nodes.Add(d);
            Edge e = new Edge(a, b)
            {
                Length = 10
            };

            graph.Edges.Add(e);
            graph.Edges.Add(new Edge(b, c)
            {
                Length = 3
            });
            graph.Edges.Add(new Edge(b, d)
            {
                Length = 4
            });

            //graph.Save("c:\\tmp\\saved.msagl");
            var settings = new Microsoft.Msagl.Layout.MDS.MdsLayoutSettings();

            LayoutHelpers.CalculateLayout(graph, settings, null);

            return(graph);
        }