Exemplo n.º 1
0
        internal static DGraph CreateDGraphAndGeometryInfo(DrawingGraph drawingGraph, GeometryGraph gleeGraph)
        {
            DGraph ret = new DGraph(drawingGraph);

            //create dnodes and glee node boundary curves
            foreach (GeometryNode geomNode in gleeGraph.NodeMap.Values)
            {
                DrawingNode drawingNode = geomNode.UserData as DrawingNode;
                CreateDNodeAndSetNodeBoundaryCurve(drawingGraph, ret, geomNode, drawingNode);
            }

            foreach (GeometryEdge gleeEdge in gleeGraph.Edges)
            {
                DEdge dEdge = new DEdge(ret.GetNode(gleeEdge.Source), ret.GetNode(gleeEdge.Target), gleeEdge.UserData as DrawingEdge, Connection.Connected);
                ret.AddEdge(dEdge);
                DrawingEdge drawingEdge             = dEdge.Edge;
                Microsoft.Msagl.Drawing.Label label = drawingEdge.Label;

                if (label != null)
                {
                    double width, height;
                    CreateDLabel(dEdge, label, out width, out height);
                }
            }

            return(ret);
        }
Exemplo n.º 2
0
        /// <summary>
        /// creates DGraph from a precalculated drawing graph
        /// </summary>
        /// <param name="drawingGraph"></param>
        /// <returns></returns>
        internal static DGraph CreateDGraphFromPrecalculatedDrawingGraph(DrawingGraph drawingGraph)
        {
            DGraph ret = new DGraph(drawingGraph);

            //create dnodes and node boundary curves
            foreach (DrawingNode drawingNode in drawingGraph.NodeMap.Values)
            {
                DNode dNode = new DNode(drawingNode);
                if (drawingNode.Label != null)
                {
                    dNode.Label = new DLabel(dNode, drawingNode.Label);
                }
                ret.AddNode(dNode);
            }

            foreach (DrawingEdge drawingEdge in drawingGraph.Edges)
            {
                ret.AddEdge(new DEdge(ret.GetNode(drawingEdge.SourceNode), ret.GetNode(drawingEdge.TargetNode), drawingEdge, Connection.Connected));
            }

            return(ret);
        }
Exemplo n.º 3
0
        /// <summary>
        /// creates DGraph from a precalculated drawing graph
        /// </summary>
        /// <param name="drawingGraph"></param>
        /// <param name="viewer">the owning viewer</param>
        /// <returns></returns>
        internal static DGraph CreateDGraphFromPrecalculatedDrawingGraph(Graph drawingGraph, GViewer viewer)
        {
            var dGraph = new DGraph(drawingGraph, viewer);

            //create dnodes and node boundary curves

            if (drawingGraph.RootSubgraph != null)
            {
                foreach (DrawingNode drawingNode in drawingGraph.RootSubgraph.AllSubgraphsWidthFirstExcludingSelf())
                {
                    var dNode = new DNode(drawingNode, viewer);
                    if (drawingNode.Label != null)
                    {
                        dNode.Label = new DLabel(dNode, drawingNode.Label, viewer);
                    }
                    dGraph.AddNode(dNode);
                }
            }

            foreach (DrawingNode drawingNode in drawingGraph.Nodes)
            {
                var dNode = new DNode(drawingNode, viewer);
                if (drawingNode.Label != null)
                {
                    dNode.Label = new DLabel(dNode, drawingNode.Label, viewer);
                }
                dGraph.AddNode(dNode);
            }


            foreach (DrawingEdge drawingEdge in drawingGraph.Edges)
            {
                dGraph.AddEdge(new DEdge(dGraph.GetNode(drawingEdge.SourceNode), dGraph.GetNode(drawingEdge.TargetNode),
                                         drawingEdge, ConnectionToGraph.Connected, viewer));
            }

            return(dGraph);
        }
Exemplo n.º 4
0
        /// <summary>
        /// creates DGraph from a precalculated drawing graph
        /// </summary>
        /// <param name="drawingGraph"></param>
        /// <param name="viewer">the owning viewer</param>
        /// <returns></returns>
        internal static DGraph CreateDGraphFromPrecalculatedDrawingGraph(Graph drawingGraph, GViewer viewer){
            var dGraph = new DGraph(drawingGraph, viewer);
            //create dnodes and node boundary curves

            if (drawingGraph.RootSubgraph != null)
                foreach (DrawingNode drawingNode in drawingGraph.RootSubgraph.AllSubgraphsWidthFirstExcludingSelf())
                {
                    var dNode = new DNode(drawingNode, viewer);
                    if (drawingNode.Label != null)
                        dNode.Label = new DLabel(dNode, drawingNode.Label, viewer);
                    dGraph.AddNode(dNode);
                }

            foreach (DrawingNode drawingNode in drawingGraph.Nodes){
                var dNode = new DNode(drawingNode, viewer);
                if (drawingNode.Label != null)
                    dNode.Label = new DLabel(dNode, drawingNode.Label, viewer);
                dGraph.AddNode(dNode);
            }

            
            foreach (DrawingEdge drawingEdge in drawingGraph.Edges)
                dGraph.AddEdge(new DEdge(dGraph.GetNode(drawingEdge.SourceNode), dGraph.GetNode(drawingEdge.TargetNode),
                                      drawingEdge, ConnectionToGraph.Connected, viewer));

            return dGraph;
        }