Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic OrthogonalLayout.Arrange error (Read 1935 times)
TimNZ
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 23rd, 2009
OrthogonalLayout.Arrange error
Mar 15th, 2009 at 3:08am
Print Post  
A number of errors are thrown, play source code follows.

I'm developing a simple tool to import schema definitions from a CRM product and display tables with foreign key links which don't use foreign key rel but some other meta data.

Sample input is three tables.

I can get one of the following:

No nodes in diagram:
Code
Select All
System.ArgumentOutOfRangeException occurred
  Message="Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"
  Source="mscorlib"
  ParamName="index"
  StackTrace:
       at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
       at System.ThrowHelper.ThrowArgumentOutOfRangeException()
       at System.Collections.Generic.List`1.get_Item(Int32 index)
       at MindFusion.Graphs.Graph.xc8338fd6506eada4(Int32 xb6a159a84cb992d6, Int32 xedfe2ee58715c12f, List`1 xf30b13768f720212)
       at MindFusion.Graphs.Graph.MakeBiconnected()
       at MindFusion.Graphs.OrthogonalDrawing..ctor(Graph graph, Boolean directed)
       at MindFusion.Layout.x6c49a7edd6c3dab9.xb7874248b0c0bc2d(x5e63d74830b5db57 x43be2e1940c135f9, xd73e2a0d3761a797 x8d3f74e5f925679c, x78e3ce9dc43283f0 x22bfd1664c623dc4)
       at MindFusion.Diagramming.Layout.OrthogonalLayout.Arrange(Diagram diagram, DiagramItemCollection items)
       at MindFusion.Diagramming.Layout.Layout.Arrange(Diagram diagram)
       at PivotalDocumenter.MainForm.btnDiagram_Click(Object sender, EventArgs e) in C:\Development\PivotalDocumenter\MainForm.cs:line 140
  InnerException:

 



Nodes, even just one:
Code
Select All
System.ArgumentException occurred
  Message="An item with the same key has already been added."
  Source="mscorlib"
  StackTrace:
       at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
       at MindFusion.Graphs.Set`1.Add(T element)
       at MindFusion.Graphs.DualGraph.GetFaceVertices(List`1 faceList)
       at MindFusion.Graphs.Graph.Planarize(Dictionary`2 edgeToDummyEdgesMap)
       at MindFusion.Graphs.OrthogonalDrawing..ctor(Graph graph, Boolean directed)
       at MindFusion.Layout.x6c49a7edd6c3dab9.xb7874248b0c0bc2d(x5e63d74830b5db57 x43be2e1940c135f9, xd73e2a0d3761a797 x8d3f74e5f925679c, x78e3ce9dc43283f0 x22bfd1664c623dc4)
       at MindFusion.Diagramming.Layout.OrthogonalLayout.Arrange(Diagram diagram, DiagramItemCollection items)
       at MindFusion.Diagramming.Layout.Layout.Arrange(Diagram diagram)
       at PivotalDocumenter.MainForm.btnDiagram_Click(Object sender, EventArgs e) in C:\Development\PivotalDocumenter\MainForm.cs:line 140
  InnerException:
 



or

Code
Select All
System.Collections.Generic.KeyNotFoundException occurred
  Message="The given key was not present in the dictionary."
  Source="mscorlib"
  StackTrace:
       at System.ThrowHelper.ThrowKeyNotFoundException()
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at MindFusion.Graphs.DualGraph.GetIncidentFaces(Vertex v)
       at MindFusion.Graphs.DualGraph.SplitExternalFace(Vertex s, Vertex t)
       at MindFusion.Graphs.Representation..ctor(Graph stGraph, Boolean weighted)
       at MindFusion.Graphs.OrthogonalDrawing..ctor(Graph graph, Boolean directed)
       at MindFusion.Layout.x6c49a7edd6c3dab9.xb7874248b0c0bc2d(x5e63d74830b5db57 x43be2e1940c135f9, xd73e2a0d3761a797 x8d3f74e5f925679c, x78e3ce9dc43283f0 x22bfd1664c623dc4)
       at MindFusion.Diagramming.Layout.OrthogonalLayout.Arrange(Diagram diagram, DiagramItemCollection items)
       at MindFusion.Diagramming.Layout.Layout.Arrange(Diagram diagram)
       at PivotalDocumenter.MainForm.btnDiagram_Click(Object sender, EventArgs e) in C:\Development\PivotalDocumenter\MainForm.cs:line 140
  InnerException:
 



  
Back to top
 
IP Logged
 
TimNZ
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 23rd, 2009
Re: OrthogonalLayout.Arrange error
Reply #1 - Mar 15th, 2009 at 3:09am
Print Post  
Sample code.  I've tried simplifying as much as possible but it makes no difference.

Code
Select All
	  private void btnDiagram_Click(object sender, EventArgs e)
	  {
		foreach (CheckedListBoxItem i in lbTables.CheckedItems)
		{
		    Table table = i.Value as Table;
		    if (!_AddedTableNodes.ContainsKey(table.Name))
		    {
			  TableNode tn = new TableNode(diagram1);
			  table.TableNode = tn;
			  tn.OffsetHeaderRows = true;
			  tn.Tag = table;
			  tn.RedimTable(2, 1);
			  tn[0, 0].Text = table.PrimaryField.FieldName;
			  tn[1, 0].Text = "Key";
			  tn.Caption = "<b>" + table.Name + "</b>";
			  tn.EnableStyledText = true;

			  diagram1.Nodes.Add(tn);

			  _AddedTableNodes.Add(table.Name, tn);
		    }
		}

		foreach ( TableNode tableNode in _AddedTableNodes.Values)
		{
		    foreach ( TableField field in ((Table) tableNode.Tag).Fields.Values)
		    {
			  Table foreignTable = field.ForeignTable;
			  if (foreignTable != null && _AddedTableNodes.ContainsKey(foreignTable.Name ))
			  {
				int row = tableNode.AddRow();

				tableNode[0, row].Text = field.FieldName;
				tableNode[1, row].Text = "F";
				DiagramLink dl = new DiagramLink(diagram1, tableNode, foreignTable.TableNode);
				dl.AutoRoute = true;
				diagram1.Links.Add(dl);



			  }
		    }

		    tableNode.ResizeToFitText(false);

		    float newHeight = tableNode.CaptionHeight +
			  Constants.GetPixel(diagram1.MeasureUnit) +
			  3 * tableNode.Pen.Width;
		    foreach (TableNode.Row row in tableNode.Rows)
			  newHeight += row.Height;

		    tableNode.Resize(tableNode.Bounds.Width, newHeight);



		}

		OrthogonalLayout layout =new OrthogonalLayout();
		layout.Anchoring = Anchoring.Reassign;
		layout.Refine = true;
		layout.Arrange(diagram1);
		diagram1.ResizeToFitItems(5);



	  }

 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint