Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) TreeLayout (Read 11113 times)
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
TreeLayout
Sep 24th, 2015 at 1:40pm
Print Post  
Hi,
how can I select the nodes that must partecipate in a treeLayout? I want to create a TreeLayout among a specified set of nodes.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout
Reply #1 - Sep 24th, 2015 at 1:58pm
Print Post  
Hi,

You can pass diagram.getSelection().getItems() to arrange(DiagramItemList) overload if user will also select the links. Otherwise you will have to loop over all selected nodes and collect the nodes and links programmatically.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
Re: TreeLayout
Reply #2 - Sep 24th, 2015 at 2:06pm
Print Post  
Sorry but it doesn't work, because method arrange wants a Diagram and not a DiagramItemList
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout
Reply #3 - Sep 24th, 2015 at 4:53pm
Print Post  
Ok, this overload is not available for TreeLayout. It only lets you arrange subsets of the tree by specifying the branch' root node via TreeLayout.setRoot method. Depending on what you are trying to do:
- call arrange from a loop, each iteration using next selected node as a root
- or find the common ancestor of all selected nodes and set it as a root, calling arrange a single time.
  
Back to top
 
IP Logged
 
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
Re: TreeLayout
Reply #4 - Sep 25th, 2015 at 11:44am
Print Post  
Ok, thank you very much Smiley
The problem is that I have a list of nodes and I want to create a tree(or something similar) only among these nodes, but if I use a tree layout it takes all nodes present in the diagram while I want only the nodes belonging to the list to be part of the tree. I have the nodes in this list:
List<ShapeNode> treeNodes where the node at the second position must be the root, how can I create a treeLayout only among these nodes?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout
Reply #5 - Sep 25th, 2015 at 3:51pm
Print Post  
Set that second node from list as TreeLayout.Root, and also enable the KeepRootPosition property so the layout does not move it, but only the children. If the nodes are already connected with links, TreeLayout should arrange them under the root then without modifying the rest of the tree. If there are child nodes that should not be arranged, you could set their IgnoreLayout property.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
Re: TreeLayout
Reply #6 - Sep 25th, 2015 at 4:09pm
Print Post  
I did it but it doesn't work, by setting ignoreLayout to true it simply draws it in a different way but still connect the node that should be ignored, I want the node that should be ignored to be connected to the root of the layout and not to other node.
  
Back to top
 
IP Logged
 
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
Re: TreeLayout
Reply #7 - Sep 25th, 2015 at 5:13pm
Print Post  
Hi,
I solved the problem, I manage it in a different way and now it does what I want, thank you anyway Smiley
  
Back to top
 
IP Logged
 
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
Re: TreeLayout
Reply #8 - Sep 28th, 2015 at 1:54pm
Print Post  
Hi,
sorry but I have another problem with tree layout, I have something like in the attachment, I called method setText on the bigger link but it wrote the text, (Text) in the example,  in rect1 while I want to write it in the middle of the bigger link.
  

ex2.png ( 5 KB | 146 Downloads )
ex2.png
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout
Reply #9 - Sep 29th, 2015 at 9:11am
Print Post  
Hi,

If that arrow shape is a DiagramLink instance, try setting a different LinkTextStyle via DiagramLink.setTextStyle method, or alternatively use LinkLabel objects, which give you more control over positioning.

If it's a ShapeNode with a custom shape, you might have specified a text region that's above the main graphics. In such case remove the text region definition from Shape constructor and the control should use the graphics outline for text too.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
Re: TreeLayout
Reply #10 - Sep 29th, 2015 at 9:57am
Print Post  
Ok, thank you very much, I used LinkLabel and it works.
But is there a way to take the length of the arrow headShape?
Because I want to put the label just under the arraow, like this:
  

ex.png ( 2 KB | 139 Downloads )
ex.png
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout
Reply #11 - Sep 29th, 2015 at 3:25pm
Print Post  
Call the getHeadShapeSize method to find the default size, or setHeadShapeSize to set your own size.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
Re: TreeLayout
Reply #12 - Sep 29th, 2015 at 3:36pm
Print Post  
Thank you very much Smiley
  
Back to top
 
IP Logged
 
Silvia88
Full Member
***
Offline


I Love MindFusion!

Posts: 121
Joined: Aug 31st, 2015
Re: TreeLayout
Reply #13 - Sep 30th, 2015 at 5:42pm
Print Post  
Hi, is there a way to know if a node belong to a TreeLayout?
Because I need to know it when I load the diagram from a saved file
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout
Reply #14 - Sep 30th, 2015 at 6:19pm
Print Post  
Hi,

There's nothing built-in to keep track of nodes processed by TreeLayout. You could mark them as processed by setting their Tag property from some recursive function you call starting with TreeLayout.Root node:

Code
Select All
void markProcessed(DiagramNode node)
{
    node.setTag(true);
    for (DiagramLink link : node.getOutgoingLinks()) // or incoming depending on tree direction
    {
        markProcessed(link.getDestination()); // or getOrigin
    }
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint