Browse Source

Object graph visualizer - all doubles for communication with Graphviz's Neato are formatted to 3 decimal places - Neato crashed on some inputs, hopefully fixed now.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4281 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Martin Koníček 17 years ago
parent
commit
a27db5bb6e
  1. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  2. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/BoxDotFormatter.cs
  3. 6
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/DotFormatter.cs
  4. 39
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/NeatoDoubleFormatter.cs
  5. 6
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/RecordDotFormatter.cs

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -185,6 +185,7 @@
<Compile Include="Src\Visualizers\Graph\Layout\Tree\DotFormatter.cs" /> <Compile Include="Src\Visualizers\Graph\Layout\Tree\DotFormatter.cs" />
<Compile Include="Src\Visualizers\Graph\Layout\Tree\IdGenerator.cs" /> <Compile Include="Src\Visualizers\Graph\Layout\Tree\IdGenerator.cs" />
<Compile Include="Src\Visualizers\Graph\Layout\Tree\LayoutDirection.cs" /> <Compile Include="Src\Visualizers\Graph\Layout\Tree\LayoutDirection.cs" />
<Compile Include="Src\Visualizers\Graph\Layout\Tree\NeatoDoubleFormatter.cs" />
<Compile Include="Src\Visualizers\Graph\Layout\Tree\NeatoEdgeRouter.cs" /> <Compile Include="Src\Visualizers\Graph\Layout\Tree\NeatoEdgeRouter.cs" />
<Compile Include="Src\Visualizers\Graph\Layout\Tree\NeatoPositionTransform.cs" /> <Compile Include="Src\Visualizers\Graph\Layout\Tree\NeatoPositionTransform.cs" />
<Compile Include="Src\Visualizers\Graph\Layout\Tree\NeatoProcess.cs" /> <Compile Include="Src\Visualizers\Graph\Layout\Tree\NeatoProcess.cs" />

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

@ -27,7 +27,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
Rect neatoInput = transform.NodeToNeatoInput(node); Rect neatoInput = transform.NodeToNeatoInput(node);
string dotFormatNode = string dotFormatNode =
string.Format(formatCulture, string.Format(this.neatoDoubleFormatter,
"{0} [pos=\"{1},{2}!\" width=\"{3}\" height=\"{4}\"];", "{0} [pos=\"{1},{2}!\" width=\"{3}\" height=\"{4}\"];",
nodeName, neatoInput.Location.X, neatoInput.Location.Y, neatoInput.Width, neatoInput.Height); nodeName, neatoInput.Location.X, neatoInput.Location.Y, neatoInput.Width, neatoInput.Height);
builder.AppendLine(dotFormatNode); builder.AppendLine(dotFormatNode);

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

@ -23,12 +23,12 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
protected NeatoPositionTransform transform; protected NeatoPositionTransform transform;
protected NeatoDoubleFormatter neatoDoubleFormatter = new NeatoDoubleFormatter();
// state (node and edge names) needed for parsing back // state (node and edge names) needed for parsing back
protected Dictionary<PositionedNode, string> nodeNames = new Dictionary<PositionedNode, string>(); protected Dictionary<PositionedNode, string> nodeNames = new Dictionary<PositionedNode, string>();
protected Dictionary<PositionedEdge, string> edgeNames = new Dictionary<PositionedEdge, string>(); protected Dictionary<PositionedEdge, string> edgeNames = new Dictionary<PositionedEdge, string>();
protected CultureInfo formatCulture = CultureInfo.GetCultureInfo("en-US");
/// <summary> /// <summary>
/// Used for generating node and edge names. /// Used for generating node and edge names.
/// </summary> /// </summary>
@ -136,7 +136,7 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
private double readDouble(TextReader reader) private double readDouble(TextReader reader)
{ {
return double.Parse(readWord(reader), formatCulture); return double.Parse(readWord(reader), this.neatoDoubleFormatter.DoubleCulture);
} }
private int readInt(TextReader reader) private int readInt(TextReader reader)

39
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Graph/Layout/Tree/NeatoDoubleFormatter.cs

@ -0,0 +1,39 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Martin Koníček" email="martin.konicek@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Globalization;
namespace Debugger.AddIn.Visualizers.Graph.Layout
{
/// <summary>
/// When used as IFormatProvider in string.Format, formats doubles to be suitable for Neato.
/// </summary>
public class NeatoDoubleFormatter : IFormatProvider, ICustomFormatter
{
private CultureInfo doubleCulture = CultureInfo.GetCultureInfo("en-US");
/// <summary>
/// CultureInfo used for formatting and parsing doubles (en-US).
/// </summary>
public CultureInfo DoubleCulture
{
get { return this.doubleCulture; }
}
public object GetFormat(Type formatType)
{
if (formatType == typeof(ICustomFormatter))
return this;
else
return null;
}
public string Format(string format, object arg, IFormatProvider formatProvider)
{
return string.Format(doubleCulture, "{0:0.000}", arg);
}
}
}

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

@ -12,7 +12,7 @@ using System.Windows;
namespace Debugger.AddIn.Visualizers.Graph.Layout namespace Debugger.AddIn.Visualizers.Graph.Layout
{ {
/// <summary> /// <summary>
/// <see cref="DotFormatter"/> that treats nodes as records of properties. /// <see cref="DotFormatter"/> that treats nodes as records of properties.
/// Edges start at property, end at node. /// Edges start at property, end at node.
/// </summary> /// </summary>
public class RecordDotFormatter : DotFormatter public class RecordDotFormatter : DotFormatter
@ -48,9 +48,9 @@ namespace Debugger.AddIn.Visualizers.Graph.Layout
} }
string dotFormatNode = string dotFormatNode =
string.Format(formatCulture, string.Format(this.neatoDoubleFormatter,
"{0} [pos=\"{1},{2}!\" width=\"{3}\" height=\"{4}\" label=\"{5}\"];", "{0} [pos=\"{1},{2}!\" width=\"{3}\" height=\"{4}\" label=\"{5}\"];",
nodeName, nodeName,
neatoInput.Location.X, neatoInput.Location.Y, neatoInput.Width, neatoInput.Height, neatoInput.Location.X, neatoInput.Location.Y, neatoInput.Width, neatoInput.Height,
recordLabel.ToString()); recordLabel.ToString());
builder.AppendLine(dotFormatNode); builder.AppendLine(dotFormatNode);

Loading…
Cancel
Save