コード例 #1
0
        /// <summary>
        /// Visit the specified node
        /// </summary>
        /// <param name="node">Node to visit</param>
        /// <returns>Dot Statement for this node.</returns>
        public IDotStatement VisitNode(Node node)
        {
            Require.NotNull("node", node);
            var result
                = new DotStatement("\"" + node.Name + "\"")
                  .AddAttribute(Dot.Label, node.Label);

            if (node.Shape != NodeShape.None)
            {
                result = result.AddAttribute(Dot.NodeShape, ValueOf(node.Shape));
            }

            if (node.FillColor != Color.Empty)
            {
                result = result.AddAttribute(Dot.FillColor, ValueOf(node.FillColor))
                         .AddAttribute(Dot.Style, "filled");
            }

            if (node.FontColor != Color.Empty)
            {
                result = result.AddAttribute(Dot.FontColor, ValueOf(node.FontColor));
            }

            if (!string.IsNullOrEmpty(node.Font))
            {
                result = result.AddAttribute(Dot.Font, node.Font);
            }

            if (node.FontSize > 0)
            {
                result = result.AddAttribute(Dot.FontSize, node.FontSize.ToString());
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Visit the specified edge
        /// </summary>
        /// <param name="edge">Edge to visit</param>
        /// <returns>Dot Statement for this edge.</returns>
        public IDotStatement VisitEdge(Edge edge)
        {
            Require.NotNull("edge", edge);
            var text = string.Format("\"{0}\" -> \"{1}\"", edge.Start.Name, edge.Finish.Name);
            var result
                = new DotStatement(text)
                  .AddAttribute(Dot.ArrowHead, ValueOf(edge.ArrowHead))
                  .AddAttribute(Dot.ArrowTail, ValueOf(edge.ArrowTail))
                  .AddAttribute(Dot.Color, ValueOf(edge.Color));

            if (edge.Constraining == false)
            {
                result = result.AddAttribute(Dot.EdgeConstraint, "false");
            }

            return(result);
        }