Browse Source

ObjecObject graph visualizer - arrows start at properties.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4236 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Martin Koníček 16 years ago
parent
commit
d1e5cbab0d
  1. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedEdge.cs
  2. 10
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedNode.cs
  3. 14
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedNodeProperty.cs
  4. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/BoxDotFormatter.cs
  5. 14
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/DotFormatter.cs
  6. 6
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/NeatoProcess.cs
  7. 31
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/RecordDotFormatter.cs
  8. 12
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/TreeLayouter.cs
  9. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/TreeNode.cs
  10. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/NamedEdge.cs
  11. 11
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/ObjectNode.cs

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedEdge.cs

@ -13,7 +13,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -13,7 +13,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// <summary>
/// Edge with position information.
/// </summary>
public class PositionedEdge : NamedEdge<PositionedNode>
public class PositionedEdge : NamedEdge<PositionedNodeProperty, PositionedNode>
{
private IList<Point> splinePoints = new List<Point>();

10
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedNode.cs

@ -34,6 +34,13 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -34,6 +34,13 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
}
}
public PositionedNodeProperty AddProperty(ObjectProperty objectProperty)
{
var newProperty = new PositionedNodeProperty(objectProperty, this);
this.Properties.Add(newProperty);
return newProperty;
}
/// <summary>
/// Creates new PositionedNode.
/// </summary>
@ -88,7 +95,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -88,7 +95,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
{
foreach (PositionedNodeProperty property in this.Properties)
{
yield return property.Edge;
if (property.Edge != null)
yield return property.Edge;
}
}
}

14
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/PositionedNodeProperty.cs

@ -17,9 +17,10 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -17,9 +17,10 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// Creates new PositionedNodeProperty.
/// </summary>
/// <param name="objectProperty">Underlying <see cref="ObjectProperty"/></param>
public PositionedNodeProperty(ObjectProperty objectProperty)
public PositionedNodeProperty(ObjectProperty objectProperty, PositionedNode containingNode)
{
this.objectProperty = objectProperty;
this.containingNode = containingNode;
}
private ObjectProperty objectProperty;
@ -28,7 +29,16 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -28,7 +29,16 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// </summary>
public ObjectProperty ObjectProperty
{
get { return objectProperty; }
get { return this.objectProperty; }
}
private PositionedNode containingNode;
/// <summary>
/// <see cref="PositionedNode"/> which contains this Property.
/// </summary>
public PositionedNode ContainingNode
{
get { return this.containingNode; }
}
/// <summary>

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/BoxDotFormatter.cs

@ -35,8 +35,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -35,8 +35,8 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
protected override void appendPosEdge(PositionedEdge edge, StringBuilder builder)
{
string sourceNodeName = nodeNames[edge.SourceNode];
string targetNodeName = nodeNames[edge.TargetNode];
string sourceNodeName = nodeNames[edge.Source.ContainingNode];
string targetNodeName = nodeNames[edge.Target];
builder.AppendLine(string.Format("{0} -> {1}", sourceNodeName, targetNodeName));
}

14
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/DotFormatter.cs

@ -48,12 +48,22 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -48,12 +48,22 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
protected abstract void appendPosEdge(PositionedEdge edge, StringBuilder builder);
protected virtual string getGraphHeader()
{
return "digraph G { node [shape = box];";
}
protected virtual string getGraphFooter()
{
return "}";
}
/// <summary>
/// Gets Graphviz's dot format string for wrapped positioned graph.
/// </summary>
public string OutputGraphInDotFormat()
{
StringBuilder dotStringBuilder = new StringBuilder("digraph G { node [shape = box];");
StringBuilder dotStringBuilder = new StringBuilder(getGraphHeader());
foreach (PositionedNode posNode in this.posGraph.Nodes)
{
@ -64,7 +74,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -64,7 +74,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
appendPosEdge(posEdge, dotStringBuilder);
}
dotStringBuilder.AppendLine("}");
dotStringBuilder.AppendLine(getGraphFooter());
return dotStringBuilder.ToString();
}

6
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/NeatoProcess.cs

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
// <version>$Revision$</version>
// </file>
using System;
using System.IO;
using System.Text;
namespace Debugger.AddIn.Visualizers.Graph.Layout
@ -72,6 +73,11 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -72,6 +73,11 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// <returns>Same graph in Graphviz plain with position information added.</returns>
public string CalculatePositions(string dotGraph)
{
using (var writer = new StreamWriter(@"D:\__prog__\Graphviz\logIn.gv"))
{
writer.Write(dotGraph);
}
neatoProcess.StandardInput.Write(dotGraph);
neatoProcess.StandardInput.Flush();
neatoProcess.StandardInput.Close();

31
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/RecordDotFormatter.cs

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
@ -16,10 +17,17 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -16,10 +17,17 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
/// </summary>
public class RecordDotFormatter : DotFormatter
{
private Dictionary<PositionedNodeProperty, string> propertyIds = new Dictionary<PositionedNodeProperty, string>();
public RecordDotFormatter(PositionedGraph posGraph) : base(posGraph)
{
}
protected override string getGraphHeader()
{
return "digraph G { rankdir=LR; node [shape = record];";
}
protected override void appendPosNode(PositionedNode node, StringBuilder builder)
{
string nodeName = genId.GetNextId().ToString();
@ -27,13 +35,17 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -27,13 +35,17 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
Rect neatoInput = transform.NodeToNeatoInput(node);
/*LEFT [
pos="0,0!"
width="1", height="1"
label = "<f0> a| <f1> b| <f2> c|<f3>d"];*/
StringBuilder recordLabel = new StringBuilder();
for (int i = 0; i < node.Properties.Count; i++)
{
string propertyId = "f" + genId.GetNextId().ToString();
propertyIds[node.Properties[i]] = propertyId;
recordLabel.Append(string.Format("<{0}> l", propertyId));
if (i < node.Properties.Count - 1)
{
recordLabel.Append("|");
}
}
string dotFormatNode =
string.Format(formatCulture,
@ -46,10 +58,11 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -46,10 +58,11 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
protected override void appendPosEdge(PositionedEdge edge, StringBuilder builder)
{
string sourceNodeName = nodeNames[edge.SourceNode];
string targetNodeName = nodeNames[edge.TargetNode];
string sourceNodeName = nodeNames[edge.Source.ContainingNode];
string sourcePropertyName = propertyIds[edge.Source];
string targetNodeName = nodeNames[edge.Target];
builder.AppendLine(string.Format("{0} -> {1}", sourceNodeName, targetNodeName));
builder.AppendLine(string.Format("{0}:{1} -> {2}", sourceNodeName, sourcePropertyName, targetNodeName));
}
}
}

12
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/TreeLayouter.cs

@ -64,7 +64,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -64,7 +64,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
treeNodeFor[objectGraphNode] = newTreeNode;
double subtreeSize = 0;
foreach (ObjectProperty property in objectGraphNode.ComplexProperties)
foreach (ObjectProperty property in objectGraphNode.Properties)
{
if (property.TargetNode != null)
{
@ -82,9 +82,13 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -82,9 +82,13 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
newEdgeIsTreeEdge = true;
subtreeSize += targetTreeNode.SubtreeSize;
}
var posNodeProperty = new PositionedNodeProperty(property);
posNodeProperty.Edge = new TreeGraphEdge { IsTreeEdge = newEdgeIsTreeEdge, Name = property.Name, SourceNode = newTreeNode, TargetNode = targetTreeNode };
newTreeNode.Properties.Add(posNodeProperty);
var posNodeProperty = newTreeNode.AddProperty(property);
posNodeProperty.Edge = new TreeGraphEdge { IsTreeEdge = newEdgeIsTreeEdge, Name = property.Name, Source = posNodeProperty, Target = targetTreeNode };
}
else
{
// PositionedNodeProperty.Edge is null
newTreeNode.AddProperty(property);
}
}
subtreeSize = Math.Max(newTreeNode.LateralSizeWithMargin, subtreeSize);

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/TreeNode.cs

@ -71,7 +71,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout @@ -71,7 +71,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
get
{
foreach (PositionedEdge outEdge in this.ChildEdges)
yield return (TreeNode)outEdge.TargetNode;
yield return (TreeNode)outEdge.Target;
}
}
}

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/NamedEdge.cs

@ -28,11 +28,11 @@ namespace Debugger.AddIn.Visualizers.Graph @@ -28,11 +28,11 @@ namespace Debugger.AddIn.Visualizers.Graph
/// <summary>
/// Target node of the edge.
/// </summary>
public TTarget TargetNode { get; set; }
public TTarget Target { get; set; }
/// <summary>
/// Source node of the edge.
/// </summary>
public TSource SourceNode { get; set; }
public TSource Source { get; set; }
}
}

11
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/ObjectGraph/ObjectNode.cs

@ -43,7 +43,16 @@ namespace Debugger.AddIn.Visualizers.Graph @@ -43,7 +43,16 @@ namespace Debugger.AddIn.Visualizers.Graph
{
public int Compare(ObjectProperty prop1, ObjectProperty prop2)
{
return prop1.Name.CompareTo(prop2.Name);
// order by IsAtomic, Name
int atomic = prop2.IsAtomic.CompareTo(prop1.IsAtomic);
if (atomic != 0)
{
return atomic;
}
else
{
return prop1.Name.CompareTo(prop2.Name);
}
}
}

Loading…
Cancel
Save