Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Arrange Nodes in Circular - Oval Shape (Read 1478 times)
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Arrange Nodes in Circular - Oval Shape
Feb 13th, 2010 at 6:30am
Print Post  
Dear Stoyo

Is there a way to show the layout in OVal shape?
i had seen the samples of layout in which i can use the Circular only. But my requirement is - To show the nodes in Circular path of oval shape or Rectangle shape path
pls help me to achieve this.


Thanks
Muthuhamid
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrange Nodes in Circular - Oval Shape
Reply #1 - Feb 13th, 2010 at 12:41pm
Print Post  
Hi Muthuhamid,

Internally CircularLayout finds a linear oder of nodes that ensures a small number of link crossings when nodes are placed on the rim of a circle. This should work for any convex shape, so you could reuse the internal implementation from the MindFusion.Graphs assembly to map the linear node order to a different shape, e.g. a square as shown below.

Code
Select All
// create a graph object representing the diagram
var graphToDiagMapNodes = new Dictionary<Vertex, DiagramNode>();
var graphToDiagMapLinks = new Dictionary<Edge, DiagramLink>();
var graph = GraphFromDiagram(diagram, graphToDiagMapNodes, graphToDiagMapLinks);

// find node ordering that ensures small number of crossings
var drawing = new CircularDrawing(graph, 2);

// map the nodes linear order to a square shape
var sideLength = 100.0f;
var circumference = sideLength * 4;
var counter = 0;
foreach (Vertex vertex in drawing.VertexOrder)
{
	var cpos = counter * circumference / graph.Vertices.Count;
	var nodePos = new System.Drawing.PointF(0, 0);
	if (cpos < sideLength)
		// top side
		nodePos = new System.Drawing.PointF(cpos, 0);
	else if (cpos < sideLength * 2)
		// right side
		nodePos = new System.Drawing.PointF(sideLength, cpos - sideLength);
	else if (cpos < sideLength * 3)
		// bottom side
		nodePos = new System.Drawing.PointF(sideLength * 3 - cpos, sideLength);
	else
		// left side
		nodePos = new System.Drawing.PointF(0, sideLength * 4 - cpos);

	var node = graphToDiagMapNodes[vertex];
	node.Move(nodePos.X - node.Bounds.Width / 2, nodePos.Y - node.Bounds.Height / 2);
	counter++;
}
 



You can find the GraphFromDiagram code here:
http://mindfusion.eu/Forum/YaBB.pl?board=diaglite_disc;action=display;num=125001...

I hope that helps,
Stoyan
« Last Edit: Oct 14th, 2013 at 12:18pm by Stoyo »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint