Ejemplo n.º 1
0
        static RulesEngineGraphGenerator()
        {
            Color defaultBg = Color.Black;

            _bg = new DictionaryCache <Type, Color>(key => defaultBg)
            {
                { typeof(AlphaNode <>), Color.Yellow },
                { typeof(WidenTypeNode <,>), Color.DarkKhaki },
                { typeof(PropertyNode <, ,>), Color.Red },
                { typeof(EachNode <, ,>), Color.Red },
                { typeof(EqualNode <,>), Color.Blue },
                { typeof(ValueNode <,>), Color.Blue },
                { typeof(CompareNode <,>), Color.Blue },
                { typeof(NotNullNode <,>), Color.Blue },
                { typeof(ExistsNode <,>), Color.Blue },
                { typeof(JoinNode <>), Color.Green },
                { typeof(OuterJoinNode <,>), Color.Green },
                { typeof(LeftJoinNode <,>), Color.LightGreen },
                { typeof(ConditionNode <>), Color.Blue },
                { typeof(DelegateProductionNode <>), Color.LightGray },
                { typeof(AddFactNode <,>), Color.LightGray },
                { typeof(ConstantNode <>), Color.Magenta },
            };

            Color defaultFg = Color.White;

            _fg = new DictionaryCache <Type, Color>(key => defaultFg)
            {
                { typeof(AlphaNode <>), Color.Black },
                { typeof(WidenTypeNode <,>), Color.Black },
                { typeof(PropertyNode <, ,>), Color.White },
                { typeof(EachNode <, ,>), Color.White },
                { typeof(EqualNode <,>), Color.White },
                { typeof(ValueNode <,>), Color.White },
                { typeof(CompareNode <,>), Color.White },
                { typeof(NotNullNode <,>), Color.White },
                { typeof(ExistsNode <,>), Color.White },
                { typeof(JoinNode <>), Color.White },
                { typeof(OuterJoinNode <,>), Color.White },
                { typeof(LeftJoinNode <,>), Color.Black },
                { typeof(ConditionNode <>), Color.White },
                { typeof(DelegateProductionNode <>), Color.Black },
                { typeof(AddFactNode <,>), Color.Black },
                { typeof(ConstantNode <>), Color.Black },
            };

            Shape defaultShape = Shape.Ellipse;

            _shape = new DictionaryCache <Type, Shape>(key => defaultShape)
            {
                { typeof(RulesEngine), Shape.Ellipse },
                { typeof(AlphaNode <>), Shape.Ellipse },
                { typeof(WidenTypeNode <,>), Shape.Circle },
                { typeof(ConstantNode <>), Shape.Circle },
                { typeof(JoinNode <>), Shape.Ellipse },
                { typeof(OuterJoinNode <,>), Shape.Ellipse },
                { typeof(LeftJoinNode <,>), Shape.Ellipse },
                { typeof(DelegateProductionNode <>), Shape.DoubleCircle },
            };
        }
Ejemplo n.º 2
0
        protected void UpdateNodeColor(object node, Color color)
        {
            if (node == null)
            {
                return;
            }

            GD.Color gcolor = new GD.Color(color.A, color.R, color.G, color.B);
            ((GD.Node)node).Attr.Fillcolor = gcolor;
        }
Ejemplo n.º 3
0
        protected object AddEdge(string idFrom, string idTo, EdgeStyle edgeStyle, Color color)
        {
            GD.Edge edge = (GD.Edge)AddEdge(idFrom, idTo, edgeStyle);
            if (edge == null)
            {
                return(null);
            }

            GD.Color gcolor = new GD.Color(color.A, color.R, color.G, color.B);
            edge.Attr.Color = gcolor;

            return(edge);
        }
Ejemplo n.º 4
0
        void NodeStyler(object sender, GleeVertexEventArgs <Vertex> args)
        {
            Color color = _bg[args.Vertex.VertexType];

            args.Node.Attr.Fillcolor = color;

            args.Node.Attr.Shape     = _shape[args.Vertex.VertexType];
            args.Node.Attr.Fontcolor = _fg[args.Vertex.VertexType];
            args.Node.Attr.Fontsize  = 8;
            args.Node.Attr.FontName  = "Arial";
            args.Node.Attr.Label     = args.Vertex.Title;
            args.Node.Attr.Padding   = 1.1;
        }
Ejemplo n.º 5
0
        void NodeStyler(object sender, GleeVertexEventArgs <Vertex> args)
        {
            Microsoft.Glee.Drawing.Color color = GetVertexColor(args.Vertex.VertexType);

            args.Node.Attr.Fillcolor = color;

            args.Node.Attr.Shape     = Shape.Box;
            args.Node.Attr.Fontcolor = Microsoft.Glee.Drawing.Color.White;
            args.Node.Attr.Fontsize  = 8;
            args.Node.Attr.FontName  = "Arial";
            args.Node.Attr.Label     = args.Vertex.Title;
            args.Node.Attr.Padding   = 1.2;
        }
Ejemplo n.º 6
0
        protected object AddNode(string id, string caption, Color color, BaseItem item, bool allowDuplicates)
        {
            if (_ignoreSidePanelItems && _sidePanel.Lookup(id))
            {
                return(null);
            }

            GD.Node node = null;

            if (_addedNodes.ContainsKey(id))
            {
                if (allowDuplicates)
                {
                    node = (GD.Node)_addedNodes[id];

                    if (node.UserData is BaseItem)
                    {
                        List <BaseItem> list = new List <BaseItem>();
                        list.Add((BaseItem)node.UserData);
                        list.Add(item);
                        node.UserData = list;
                    }
                    else if (node.UserData is List <BaseItem> )
                    {
                        List <BaseItem> list = node.UserData as List <BaseItem>;
                        list.Add(item);
                    }
                    else
                    {
                        _logView.Debug("AddNode reports invalid UserData");
                    }
                }
            }
            else
            {
                // NB Don't add it to the graph yet.
                node = new GD.Node(id);

                node.UserData   = (object)item;
                node.Attr.Label = caption;

                GD.Color gcolor = new GD.Color(color.A, color.R, color.G, color.B);
                node.Attr.Fillcolor = gcolor;

                _addedNodes.Add(id, node);
            }

            return(node);
        }
Ejemplo n.º 7
0
        private bool Hilite(GD.Node node)
        {
            bool result = false;

            if (_hiliteNodes.ContainsKey(node))
            {
                return(result);
            }

            _hiliteNodes.Add(node, new AffectedNode(node.Attr.Color, node.Attr.Fillcolor, node.Attr.Fontcolor));

            Color color = _options.HiliteColor;

            GD.Color gcolor = new GD.Color(color.A, color.R, color.G, color.B);
            node.Attr.Fillcolor = gcolor;

            color  = _options.HiliteLineColor;
            gcolor = new GD.Color(color.A, color.R, color.G, color.B);

            // We need access to the builder here :/
            if (_activeItem != null && _builders.ContainsKey(_activeItem))
            {
                BaseGraphBuilder builder = _builders[_activeItem];
                foreach (KeyValuePair <string, List <object> > pair in builder.AddedEdges)
                {
                    foreach (GD.Edge edge in pair.Value)
                    {
                        if (edge.Source == node.Id || edge.Target == node.Id)
                        {
                            // Abuse the userdata to hang onto the old color.
                            edge.UserData   = new AffectedEdge(edge.Attr.Color);
                            edge.Attr.Color = gcolor;
                        }
                    }
                }
                result = true;
            }
            return(result);
        }
Ejemplo n.º 8
0
        private bool Hilite(GD.Node node)
        {
            bool result = false;

            if (_hiliteNodes.ContainsKey(node)) return result;

            _hiliteNodes.Add(node, new AffectedNode(node.Attr.Color, node.Attr.Fillcolor, node.Attr.Fontcolor));

            Color color = _options.HiliteColor;
            GD.Color gcolor = new GD.Color(color.A, color.R, color.G, color.B);
            node.Attr.Fillcolor = gcolor;

            color = _options.HiliteLineColor;
            gcolor = new GD.Color(color.A, color.R, color.G, color.B);

            // We need access to the builder here :/
            if (_activeItem != null && _builders.ContainsKey(_activeItem))
            {
                BaseGraphBuilder builder = _builders[_activeItem];
                foreach (KeyValuePair<string, List<object>> pair in builder.AddedEdges)
                {
                    foreach (GD.Edge edge in pair.Value)
                    {
                        if (edge.Source == node.Id || edge.Target == node.Id)
                        {
                            // Abuse the userdata to hang onto the old color.
                            edge.UserData = new AffectedEdge(edge.Attr.Color);
                            edge.Attr.Color = gcolor;
                        }
                    }
                }
                result = true;
            }
            return result;
        }
Ejemplo n.º 9
0
 internal AffectedNode(GD.Color color, GD.Color fillColor, GD.Color fontColor)
 {
     Color = color;
     FillColor = fillColor;
     FontColor = fontColor;
 }
Ejemplo n.º 10
0
 internal AffectedEdge(GD.Color color)
 {
     Color = color;
 }
Ejemplo n.º 11
0
        protected void UpdateNodeColor(object node, Color color)
        {
            if (node == null) return;

            GD.Color gcolor = new GD.Color(color.A, color.R, color.G, color.B);
            ((GD.Node)node).Attr.Fillcolor = gcolor;
        }
Ejemplo n.º 12
0
        protected object AddNode(string id, string caption, Color color, BaseItem item, bool allowDuplicates)
        {
            if (_ignoreSidePanelItems && _sidePanel.Lookup(id)) return null;

            GD.Node node = null;

            if (_addedNodes.ContainsKey(id))
            {
                if (allowDuplicates)
                {
                    node = (GD.Node)_addedNodes[id];

                    if (node.UserData is BaseItem)
                    {
                        List<BaseItem> list = new List<BaseItem>();
                        list.Add((BaseItem)node.UserData);
                        list.Add(item);
                        node.UserData = list;
                    }
                    else if (node.UserData is List<BaseItem>)
                    {
                        List<BaseItem> list = node.UserData as List<BaseItem>;
                        list.Add(item);
                    }
                    else _logView.Debug("AddNode reports invalid UserData");
                }
            }
            else
            {
                // NB Don't add it to the graph yet.
                node = new GD.Node(id);

                node.UserData = (object)item;
                node.Attr.Label = caption;

                GD.Color gcolor = new GD.Color(color.A, color.R, color.G, color.B);
                node.Attr.Fillcolor = gcolor;

                _addedNodes.Add(id, node);
            }

            return node;
        }
Ejemplo n.º 13
0
        protected object AddEdge(string idFrom, string idTo, EdgeStyle edgeStyle, Color color)
        {
            GD.Edge edge = (GD.Edge)AddEdge(idFrom, idTo, edgeStyle);
            if (edge == null) return null;

            GD.Color gcolor = new GD.Color(color.A, color.R, color.G, color.B);
            edge.Attr.Color = gcolor;

            return edge;
        }
Ejemplo n.º 14
0
 internal AffectedEdge(GD.Color color)
 {
     Color = color;
 }
Ejemplo n.º 15
0
 internal AffectedNode(GD.Color color, GD.Color fillColor, GD.Color fontColor)
 {
     Color     = color;
     FillColor = fillColor;
     FontColor = fontColor;
 }