2009-12-24 63 views
0

我正在嘗試使用QuickGraph構建包含記錄頂點的Graphviz圖。到目前爲止,我有這樣的:QuickGraph GraphvizRecord不顯示在頂點

var algo = new GraphvizAlgorithm<Entity, EntityEdge>(this); 
algo.CommonVertexFormat.Shape = GraphvizVertexShape.Record; 
algo.CommonVertexFormat.Style = GraphvizVertexStyle.Filled; 
algo.FormatVertex += new FormatVertexEventHandler<Entity>(FormatVertex); 

private void FormatVertex(object sender, FormatVertexEventArgs<Entity> e) { 
    Entity ent = e.Vertex; 
    GraphvizRecord rec = new GraphvizRecord(); 

    GraphvizRecordCell rootCell = new GraphvizRecordCell(); 
    rootCell.Text = ent.ClassName + "\\n" + ent.TargetName; 

    var inputs = ent.GetUniqueInputNames(); 

    foreach (string input in inputs) { 
     GraphvizRecordCell cell = new GraphvizRecordCell(); 
     cell.Text = input; 
     cell.Port = input; 
     rootCell.Cells.Add(cell); 
    } 

    rec.Cells.Add(rootCell); 

    e.VertexFormatter.Record = rec; 
} 

當我生成的圖表,但是,頂點顯示標籤,而不是一個紀錄。我究竟做錯了什麼?

編輯

這裏的點輸出。

digraph G { 
    bgcolor="#454545FF" 
    node [fillcolor="#505050FF", color="#2A2A2AFF", shape=record, fontname="Verdana", fontsize=10, label="", style=filled, fontcolor="#FFFFFFFF"]; 
    edge [ fontsize=10, fontcolor="#FFFFFFFF", color="#ECA706FF", fontname="Verdana"]; 
    0 [label="EntityMap.Entity"]; 
    1 [label="EntityMap.Entity"]; 
    2 [label="EntityMap.Entity"]; 
    3 [label="EntityMap.Entity"]; 
    4 [label="EntityMap.Entity"]; 
    5 [label="EntityMap.Entity"]; 
    6 [label="EntityMap.Entity"]; 
    7 [label="EntityMap.Entity"]; 
    8 [label="EntityMap.Entity"]; 
    9 [label="EntityMap.Entity"]; 
    10 [label="EntityMap.Entity"]; 
    11 [label="EntityMap.Entity"]; 
    12 [label="EntityMap.Entity"]; 
    13 [label="EntityMap.Entity"]; 
    14 [label="EntityMap.Entity"]; 
    15 [label="EntityMap.Entity"]; 
    0 -> 0 [ label="OnPlayerUse", headport="EnableMotion", headlabel=""]; 
    0 -> 1 [ label="OnPlayerUse", headport="Explode", headlabel=""]; 
    0 -> 6 [ label="OnPlayerUse", headport="Compare", headlabel=""]; 
    0 -> 5 [ label="OnPlayerUse", headport="RevertToDefaultRelationship", headlabel=""]; 
    3 -> 4 [ label="OnTrigger", headport="Wake", headlabel=""]; 
    4 -> 2 [ label="OnFoundEnemy", headport="Display", headlabel=""]; 
    6 -> 15 [ label="OnEqualTo", headport="EmitAISound", headlabel=""]; 
    6 -> 4 [ label="OnEqualTo", headport="Wake", headlabel=""]; 
    7 -> 8 [ label="OnStartTouch", headport="Command", headlabel="+duck"]; 
    7 -> 8 [ label="OnEndTouch", headport="Command", headlabel="-duck"]; 
    7 -> 9 [ label="OnEndTouch", headport="Enable", headlabel=""]; 
    7 -> 10 [ label="OnEndTouch", headport="Fade", headlabel=""]; 
    7 -> 7 [ label="OnEndTouch", headport="Disable", headlabel=""]; 
    12 -> 11 [ label="OnMapSpawn", headport="Fade", headlabel=""]; 
    13 -> 6 [ label="OnPass", headport="SetValue", headlabel="1"]; 
    14 -> 6 [ label="OnPass", headport="SetValue", headlabel="1"]; 
} 
+0

是否有可能獲得渲染圖形的「點」源?它可能會提供線索... – 2009-12-24 22:38:22

+0

我已將點輸出添加到問題。 – 2009-12-24 22:55:48

回答

0

在根單元中有詳細信息丟失,特別是對象方法的名稱。我猜dot輸出線

0 [label="EntityMap.Entity"]; 

...真的應該:

0 [label="<EnableMotion> EntityMap.Entity"]; 

(......我猜他們不都是應該被命名爲EntityMap.Entity?)

我不能真的可以告訴程序中哪些邊緣被引入,但是似乎邊緣是基於不同於頂點的信息來渲染的。

手動運行dotdot foo.dot -Tpng -o foo.png)可能會爲您提供更多信息錯誤/警告消息。

+0

嗯,點輸出是錯誤的,因爲這是QuickGraph生成它的方式。我正在設置所有內容以使用記錄和單元格,但QuickGraph忽略了我並使用了標籤。 – 2009-12-25 14:42:12