protected virtual void FormatVertex(ControlFlowBlock cfb, GraphvizVertex fmt) { if (cfb.Name == "start") { fmt.Label = "start"; } else if (cfb.Name == "finish") { fmt.Label = "finish"; } else { var match = Regex.Match(cfb.DumpAsText(), @"^(?<header>.*?)?(\r\n(?<code>.*))?$", RegexOptions.Singleline); match.Success.AssertTrue(); var header = match.Result("${header}"); if (header.IsNeitherNullNorEmpty()) { var cfi = Cflow().IndexOf(cfb); header = header + String.Format(", cfi={0}", cfi == -1 ? "*" : cfi.ToString()); } var code = match.Result("${code}"); fmt.Label = new[] { header, code }.Where(s => s.IsNeitherNullNorEmpty()).StringJoin(Environment.NewLine); } }
/// <summary /> internal FormatVertexEventArgs([NotNull] TVertex vertex, [NotNull] GraphvizVertex vertexFormat) : base(vertex) { Debug.Assert(vertexFormat != null); VertexFormat = vertexFormat; }
public void ToDot_InvariantCulture([NotNull, InstantHandle] Func <GraphvizVertex, string> convert) { var vertex = new GraphvizVertex { Shape = GraphvizVertexShape.Polygon, Distortion = 2.5, Font = new GraphvizFont("Test font", 12.5f), PenWidth = 2.5, Orientation = 45.8, FixedSize = true, Size = new GraphvizSizeF(14.5f, 21.6f), Skew = 2.2, Z = 12.3 }; const string expectedDot = @"fontname=""Test font"", fontsize=12.5, penwidth=2.5, shape=polygon, fixedsize=true, height=21.6, " + @"width=14.5, orientation=45.8, z=12.3, sides=4, skew=2.2, distortion=2.5"; using (CultureScope(EnglishCulture)) { Assert.AreEqual(expectedDot, convert(vertex)); } using (CultureScope(FrenchCulture)) { Assert.AreEqual(expectedDot, convert(vertex)); } }
public void Constructor() { var vertex = new GraphvizVertex(); Assert.IsNull(vertex.Position); Assert.IsNull(vertex.Comment); Assert.IsNull(vertex.Label); Assert.IsNull(vertex.ToolTip); Assert.IsNull(vertex.Url); Assert.Zero(vertex.Distortion); Assert.AreEqual(GraphvizColor.White, vertex.FillColor); Assert.IsNull(vertex.Font); Assert.AreEqual(GraphvizColor.Black, vertex.FontColor); Assert.AreEqual(1.0, vertex.PenWidth); Assert.IsNull(vertex.Group); Assert.IsNull(vertex.Layer); Assert.Zero(vertex.Orientation); Assert.AreEqual(-1, vertex.Peripheries); Assert.IsFalse(vertex.Regular); Assert.IsNotNull(vertex.Record); Assert.AreEqual(GraphvizVertexShape.Unspecified, vertex.Shape); Assert.AreEqual(4, vertex.Sides); Assert.IsNotNull(vertex.Size); Assert.Zero(vertex.Size.Width); Assert.Zero(vertex.Size.Height); Assert.IsFalse(vertex.FixedSize); Assert.Zero(vertex.Skew); Assert.AreEqual(GraphvizColor.Black, vertex.StrokeColor); Assert.AreEqual(GraphvizVertexStyle.Unspecified, vertex.Style); Assert.AreEqual(-1, vertex.Z); }
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"; }
public void ProcessVertex(GraphvizVertex formatter, Project project) { if (IsModelProject(project)) { formatter.StrokeColor = Color.DeepSkyBlue; formatter.Subgraph = "Model"; } }
internal FormatVertexEventArgs(TVertex v, GraphvizVertex vertexFormatter) : base(v) { #if CONTRACTS_BUG Contract.Requires(vertexFormatter != null); #endif this.vertexFormatter = vertexFormatter; }
public FormatVertexEventArgs(GraphvizVertex vertexFormatter, V v) : base(v) { if (vertexFormatter == null) { throw new ArgumentNullException("vertexFormatter"); } this.vertexFormatter = vertexFormatter; }
/// <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(); }
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(); }
private void OnFormatVertex(TVertex v) { Output.Write("{0} ", this.vertexIds[v]); if (FormatVertex != null) { GraphvizVertex gv = new GraphvizVertex(); gv.Label = v.ToString(); FormatVertex(this, new FormatVertexEventArgs <TVertex>(gv, v)); string s = gv.ToDot(); if (s.Length != 0) { Output.Write("[{0}]", s); } } Output.WriteLine(";"); }
void alg_WriteVertex(object sender, VertexEventArgs e) { GraphvizAlgorithm algo = (GraphvizAlgorithm)sender; GraphvizVertex vertex = new GraphvizVertex(); ReferenceVertex v = e.Vertex as ReferenceVertex; vertex.Label = v.Name; if (!string.IsNullOrEmpty(v.Path)) { vertex.Url = "file://" + Path.GetFullPath(v.Path); } // TODO: add .URL if (v.ReferenceType == ReferenceType.Project) { vertex.Shape = GraphvizVertexShape.Box; } algo.Output.Write(vertex.ToDot()); }
private static void FormatVertex( GraphvizVertex vertexFormatter, double relCount, string label, bool isRoot, bool isArgument = false) { var strokeColor = (byte)((1d - relCount) * MAX_STROKE_COLOR); var fontColor = (byte)((1d - relCount) * MAX_FONT_COLOR); vertexFormatter.Shape = isArgument ? ARG_VERTEX_SHAPE : NODE_VERTEX_SHAPE; if (isRoot) { vertexFormatter.Style = ROOT_VERTEX_STYLE; } vertexFormatter.Size = new GraphvizSizeF(0.15f, 0.15f); vertexFormatter.FixedSize = isArgument; vertexFormatter.Font = new GraphvizFont(FONT_NAME, isArgument ? ARG_FONT_SIZE : FONT_SIZE); vertexFormatter.FontColor = new GraphvizColor(255, fontColor, fontColor, fontColor); vertexFormatter.Label = label; vertexFormatter.StrokeColor = new GraphvizColor(255, strokeColor, strokeColor, strokeColor); }
/// <summary> /// Formats a <see cref="DataTable"/> (a table). /// </summary> /// <param name="sender"></param> /// <param name="args"></param> protected virtual void FormatTable([NotNull] object sender, [NotNull] FormatVertexEventArgs <DataTable> args) { Debug.Assert(sender != null); Debug.Assert(args != null); DataTable vertex = args.Vertex; GraphvizVertex format = args.VertexFormat; format.Shape = GraphvizVertexShape.Record; // Create a record with a title and a list of columns var title = new GraphvizRecordCell { Text = vertex.TableName }; var builder = new StringBuilder(); bool flag = true; foreach (DataColumn column in vertex.Columns) { if (flag) { flag = false; } else { builder.AppendLine(); } builder.Append($"+ {column.ColumnName} : {column.DataType.Name}"); if (column.Unique) { builder.Append(" unique"); } } var columns = new GraphvizRecordCell { Text = builder.ToString().TrimEnd() }; format.Record.Cells.Add(title); format.Record.Cells.Add(columns); }
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(); }
/// <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); }
public FileDependencyTest() { m_Vertex = new GraphvizVertex(); m_Names = new VertexStringDictionary(); }
public void ToDot([NotNull] GraphvizVertex vertex, [NotNull] string expectedDot) { Assert.AreEqual(expectedDot, vertex.ToDot()); Assert.AreEqual(expectedDot, vertex.ToString()); }