Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Radial tree? (Read 1372 times)
dinesh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Mar 5th, 2008
Radial tree?
Mar 8th, 2008 at 12:27pm
Print Post  
Hi stoyo


In my project Im drawing Radial tree.But in Output
all nodes Overlap each other.. I dont know What happened..
Below i provided my source code
Code
Select All
private void fillWeb()
{
try
{



string strSql = "SELECT * FROM Web WHERE W_Parent = 1 ORDER BY W_ID";

OleDbCommand cmd = mcn.CreateCommand();
cmd.CommandText = strSql;

OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Web");
cmd.Dispose();

// Create the root of the tree.
this.mboxRoot=this.fc.Factory.CreateShapeNode(fc.Bounds.Width / 4, fc.Bounds.Height / 6, 10, 10);
//this.mboxRoot = this.fc.CreateBox(fc.Size.Width / 4, fc.Size.Height / 6, 10, 10);
this.mboxRoot.Text = "Home";
this.mboxRoot.Tag = 1;
this.mboxRoot.Brush=new MindFusion.Drawing.LinearGradientBrush(
Color.Yellow, Color.BurlyWood, 20);
//this.mboxRoot.Brush = Color.AliceBlue;

// We want all node's children to move when their parent is moved.

this.mgrpRoot=this.fc.Factory.CreateGroup(this.mboxRoot);

this.mgrpRoot.Tag = 1;
this.mboxCurrent=this.mboxRoot;
foreach (DataRow dr in ds.Tables["Web"].Rows)
{
ShapeNode b = addChild(this.mboxCurrent);
b.Tag = dr[0];
b.Text = dr[0].ToString();
b.ToolTip = dr[3].ToString() + dr[2].ToString();

if (dr[2].ToString().IndexOf(".") > 0)
{
b.Brush=new MindFusion.Drawing.SolidBrush(Color.AliceBlue);

b.Pen=new MindFusion.Drawing.Pen(Color.LightGray);

}
else
{


b.Brush=new MindFusion.Drawing.SolidBrush(Color.MintCream);

b.Pen=new MindFusion.Drawing.Pen(Color.MintCream);

addChilds(b);
}

}

ds.Dispose();
da.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}


/////////////////////// add child


private ShapeNode addChild(ShapeNode bParent)
{
// Get the group of the parent node.
Group gParent = fc.FindGroup(bParent.Tag);

// Create the new node and add it to the parent group
// so its position is updated when the parent is moved.
ShapeNode b = fc.Factory.CreateShapeNode(0, 0, 5, 5);
gParent.AttachToCorner(b,0);

// Link the parent node with the child.
DiagramLink a = fc.Factory.CreateDiagramLink(bParent, b);

a.Pen=new MindFusion.Drawing.Pen(Color.Red);

// Update the counter.
this.mintUniqueId++;
b.Tag = this.mintUniqueId;

// Start a new group to which node children will be added.
Group g = fc.Factory.CreateGroup(b);
g.Tag = this.mintUniqueId;

// Rearrange the tree.
reArrange();

return b;
}


private void reArrange()
{
if (this.mtl == null)
{

this.mtl = new MindFusion.Diagramming.Layout.TreeLayout (this.mboxRoot,
MindFusion.Diagramming.Layout.TreeLayoutType.Radial, false, MindFusion.Diagramming.Layout.TreeLayoutLinkType.Rounded,
MindFusion.Diagramming.Layout.TreeLayoutDirection.TopToBottom, 169, 120, true,new SizeF(10, 10), true);
}

this.mtl.Arrange(this.fc);
}
//////////////////////////////


private void addChilds(ShapeNode pBox)
{

try
{
 String strSql = "SELECT * FROM Web WHERE W_Parent = " + pBox.Tag.ToString() + " ORDER BY W_ID";
OleDbCommand cmd = mcn.CreateCommand();
cmd.CommandText = strSql;

OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "User_Log");
cmd.Dispose();

if (ds.Tables["User_Log"].Rows.Count > 0)
{
// We want all node's children to move when their parent is moved.
Group grp = this.fc.Factory.CreateGroup(pBox);
pBox.Tag=this.mgrpRoot.Tag;

foreach (	    DataRow dr in ds.Tables["User_Log"].Rows)
{
ShapeNode b = addChild(pBox);
b.Tag = dr[0];
b.Text = dr[0].ToString();
b.ToolTip = dr[3].ToString() + dr[2].ToString();

if (dr[2].ToString().IndexOf(".") > 0)
{


b.Brush=new MindFusion.Drawing.SolidBrush(Color.AliceBlue);

b.Pen=new MindFusion.Drawing.Pen(Color.LightGray);




}
else
{

b.Brush=new MindFusion.Drawing.SolidBrush(Color.MintCream);

b.Pen=new MindFusion.Drawing.Pen(Color.LightGray);

addChilds(b);
}
}
}

ds.Dispose();
da.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}




 





I dont know how to insert image in this forum that's why i hav Given source code ,,Pls dont mistake me
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Radial tree?
Reply #1 - Mar 9th, 2008 at 11:42am
Print Post  
Hi Dinesh,

I haven't tried your code, but I can see you are creating a group where all child nodes are attached to the root, and then running the radial layout with the KeepGroupLayout option enabled (the last argument in the TreeLayout constructor)? When using KeepGroupLayout, the layout algorithm treats each group as a single compound node in the graph. This effectively makes TreeLayout process your whole tree as a single node, preserving the initial positions of the child nodes relatively to the root. So try how that will work with KeepGroupLayout = false.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
dinesh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Mar 5th, 2008
Re: Radial tree?
Reply #2 - Mar 11th, 2008 at 9:31am
Print Post  
Yes I made mistake in constructor.. Thanks a lot stoyo
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint