Esempio n. 1
0
        public void Label_Throws()
        {
            var edge = new GraphvizEdge();

            // ReSharper disable once AssignNullToNotNullAttribute
            Assert.Throws <ArgumentNullException>(() => edge.Label = null);
        }
Esempio n. 2
0
        public void ToDot_InvariantCulture([NotNull, InstantHandle] Func <GraphvizEdge, string> convert)
        {
            var edge = new GraphvizEdge
            {
                Label = new GraphvizEdgeLabel
                {
                    Value    = "Edge label",
                    Angle    = 25.5,
                    Distance = 1.5,
                    Font     = new GraphvizFont("Label font", 14.5f)
                },
                Font     = new GraphvizFont("Test font", 12.5f),
                PenWidth = 2.5,
                Weight   = 1.5
            };

            const string expectedDot =
                @"fontname=""Test font"", fontsize=12.5, penwidth=2.5, label=""Edge label"", labelangle=25.5, "
                + @"labeldistance=1.5, labelfontname=""Label font"", labelfontsize=14.5, weight=1.5";

            using (CultureScope(EnglishCulture))
            {
                Assert.AreEqual(expectedDot, convert(edge));
            }

            using (CultureScope(FrenchCulture))
            {
                Assert.AreEqual(expectedDot, convert(edge));
            }
        }
Esempio n. 3
0
        public void Constructor()
        {
            var edge = new GraphvizEdge();

            Assert.IsNull(edge.Comment);
            Assert.IsFalse(edge.Label.IsHtmlLabel);
            Assert.IsNotNull(edge.Label);
            Assert.IsNull(edge.ToolTip);
            Assert.IsNull(edge.Url);
            Assert.AreEqual(GraphvizEdgeDirection.Forward, edge.Direction);
            Assert.IsNull(edge.Font);
            Assert.AreEqual(GraphvizColor.Black, edge.FontColor);
            Assert.AreEqual(1.0, edge.PenWidth);
            Assert.IsNotNull(edge.Head);
            Assert.IsNull(edge.HeadArrow);
            Assert.IsNull(edge.HeadPort);
            Assert.IsNotNull(edge.Tail);
            Assert.IsNull(edge.TailArrow);
            Assert.IsNull(edge.TailPort);
            Assert.IsTrue(edge.IsConstrained);
            Assert.IsFalse(edge.IsDecorated);
            Assert.IsNull(edge.Layer);
            Assert.AreEqual(GraphvizColor.Black, edge.StrokeColor);
            Assert.AreEqual(GraphvizEdgeStyle.Unspecified, edge.Style);
            Assert.AreEqual(1, edge.Weight);
            Assert.AreEqual(1, edge.Length);
            Assert.AreEqual(1, edge.MinLength);
        }
        public TestGraphvizVertex(VertexStringDictionary names)
        {
            m_Names = names;

            m_Vertex             = new GraphvizVertex();
            m_Vertex.Shape       = GraphvizVertexShape.Hexagon;
            m_Vertex.Style       = GraphvizVertexStyle.Filled;
            m_Vertex.ToolTip     = "This is a tooltip";
            m_Vertex.Url         = "http://www.dotnetwiki.org";
            m_Vertex.StrokeColor = Color.Red;
            m_Vertex.FillColor   = Color.LightGray;
            m_Vertex.FontColor   = Color.Blue;
            m_Vertex.Orientation = 45;
            m_Vertex.Regular     = true;
            m_Vertex.Sides       = 2;

            m_Edge                    = new GraphvizEdge();
            m_Edge.HeadArrow          = new GraphvizArrow(GraphvizArrowShape.Box);
            m_Edge.HeadArrow.Clipping = GraphvizArrowClipping.Left;
            m_Edge.HeadArrow.Filling  = GraphvizArrowFilling.Open;

            m_Edge.TailArrow = new GraphvizArrow(GraphvizArrowShape.Dot);

            m_Edge.Label.Value = "This is an edge";
        }
        /// <summary />
        internal FormatEdgeEventArgs([NotNull] TEdge edge, [NotNull] GraphvizEdge edgeFormat)
            : base(edge)
        {
            Debug.Assert(edgeFormat != null);

            EdgeFormat = edgeFormat;
        }
 protected virtual void FormatEdge(ControlFlowEdge e, GraphvizEdge fmt)
 {
     fmt.Label = new GraphvizEdgeLabel {
         Value = e.IsConditional ? e.Tag.ToSymbol() : null
     };
     fmt.Style = BackEdges().Contains(e) ? GraphvizEdgeStyle.Dotted : GraphvizEdgeStyle.Solid;
 }
 public void ProcessEdge(GraphvizEdge formatter, Project sourceProject, Project targetProject)
 {
     if (IsModelProject(targetProject))
     {
         formatter.Style       = GraphvizEdgeStyle.Bold;
         formatter.StrokeColor = Color.DeepSkyBlue;
     }
 }
Esempio n. 8
0
        internal FormatEdgeEventArgs(TEdge e, GraphvizEdge edgeFormatter)
            : base(e)
        {
#if CONTRACTS_BUG
            Contract.Requires(edgeFormatter != null);
#endif
            this.edgeFormatter = edgeFormatter;
        }
Esempio n. 9
0
        public void Head_Throws()
        {
            var edge = new GraphvizEdge();

            // ReSharper disable once AssignNullToNotNullAttribute
            Assert.Throws <ArgumentNullException>(() => edge.Head = null);
            Assert.Throws <ArgumentException>(() => edge.Head     = new GraphvizEdgeExtremity(false));
        }
 public FormatEdgeEventArgs(GraphvizEdge edgeFormatter, E e)
     : base(e)
 {
     if (edgeFormatter == null)
     {
         throw new ArgumentNullException("edgeFormatter");
     }
     this.edgeFormatter = edgeFormatter;
 }
Esempio n. 11
0
 private void OnFormatEdge(TEdge e)
 {
     if (FormatEdge != null)
     {
         GraphvizEdge ev = new GraphvizEdge();
         FormatEdge(this, new FormatEdgeEventArgs <TVertex, TEdge>(ev, e));
         Output.Write(" {0}", ev.ToDot());
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Formats a <see cref="DataRelationEdge"/> (a relation between tables).
        /// </summary>
        protected virtual void FormatRelation([NotNull] object sender, [NotNull] FormatEdgeEventArgs <DataTable, DataRelationEdge> args)
        {
            Debug.Assert(sender != null);
            Debug.Assert(args != null);

            GraphvizEdge format = args.EdgeFormat;

            format.Label.Value = args.Edge.Relation.RelationName;
        }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphvizAlgorithm{TVertex,TEdge}"/> class.
 /// </summary>
 /// <param name="graph">Graph to convert to DOT.</param>
 /// <param name="imageType">Target output image type.</param>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="graph"/> is <see langword="null"/>.</exception>
 public GraphvizAlgorithm(
     [NotNull] IEdgeListGraph <TVertex, TEdge> graph,
     GraphvizImageType imageType)
 {
     ClusterCount       = 0;
     _visitedGraph      = graph ?? throw new ArgumentNullException(nameof(graph));
     ImageType          = imageType;
     GraphFormat        = new GraphvizGraph();
     CommonVertexFormat = new GraphvizVertex();
     CommonEdgeFormat   = new GraphvizEdge();
 }
Esempio n. 14
0
        public void Label()
        {
            var edge = new GraphvizEdge();

            if (edge.Label is null)
            {
                throw new InvalidOperationException($"Edge has null {nameof(GraphvizEdge.Label)}.");
            }

            var label = new GraphvizEdgeLabel();

            edge.Label = label;
            Assert.AreSame(label, edge.Label);
        }
Esempio n. 15
0
        public void Tail()
        {
            var edge = new GraphvizEdge();

            if (edge.Tail is null)
            {
                throw new InvalidOperationException($"Edge has null {nameof(GraphvizEdge.Tail)}.");
            }

            var tailExtremity = new GraphvizEdgeExtremity(false);

            edge.Tail = tailExtremity;
            Assert.AreSame(tailExtremity, edge.Tail);
        }
Esempio n. 16
0
        public void Head()
        {
            var edge = new GraphvizEdge();

            if (edge.Head is null)
            {
                throw new InvalidOperationException($"Edge has null {nameof(GraphvizEdge.Head)}.");
            }

            var headExtremity = new GraphvizEdgeExtremity(true);

            edge.Head = headExtremity;
            Assert.AreSame(headExtremity, edge.Head);
        }
Esempio n. 17
0
        public GraphvizAlgorithm(
            IEdgeListGraph <TVertex, TEdge> g,
            String path,
            GraphvizImageType imageType
            )
        {
            Contract.Requires(g != null);
            Contract.Requires(!String.IsNullOrEmpty(path));

            this.visitedGraph       = g;
            this.imageType          = imageType;
            this.graphFormat        = new GraphvizGraph();
            this.commonVertexFormat = new GraphvizVertex();
            this.commonEdgeFormat   = new GraphvizEdge();
        }
Esempio n. 18
0
        /// <summary>
        /// Emptry constructor
        /// </summary>
        public EdgeDfsTest()
        {
            m_Vertex = new GraphvizVertex();
            m_Edge   = new GraphvizEdge();

            Vertex.Style     = GraphvizVertexStyle.Filled;
            Vertex.FillColor = Color.LightSkyBlue;

            GraphvizRecordCell cell = new GraphvizRecordCell();

            Vertex.Record.Cells.Add(cell);

            GraphvizRecordCell child = new GraphvizRecordCell();

            child.Text = "State";
            cell.Cells.Add(child);

            m_Cell = new GraphvizRecordCell();
            cell.Cells.Add(m_Cell);
        }
Esempio n. 19
0
 public GraphvizAlgorithm(
     IVertexAndEdgeSet <TVertex, TEdge> g,
     String path,
     GraphvizImageType imageType
     )
 {
     if (g == null)
     {
         throw new ArgumentNullException("g");
     }
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     this.visitedGraph       = g;
     this.imageType          = imageType;
     this.graphFormat        = new GraphvizGraph();
     this.commonVertexFormat = new GraphvizVertex();
     this.commonEdgeFormat   = new GraphvizEdge();
 }
Esempio n. 20
0
        private static void FormatEdge(double relCount, GraphvizEdge edgeFormatter)
        {
            var edgeColor = (byte)((1d - relCount) * MAX_STROKE_COLOR);

            edgeFormatter.StrokeGraphvizColor = new GraphvizColor(255, edgeColor, edgeColor, edgeColor);
        }
Esempio n. 21
0
 public void ToDot([NotNull] GraphvizEdge edge, [NotNull] string expectedDot)
 {
     Assert.AreEqual(expectedDot, edge.ToDot());
     Assert.AreEqual(expectedDot, edge.ToString());
 }