Exemplo n.º 1
0
 public EdgeRealizer(String name, GrColor color, GrColor textColor, int lineWidth, GrLineStyle lineStyle)
 {
     Name      = name;
     Color     = color;
     TextColor = textColor;
     LineWidth = lineWidth;
     LineStyle = lineStyle;
 }
Exemplo n.º 2
0
 internal void ChangeEdgeStyle(ElementMode mode, GrLineStyle style)
 {
     edgeRealizers[(int)mode] = GetEdgeRealizer(
         edgeRealizers[(int)mode].Color,
         edgeRealizers[(int)mode].TextColor,
         edgeRealizers[(int)mode].LineWidth,
         style);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the VCG string representation of a GrLineStyle object.
 /// </summary>
 /// <param name="style">The GrLineStyle object.</param>
 /// <returns>The VCG string representation of <c>style</c>.</returns>
 public static String GetLineStyle(GrLineStyle style)
 {
     if ((uint)style >= lineStyles.Length)
     {
         return(lineStyles[0]);
     }
     else
     {
         return(lineStyles[(int)style]);
     }
 }
Exemplo n.º 4
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('}');
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
 public void SetEdgeDumpTypeLineStyle(GrElemDumpType type, GrLineStyle style)
 {
     edgeLineStyles[(int)type] = style;
 }
Exemplo n.º 7
0
 public void SetEdgeTypeLineStyle(EdgeType edgeType, GrLineStyle style)
 {
     edgeTypeLineStyles[edgeType] = style;           // overwrites existing mapping
     EdgeTypeAppearanceChanged(edgeType);
 }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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;
                }
            }
        }
Exemplo n.º 10
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);
 }
Exemplo n.º 11
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(']');
        }
Exemplo n.º 12
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('}');
        }
Exemplo n.º 13
0
 /// <summary>
 /// Gets the VCG string representation of a GrLineStyle object.
 /// </summary>
 /// <param name="style">The GrLineStyle object.</param>
 /// <returns>The VCG string representation of <c>style</c>.</returns>
 public static String GetLineStyle(GrLineStyle style)
 {
     if((uint) style >= lineStyles.Length) return lineStyles[0];
     else return lineStyles[(int) style];
 }
Exemplo n.º 14
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);
 }