Esempio n. 1
0
 internal void ChangeNodeTextColor(ElementMode mode, GrColor textColor)
 {
     nodeRealizers[(int)mode] = GetNodeRealizer(
         nodeRealizers[(int)mode].Color,
         nodeRealizers[(int)mode].BorderColor,
         textColor,
         nodeRealizers[(int)mode].Shape);
 }
Esempio n. 2
0
 public NodeRealizer(String name, GrColor color, GrColor borderColor, GrColor textColor, GrNodeShape shape)
 {
     Name        = name;
     Color       = color;
     BorderColor = borderColor;
     TextColor   = textColor;
     Shape       = shape;
 }
Esempio n. 3
0
 public EdgeRealizer(String name, GrColor color, GrColor textColor, int lineWidth, GrLineStyle lineStyle)
 {
     Name      = name;
     Color     = color;
     TextColor = textColor;
     LineWidth = lineWidth;
     LineStyle = lineStyle;
 }
Esempio n. 4
0
 internal void ChangeEdgeTextColor(ElementMode mode, GrColor textColor)
 {
     edgeRealizers[(int)mode] = GetEdgeRealizer(
         edgeRealizers[(int)mode].Color,
         textColor,
         edgeRealizers[(int)mode].LineWidth,
         edgeRealizers[(int)mode].LineStyle);
 }
Esempio n. 5
0
 /// <summary>
 /// Gets the VCG string representation of a GrColor object.
 /// </summary>
 /// <param name="color">The GrColor object.</param>
 /// <returns>The VCG string representation of <c>color</c>.</returns>
 public static String GetColor(GrColor color)
 {
     if ((uint)color >= colors.Length)
     {
         return(colors[0]);
     }
     else
     {
         return(colors[(int)color]);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Dump an edge to the VCG graph
        /// </summary>
        /// <param name="srcNode">The source node of the edge</param>
        /// <param name="tgtNode">The target node of the edge</param>
        /// <param name="label">The label of the edge, may be null</param>
        /// <param name="attributes">An enumerable of attribute strings</param>
        /// <param name="textColor">The color of the text</param>
        /// <param name="edgeColor">The color of the edge</param>
        /// <param name="lineStyle">The linestyle of the edge</param>
        /// <param name="thickness">The thickness of the edge (1-5)</param>
        ///
        /// TODO: Check whether GetHashCode should really be used or better Graph.GetElementName()
        ///
        public void DumpEdge(INode srcNode, INode tgtNode, String label, IEnumerable <String> attributes,
                             GrColor textColor, GrColor edgeColor, GrLineStyle lineStyle, int thickness)
        {
            Indent();
            sw.Write("edge:{{sourcename:\"n{0}\" targetname:\"n{1}\"", srcNode.GetHashCode(), tgtNode.GetHashCode());

            String attrStr = "";

            if (attributes != null && attributes.GetEnumerator().MoveNext())
            {
                StringBuilder attrStrBuilder = new StringBuilder("\nAttributes:");
                bool          first          = true;
//                indent++;
                foreach (String attr in attributes)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        attrStrBuilder.Append('\n');
                    }
                    attrStrBuilder.Append(EncodeString(attr));
                }
//                indent--;
//                sw.Write('\"');
                attrStr = attrStrBuilder.ToString();
            }

            if (label != null)
            {
                sw.Write(" label:\"" + label + attrStr + "\"");
            }
            if (textColor != GrColor.Default)
            {
                sw.Write(" textcolor:" + GetColor(textColor));
            }
            if (edgeColor != GrColor.Default)
            {
                sw.Write(" color:" + GetColor(edgeColor));
            }
            if (lineStyle != GrLineStyle.Default)
            {
                sw.Write(" linestyle:" + GetLineStyle(lineStyle));
            }
            if (thickness != 1)
            {
                sw.Write(" thickness:" + thickness);
            }
            sw.WriteLine('}');
        }
Esempio n. 7
0
 /// <summary>
 /// Dump a node to the VCG graph.
 /// </summary>
 /// <param name="node">The node to be dumped.</param>
 /// <param name="label">The label to use for the node.</param>
 /// <param name="attributes">An enumerable of attribute strings.</param>
 /// <param name="textColor">The color of the text.</param>
 /// <param name="nodeColor">The color of the node border.</param>
 /// <param name="borderColor">The color of the node.</param>
 /// <param name="nodeShape">The shape of the node.</param>
 ///
 /// TODO: Check whether GetHashCode should really be used or better Graph.GetElementName()
 ///
 public void DumpNode(INode node, String label, IEnumerable <String> attributes, GrColor textColor,
                      GrColor nodeColor, GrColor borderColor, GrNodeShape nodeShape)
 {
     Indent();
     sw.Write("node:{{title:\"n{0}\"", node.GetHashCode());
     if (label != null)
     {
         sw.Write(" label:\"{0}\"", label);
     }
     if (textColor != GrColor.Default)
     {
         sw.Write(" textcolor:" + GetColor(textColor));
     }
     if (nodeColor != GrColor.White)
     {
         sw.Write(" color:" + GetColor(nodeColor));
     }
     if (borderColor != textColor)
     {
         sw.Write(" bordercolor:" + GetColor(borderColor));
     }
     if (nodeShape != GrNodeShape.Default)
     {
         sw.Write(" shape:" + GetNodeShape(nodeShape));
     }
     if (attributes != null)
     {
         sw.Write(" info1: \"");
         bool first = true;
         indent++;
         foreach (String attr in attributes)
         {
             if (first)
             {
                 first = false;
             }
             else
             {
                 sw.WriteLine();
                 Indent();
             }
             sw.Write(EncodeString(attr));
         }
         indent--;
         sw.Write('\"');
     }
     sw.WriteLine('}');
 }
Esempio n. 8
0
        /// <summary>
        /// Creates a new sub-graph to the DOT graph
        /// </summary>
        /// <param name="node">The node starting the new sub-graph</param>
        /// <param name="label">The label to use for the node</param>
        /// <param name="attributes">An enumerable of attribute strings</param>
        /// <param name="textColor">The color of the text</param>
        /// <param name="subgraphColor">The color of the subgraph node</param>
        /// TODO: Check whether GetHashCode should really be used or better Graph.GetElementName()
        public void StartSubgraph(INode node, string label, IEnumerable <String> attributes, GrColor textColor,
                                  GrColor subgraphColor)
        {
            groupNodesToCharacteristicContainedNode.Add(node, null);
            groupNesting.Push(node);

            WriteIndentation();
            sw.Write("subgraph cluster{0} {{", node.GetHashCode());

            if (label != null)
            {
                sw.Write(" label=\"{0}\";", label);
            }
            if (textColor != GrColor.Default)
            {
                sw.Write(" fontcolor=" + GetColor(textColor) + ";");
            }
            if (subgraphColor != textColor)
            {
                sw.Write(" fillcolor=" + GetColor(subgraphColor) + "; style=filled;");
            }
            if (attributes != null)
            {
                sw.Write(" tooltip=\"");
                bool first = true;
                Indent();
                foreach (String attr in attributes)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        sw.WriteLine();
                        WriteIndentation();
                    }
                    sw.Write(EncodeString(attr));
                }
                Unindent();
                sw.Write('\"');
            }
            sw.WriteLine(";");
            Indent();
        }
Esempio n. 9
0
        String GetEdgeRealizer(GrColor edgeColor, GrColor textColor, int lineWidth, GrLineStyle lineStyle)
        {
            EdgeRealizer newEr = new EdgeRealizer("er" + nextEdgeRealizerID, edgeColor, textColor, lineWidth, lineStyle);

            EdgeRealizer er;

            if (!edgeRealizers.TryGetValue(newEr, out er))
            {
                ycompStream.Write("addEdgeRealizer \"" + newEr.Name + "\" \""
                                  + VCGDumper.GetColor(newEr.Color) + "\" \""
                                  + VCGDumper.GetColor(newEr.TextColor) + "\" \""
                                  + lineWidth + "\" \"continuous\"\n");
                edgeRealizers.Add(newEr, newEr);
                nextEdgeRealizerID++;
                er = newEr;
            }
            return(er.Name);
        }
Esempio n. 10
0
        String GetNodeRealizer(GrColor nodeColor, GrColor borderColor, GrColor textColor, GrNodeShape shape)
        {
            NodeRealizer newNr = new NodeRealizer("nr" + nextNodeRealizerID, nodeColor, borderColor, textColor, shape);

            NodeRealizer nr;

            if (!nodeRealizers.TryGetValue(newNr, out nr))
            {
                ycompStream.Write("addNodeRealizer \"" + newNr.Name + "\" \""
                                  + VCGDumper.GetColor(borderColor) + "\" \""
                                  + VCGDumper.GetColor(nodeColor) + "\" \""
                                  + VCGDumper.GetColor(textColor) + "\" \""
                                  + VCGDumper.GetNodeShape(shape) + "\"\n");
                nodeRealizers.Add(newNr, newNr);
                nextNodeRealizerID++;
                nr = newNr;
            }
            return(nr.Name);
        }
Esempio n. 11
0
 /// <summary>
 /// Creates a new sub-graph to the VCG graph
 /// </summary>
 /// <param name="node">The node starting the new sub-graph</param>
 /// <param name="label">The label to use for the node</param>
 /// <param name="attributes">An enumerable of attribute strings</param>
 /// <param name="textColor">The color of the text</param>
 /// <param name="subgraphColor">The color of the subgraph node</param>
 /// TODO: Check whether GetHashCode should really be used or better Graph.GetElementName()
 public void StartSubgraph(INode node, string label, IEnumerable <String> attributes, GrColor textColor,
                           GrColor subgraphColor)
 {
     Indent();
     sw.Write("graph:{{title:\"n{0}\"", node.GetHashCode());
     if (label != null)
     {
         sw.Write(" label:\"{0}\" status:clustered", label);
     }
     if (textColor != GrColor.Default)
     {
         sw.Write(" textcolor:" + GetColor(textColor));
     }
     if (subgraphColor != textColor)
     {
         sw.Write(" color:" + GetColor(subgraphColor));
     }
     if (attributes != null)
     {
         sw.Write(" info1: \"");
         bool first = true;
         indent++;
         foreach (String attr in attributes)
         {
             if (first)
             {
                 first = false;
             }
             else
             {
                 sw.WriteLine();
                 Indent();
             }
             sw.Write(EncodeString(attr));
         }
         indent--;
         sw.Write('\"');
     }
     sw.WriteLine();
     indent++;
 }
Esempio n. 12
0
        private NodeRealizer GetNodeRealizer(GrColor nodeColor, GrColor borderColor, GrColor textColor, GrNodeShape shape)
        {
            NodeRealizer newNr = new NodeRealizer("nr" + nextNodeRealizerID, nodeColor, borderColor, textColor, shape);

            NodeRealizer nr;

            if (!registeredNodeRealizers.TryGetValue(newNr, out nr))
            {
                if (ycompStream != null)
                {
                    ycompStream.Write("addNodeRealizer \"" + newNr.Name + "\" \""
                                      + VCGDumper.GetColor(borderColor) + "\" \""
                                      + VCGDumper.GetColor(nodeColor) + "\" \""
                                      + VCGDumper.GetColor(textColor) + "\" \""
                                      + VCGDumper.GetNodeShape(shape) + "\"\n");
                }
                registeredNodeRealizers.Add(newNr, newNr);
                ++nextNodeRealizerID;
                nr = newNr;
            }
            return(nr);
        }
Esempio n. 13
0
        private EdgeRealizer GetEdgeRealizer(GrColor edgeColor, GrColor textColor, int lineWidth, GrLineStyle lineStyle)
        {
            EdgeRealizer newEr = new EdgeRealizer("er" + nextEdgeRealizerID, edgeColor, textColor, lineWidth, lineStyle);

            EdgeRealizer er;

            if (!registeredEdgeRealizers.TryGetValue(newEr, out er))
            {
                if (ycompStream != null)
                {
                    ycompStream.Write("addEdgeRealizer \"" + newEr.Name + "\" \""
                                      + VCGDumper.GetColor(newEr.Color) + "\" \""
                                      + VCGDumper.GetColor(newEr.TextColor) + "\" \""
                                      + lineWidth + "\" \""
                                      + VCGDumper.GetLineStyle(newEr.LineStyle) + "\"\n");
                }
                registeredEdgeRealizers.Add(newEr, newEr);
                ++nextEdgeRealizerID;
                er = newEr;
            }
            return(er);
        }
Esempio n. 14
0
 public void SetEdgeTypeTextColor(EdgeType edgeType, GrColor color)
 {
     edgeTypeTextColors[edgeType] = color;           // overwrites existing mapping
     EdgeTypeAppearanceChanged(edgeType);
 }
Esempio n. 15
0
 public void SetNodeTypeTextColor(NodeType nodeType, GrColor color)
 {
     nodeTypeTextColors[nodeType] = color;           // overwrites existing mapping
     NodeTypeAppearanceChanged(nodeType);
 }
Esempio n. 16
0
 /// <summary>
 /// Gets the VCG string representation of a GrColor object.
 /// </summary>
 /// <param name="color">The GrColor object.</param>
 /// <returns>The VCG string representation of <c>color</c>.</returns>
 public static String GetColor(GrColor color)
 {
     if((uint) color >= colors.Length) return colors[0];
     else return colors[(int) color];
 }
Esempio n. 17
0
 /// <summary>
 /// Dump a node to the VCG graph.
 /// </summary>
 /// <param name="node">The node to be dumped.</param>
 /// <param name="label">The label to use for the node.</param>
 /// <param name="attributes">An enumerable of attribute strings.</param>
 /// <param name="textColor">The color of the text.</param>
 /// <param name="nodeColor">The color of the node border.</param>
 /// <param name="borderColor">The color of the node.</param>
 /// <param name="nodeShape">The shape of the node.</param>
 ///
 /// TODO: Check whether GetHashCode should really be used or better Graph.GetElementName()
 ///
 public void DumpNode(INode node, String label, IEnumerable<String> attributes, GrColor textColor,
     GrColor nodeColor, GrColor borderColor, GrNodeShape nodeShape)
 {
     Indent();
     sw.Write("node:{{title:\"n{0}\"", node.GetHashCode());
     if(label != null) sw.Write(" label:\"{0}\"", label);
     if(textColor != GrColor.Default) sw.Write(" textcolor:" + GetColor(textColor));
     if(nodeColor != GrColor.White) sw.Write(" color:" + GetColor(nodeColor));
     if(borderColor != textColor) sw.Write(" bordercolor:" + GetColor(borderColor));
     if(nodeShape != GrNodeShape.Default) sw.Write(" shape:" + GetNodeShape(nodeShape));
     if(attributes != null)
     {
         sw.Write(" info1: \"");
         bool first = true;
         indent++;
         foreach(String attr in attributes)
         {
             if(first) first = false;
             else
             {
                 sw.WriteLine();
                 Indent();
             }
             sw.Write(EncodeString(attr));
         }
         indent--;
         sw.Write('\"');
     }
     sw.WriteLine('}');
 }
Esempio n. 18
0
        /// <summary>
        /// Dump an edge to the VCG graph
        /// </summary>
        /// <param name="srcNode">The source node of the edge</param>
        /// <param name="tgtNode">The target node of the edge</param>
        /// <param name="label">The label of the edge, may be null</param>
        /// <param name="attributes">An enumerable of attribute strings</param>
        /// <param name="textColor">The color of the text</param>
        /// <param name="edgeColor">The color of the edge</param>
        /// <param name="lineStyle">The linestyle of the edge</param>
        /// <param name="thickness">The thickness of the edge (1-5)</param>
        ///
        /// TODO: Check whether GetHashCode should really be used or better Graph.GetElementName()
        ///
        public void DumpEdge(INode srcNode, INode tgtNode, String label, IEnumerable<String> attributes,
            GrColor textColor, GrColor edgeColor, GrLineStyle lineStyle, int thickness)
        {
            Indent();
            sw.Write("edge:{{sourcename:\"n{0}\" targetname:\"n{1}\"", srcNode.GetHashCode(), tgtNode.GetHashCode());

            String attrStr = "";
            if(attributes != null && attributes.GetEnumerator().MoveNext())
            {
                StringBuilder attrStrBuilder = new StringBuilder("\nAttributes:");
                bool first = true;
//                indent++;
                foreach(String attr in attributes)
                {
                    if(first) first = false;
                    else
                    {
                        attrStrBuilder.Append('\n');
                    }
                    attrStrBuilder.Append(EncodeString(attr));
                }
//                indent--;
//                sw.Write('\"');
                attrStr = attrStrBuilder.ToString();
            }

            if(label != null) sw.Write(" label:\"" + label + attrStr + "\"");
            if(textColor != GrColor.Default) sw.Write(" textcolor:" + GetColor(textColor));
            if(edgeColor != GrColor.Default) sw.Write(" color:" + GetColor(edgeColor));
            if(lineStyle != GrLineStyle.Default) sw.Write(" linestyle:" + GetLineStyle(lineStyle));
            if(thickness != 1) sw.Write(" thickness:" + thickness);
            sw.WriteLine('}');
        }
Esempio n. 19
0
 /// <summary>
 /// Creates a new sub-graph to the VCG graph
 /// </summary>
 /// <param name="node">The node starting the new sub-graph</param>
 /// <param name="label">The label to use for the node</param>
 /// <param name="attributes">An enumerable of attribute strings</param>
 /// <param name="textColor">The color of the text</param>
 /// <param name="subgraphColor">The color of the subgraph node</param>
 /// TODO: Check whether GetHashCode should really be used or better Graph.GetElementName()
 public void StartSubgraph(INode node, string label, IEnumerable<String> attributes, GrColor textColor,
     GrColor subgraphColor)
 {
     Indent();
     sw.Write("graph:{{title:\"n{0}\"", node.GetHashCode());
     if(label != null) sw.Write(" label:\"{0}\" status:clustered", label);
     if(textColor != GrColor.Default) sw.Write(" textcolor:" + GetColor(textColor));
     if(subgraphColor != textColor) sw.Write(" color:" + GetColor(subgraphColor));
     if(attributes != null)
     {
         sw.Write(" info1: \"");
         bool first = true;
         indent++;
         foreach(String attr in attributes)
         {
             if(first) first = false;
             else
             {
                 sw.WriteLine();
                 Indent();
             }
             sw.Write(EncodeString(attr));
         }
         indent--;
         sw.Write('\"');
     }
     sw.WriteLine();
     indent++;
 }
Esempio n. 20
0
        /// <summary>
        /// Dump a node to the DOT language graph.
        /// </summary>
        /// <param name="node">The node to be dumped.</param>
        /// <param name="label">The label to use for the node.</param>
        /// <param name="attributes">An enumerable of attribute strings.</param>
        /// <param name="textColor">The color of the text.</param>
        /// <param name="nodeColor">The color of the node.</param>
        /// <param name="borderColor">The color of the node border.</param>
        /// <param name="nodeShape">The shape of the node.</param>
        /// TODO: Check whether GetHashCode should really be used or better Graph.GetElementName()
        public void DumpNode(INode node, String label, IEnumerable <String> attributes, GrColor textColor,
                             GrColor nodeColor, GrColor borderColor, GrNodeShape nodeShape)
        {
            if (groupNesting.Count > 0)
            {
                // edges coming from or going to subgraph nodes require plain nodes as source or target in the DOT format,
                // so if a characteristic node of a group is enlarged itself to a subgraph, we have to choose another - hopefully plain node - as contained characteristic node
                // otherwise we stick to the first node picked as characteristic node (first node added after group opening)
                if (groupNodesToCharacteristicContainedNode[groupNesting.Peek()] == null ||
                    groupNodesToCharacteristicContainedNode.ContainsKey(groupNodesToCharacteristicContainedNode[groupNesting.Peek()]))
                {
                    groupNodesToCharacteristicContainedNode[groupNesting.Peek()] = node;
                }
            }

            WriteIndentation();
            sw.Write("n{0} [", node.GetHashCode());

            if (label != null)
            {
                sw.Write(" label=\"{0}\"", label);
            }
            if (textColor != GrColor.Default)
            {
                sw.Write(" fontcolor=" + GetColor(textColor));
            }
            if (nodeColor != GrColor.Default)
            {
                sw.Write(" fillcolor=" + GetColor(nodeColor) + " style=filled");
            }
            if (borderColor != textColor)
            {
                sw.Write(" color=" + GetColor(borderColor));
            }
            if (nodeShape != GrNodeShape.Default)
            {
                sw.Write(" shape=" + GetNodeShape(nodeShape));
            }
            if (attributes != null)
            {
                sw.Write(" tooltip=\"");
                bool first = true;
                Indent();
                foreach (String attr in attributes)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        sw.WriteLine();
                        WriteIndentation();
                    }
                    sw.Write(EncodeString(attr));
                }
                Unindent();
                sw.Write('\"');
            }

            sw.WriteLine(']');
        }
Esempio n. 21
0
        /// <summary>
        /// Dump an edge to the DOT language graph
        /// </summary>
        /// <param name="srcNode">The source node of the edge</param>
        /// <param name="tgtNode">The target node of the edge</param>
        /// <param name="label">The label of the edge, may be null</param>
        /// <param name="attributes">An enumerable of attribute strings</param>
        /// <param name="textColor">The color of the text</param>
        /// <param name="edgeColor">The color of the edge</param>
        /// <param name="lineStyle">The linestyle of the edge</param>
        /// <param name="thickness">The thickness of the edge (1-5)</param>
        /// TODO: Check whether GetHashCode should really be used or better Graph.GetElementName()
        public void DumpEdge(INode srcNode, INode tgtNode, String label, IEnumerable <String> attributes,
                             GrColor textColor, GrColor edgeColor, GrLineStyle lineStyle, int thickness)
        {
            INode srcNodeOrCharNodeFromGroupIfGroupNode = srcNode;

            if (groupNodesToCharacteristicContainedNode.ContainsKey(srcNode))
            {
                srcNodeOrCharNodeFromGroupIfGroupNode = groupNodesToCharacteristicContainedNode[srcNode];
            }
            INode tgtNodeOrNodeFromGroupIfGroupNode = tgtNode;

            if (groupNodesToCharacteristicContainedNode.ContainsKey(tgtNode))
            {
                tgtNodeOrNodeFromGroupIfGroupNode = groupNodesToCharacteristicContainedNode[tgtNode];
            }

            WriteIndentation();
            sw.Write("n{0} -> n{1} [", srcNodeOrCharNodeFromGroupIfGroupNode.GetHashCode(), tgtNodeOrNodeFromGroupIfGroupNode.GetHashCode());

            String attrStr = "";

            if (attributes != null && attributes.GetEnumerator().MoveNext())
            {
                StringBuilder attrStrBuilder = new StringBuilder("Attributes:");
                bool          first          = true;
                foreach (String attr in attributes)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        attrStrBuilder.Append('\n');
                    }
                    attrStrBuilder.Append(EncodeString(attr));
                }
                attrStr = attrStrBuilder.ToString();
            }

            if (srcNodeOrCharNodeFromGroupIfGroupNode != srcNode)
            {
                sw.Write(" ltail=cluster" + srcNode.GetHashCode());
            }
            if (tgtNodeOrNodeFromGroupIfGroupNode != tgtNode)
            {
                sw.Write(" lhead=cluster" + tgtNode.GetHashCode());
            }

            if (label != null)
            {
                sw.Write(" label=\"" + label + "\"");
            }
            if (attrStr != "")
            {
                sw.Write(" tooltip=\"" + attrStr + "\"");
            }
            if (textColor != GrColor.Default)
            {
                sw.Write(" fontcolor=" + GetColor(textColor));
            }
            if (edgeColor != GrColor.Default)
            {
                sw.Write(" color=" + GetColor(edgeColor));
            }
            if (lineStyle != GrLineStyle.Default)
            {
                sw.Write(" style=" + GetLineStyle(lineStyle));
            }
            if (thickness != 1)
            {
                sw.Write(" thickness=" + thickness + ".0");
            }

            sw.WriteLine(']');
        }
Esempio n. 22
0
 private static void DumpNode(INode node, GrColor textColor, GrColor color, GrColor borderColor,
                              GrNodeShape shape, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpNode(node, GetElemLabel(node, dumpInfo), DumpAttributes(node), textColor,
                     color, borderColor, shape);
 }
Esempio n. 23
0
 private static void DumpEdge(IEdge edge, GrColor textColor, GrColor color, GrLineStyle style,
                              int thickness, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpEdge(edge.Source, edge.Target, GetElemLabel(edge, dumpInfo), DumpAttributes(edge),
                     textColor, color, style, thickness);
 }
Esempio n. 24
0
 private static void DumpEdge(IEdge edge, GrColor textColor, GrColor color, GrLineStyle style,
     int thickness, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpEdge(edge.Source, edge.Target, GetElemLabel(edge, dumpInfo), DumpAttributes(edge),
         textColor, color, style, thickness);
 }
Esempio n. 25
0
 public void SetNodeDumpTypeTextColor(GrElemDumpType type, GrColor color)
 {
     nodeTextColors[(int)type] = color;
 }
Esempio n. 26
0
        /// <summary>
        /// Dumps the given matches.
        /// </summary>
        /// <param name="dumper">The graph dumper to be used.</param>
        /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
        /// <param name="matches">An IMatches object containing the matches.</param>
        /// <param name="which">Which match to dump, or AllMatches for dumping all matches
        /// adding connections between them, or OnlyMatches to dump the matches only</param>
        public static void DumpMatchOnly(IDumper dumper, DumpInfo dumpInfo, IMatches matches, DumpMatchSpecial which,
                                         ref Set <INode> matchedNodes, ref Set <INode> multiMatchedNodes, ref Set <IEdge> matchedEdges, ref Set <IEdge> multiMatchedEdges)
        {
            matchedNodes = new Set <INode>();
            matchedEdges = new Set <IEdge>();

            if ((int)which >= 0 && (int)which < matches.Count)
            {
                // Show exactly one match

                IMatch match = matches.GetMatch((int)which);
                matchedNodes.Add(match.Nodes);
                matchedEdges.Add(match.Edges);
            }
            else
            {
                GrColor     vnodeColor       = dumpInfo.GetNodeDumpTypeColor(GrElemDumpType.VirtualMatch);
                GrColor     vedgeColor       = dumpInfo.GetEdgeDumpTypeColor(GrElemDumpType.VirtualMatch);
                GrColor     vnodeBorderColor = dumpInfo.GetNodeDumpTypeBorderColor(GrElemDumpType.VirtualMatch);
                GrColor     vnodeTextColor   = dumpInfo.GetNodeDumpTypeTextColor(GrElemDumpType.VirtualMatch);
                GrColor     vedgeTextColor   = dumpInfo.GetEdgeDumpTypeTextColor(GrElemDumpType.VirtualMatch);
                GrNodeShape vnodeShape       = dumpInfo.GetNodeDumpTypeShape(GrElemDumpType.VirtualMatch);
                GrLineStyle vedgeLineStyle   = dumpInfo.GetEdgeDumpTypeLineStyle(GrElemDumpType.VirtualMatch);
                int         vedgeThickness   = dumpInfo.GetEdgeDumpTypeThickness(GrElemDumpType.VirtualMatch);

                multiMatchedNodes = new Set <INode>();
                multiMatchedEdges = new Set <IEdge>();

                // TODO: May edges to nodes be dumped before those nodes exist??
                // TODO: Should indices in strings start at 0 or 1? (original: 0)

                // Dump all matches with virtual nodes
                int i = 0;
                foreach (IMatch match in matches)
                {
                    VirtualNode virtNode = new VirtualNode(-i - 1);
                    dumper.DumpNode(virtNode, String.Format("{0}. match of {1}", i + 1, matches.Producer.Name),
                                    null, vnodeTextColor, vnodeColor, vnodeBorderColor, vnodeShape);
                    int j = 1;
                    foreach (INode node in match.Nodes)
                    {
                        dumper.DumpEdge(virtNode, node, String.Format("node {0}", ++j), null,
                                        vedgeTextColor, vedgeColor, vedgeLineStyle, vedgeThickness);

                        if (matchedNodes.Contains(node))
                        {
                            multiMatchedNodes.Add(node);
                        }
                        else
                        {
                            matchedNodes.Add(node);
                        }
                    }

                    // Collect matched edges
                    foreach (IEdge edge in match.Edges)
                    {
                        if (matchedEdges.Contains(edge))
                        {
                            multiMatchedEdges.Add(edge);
                        }
                        else
                        {
                            matchedEdges.Add(edge);
                        }
                    }
                    ++i;
                }

                if (which == DumpMatchSpecial.OnlyMatches)
                {
                    // Dump the matches only
                    // First dump the matched nodes

                    foreach (INode node in matchedNodes)
                    {
                        GrElemDumpType dumpType;
                        if (multiMatchedNodes.Contains(node))
                        {
                            dumpType = GrElemDumpType.MultiMatched;
                        }
                        else
                        {
                            dumpType = GrElemDumpType.SingleMatched;
                        }

                        DumpNode(node, dumpInfo.GetNodeDumpTypeTextColor(dumpType),
                                 dumpInfo.GetNodeDumpTypeColor(dumpType),
                                 dumpInfo.GetNodeDumpTypeBorderColor(dumpType),
                                 dumpInfo.GetNodeDumpTypeShape(dumpType),
                                 dumper, dumpInfo);
                    }

                    // Now add the matched edges (possibly including "Not matched" nodes)

                    foreach (IEdge edge in matchedEdges)
                    {
                        if (!matchedNodes.Contains(edge.Source))
                        {
                            DumpNode(edge.Source,
                                     dumpInfo.GetNodeTypeTextColor(edge.Source.Type),
                                     dumpInfo.GetNodeTypeColor(edge.Source.Type),
                                     dumpInfo.GetNodeTypeBorderColor(edge.Source.Type),
                                     dumpInfo.GetNodeTypeShape(edge.Source.Type),
                                     dumper, dumpInfo);
                        }

                        if (!matchedNodes.Contains(edge.Target))
                        {
                            DumpNode(edge.Target,
                                     dumpInfo.GetNodeTypeTextColor(edge.Target.Type),
                                     dumpInfo.GetNodeTypeColor(edge.Target.Type),
                                     dumpInfo.GetNodeTypeBorderColor(edge.Target.Type),
                                     dumpInfo.GetNodeTypeShape(edge.Target.Type),
                                     dumper, dumpInfo);
                        }

                        GrElemDumpType dumpType;
                        if (multiMatchedEdges.Contains(edge))
                        {
                            dumpType = GrElemDumpType.MultiMatched;
                        }
                        else
                        {
                            dumpType = GrElemDumpType.SingleMatched;
                        }

                        DumpEdge(edge, dumpInfo.GetEdgeDumpTypeTextColor(dumpType),
                                 dumpInfo.GetEdgeDumpTypeColor(dumpType),
                                 dumpInfo.GetEdgeDumpTypeLineStyle(dumpType),
                                 dumpInfo.GetEdgeDumpTypeThickness(dumpType),
                                 dumper, dumpInfo);
                    }
                    return;
                }
            }
        }
Esempio n. 27
0
 public void SetEdgeDumpTypeTextColor(GrElemDumpType type, GrColor color)
 {
     edgeTextColors[(int)type] = color;
 }
Esempio n. 28
0
 private static void DumpNode(INode node, GrColor textColor, GrColor color, GrColor borderColor,
     GrNodeShape shape, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpNode(node, GetElemLabel(node, dumpInfo), DumpAttributes(node), textColor,
         color, borderColor, shape);
 }