Beispiel #1
0
        public override DirectedGraphStylingCase GetStylingCase(IEnumerable <IGraphNode> source)
        {
            DirectedGraphStylingCase output = new DirectedGraphStylingCase(setup);

            foreach (var ch in source)
            {
                Int32  tid    = GetTypeID(ch);
                Double weight = GetNodeWeight(ch);

                output.nodeStyler.learn(tid, weight);

                if (ch.parent != null)
                {
                    IGraphNode parent = ch.parent;
                    IGraphNode child  = ch;
                    if ((parent != null) && (child != null))
                    {
                        var    l_tid = GetTypeID(child);
                        Double l_w   = GetLinkWeight(parent, child);
                        output.linkStyler.learn(l_tid, l_w);

                        var cl = output.Categories.AddOrGetCategory(GetTypeID(parent), GetCategoryID(parent), "");
                        output.Categories.AddUnique(cl);
                    }
                }

                var c = output.Categories.AddOrGetCategory(GetTypeID(ch), GetCategoryID(ch), "");
                output.Categories.AddUnique(c);
            }
            return(output);
        }
        public override DirectedGraphStylingCase GetStylingCase(IEnumerable <T> nodes)
        {
            DirectedGraphStylingCase output = new DirectedGraphStylingCase(setup);

            foreach (var ch in nodes)
            {
                Int32  tid    = GetTypeID(ch);
                Double weight = GetNodeWeight(ch);

                output.nodeStyler.learn(tid, weight);

                if (ch.parent != null)
                {
                    T parent = (T)ch.parent;
                    T child  = (T)ch;
                    if ((parent != null) && (child != null))
                    {
                        var    l_tid = GetTypeID(child);
                        Double l_w   = GetLinkWeight(parent, child);
                        output.linkStyler.learn(l_tid, l_w);

                        var cl = output.Categories.AddOrGetCategory(GetTypeID(parent), GetCategoryID(parent), "");
                        output.Categories.AddUnique(cl);
                    }
                }

                Int32 cc = output.Categories.Count;

                var c = output.Categories.AddOrGetCategory(GetTypeID(ch), GetCategoryID(ch), "");

                if (cc != output.Categories.Count)
                {
                    c.Background = setup.colorWheel.next().ColorToHex();
                }
                output.Categories.AddUnique(c);
            }
            return(output);
        }
Beispiel #3
0
        //        public GraphStylerSettings setup { get; set; }

        public override DirectedGraph Convert(IGraphNode source, int depthLimit = 500, IEnumerable <IGraphNode> rootNodes = null)
        {
            DirectedGraph output = new DirectedGraph();

            if (source == null)
            {
                return(output);
            }
            output.Title = source.name;

            String description = "DirectedGraph built from " + source.GetType().Name + ":GraphNodeBase graph";

            Int32 startLevel = source.level;

            var nodes = source.getAllChildrenInType <IGraphNode>(null, false, true, 1, depthLimit);//source.getAllChildren(null, false, false, 1, depthLimit).ConvertList<IObjectWithPathAndChildren, IGraphNode>(); //.ConvertIList<IObjectWithPathAndChildren, T>();

            DirectedGraphStylingCase styleCase = GetStylingCase(nodes);

            Dictionary <String, Node> nodeDictionary = new Dictionary <string, Node>();

            foreach (IGraphNode ch in nodes)
            {
                if (ch.level > (startLevel + depthLimit))
                {
                    continue;
                }

                IGraphNode child = ch;
                var        gn    = output.Nodes.AddNode(GetNodeID(child), GetNodeLabel(child));
                gn.Label = GetNodeLabel(child);
                var    tid = GetTypeID(child);
                Double w   = GetNodeWeight(child);
                gn.Category        = styleCase.Categories.AddOrGetCategory(tid.ToString(), "", "").Id;
                gn.Background      = styleCase.nodeStyler.GetHexColor(w, tid);
                gn.StrokeThinkness = styleCase.nodeStyler.GetBorderThickness(w, tid);
                gn.Stroke          = styleCase.nodeStyler.GetHexColor(w, tid);
                SetNodeCustomization(child, gn, styleCase);
            }

            foreach (var ch in nodes)
            {
                if (ch.level > (startLevel + depthLimit))
                {
                    continue;
                }
                if (ch.parent != null)
                {
                    IGraphNode parent = ch.parent;
                    IGraphNode child  = ch;
                    if ((parent != null) && (child != null))
                    {
                        Link tmp = GetLink(parent, child);
                        tmp.Label = GetLinkLabel(parent, child);
                        var    l_tid = GetTypeID(child);
                        Double l_w   = GetLinkWeight(parent, child);
                        output.Links.Add(tmp);
                        tmp.Category        = styleCase.Categories.AddOrGetCategory(l_tid.ToString(), "", "").Id;
                        tmp.StrokeThinkness = styleCase.linkStyler.GetBorderThickness(l_w, l_tid);
                        tmp.Stroke          = styleCase.linkStyler.GetHexColor(l_w, l_tid);
                        SetLinkCustomization(parent, child, tmp, styleCase);
                    }
                }
            }

            output.Layout         = setup.GraphLayout;    // DGML.enums.GraphLayoutEnum.Sugiyama;
            output.GraphDirection = setup.GraphDirection; // DGML.enums.GraphDirectionEnum.LeftToRight;

            return(output);
        }
Beispiel #4
0
 public virtual void SetNodeCustomization(IGraphNode sourceNode, Node targetNode, DirectedGraphStylingCase styleCase)
 {
 }
Beispiel #5
0
 public virtual void SetLinkCustomization(IGraphNode parent, IGraphNode child, Link link, DirectedGraphStylingCase styleCase)
 {
 }
 public virtual void SetLinkCustomization(graphData parent, graphData child, Link link, DirectedGraphStylingCase styleCase)
 {
 }