Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Arrows and routing (Read 5428 times)
iazeibak
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!
A little.

Posts: 14
Joined: Jul 27th, 2007
Arrows and routing
Feb 6th, 2008 at 10:18pm
Print Post  
I am first drawing background boxes, smaller boxes then drawing the arrows between them. When I auto route the arrows they turn out very bad looking, because it is not clear which arrows are going where.



However, when I turn off autorouting, I get a clearer view of some of the arrows but not the others. It would be fine if they did not slice through the boxes.



I guess what I am asking is if there is autorouting that makes it a bit clearer, or a way to not use autorouting while making the boxes an obstacle.
  

Jdiagram-ing,&&&&Issam
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrows and routing
Reply #1 - Feb 7th, 2008 at 7:21am
Print Post  
It should look better if you distribute the link points uniformly along the respective box side. E.g. assuming the links will go from left to right:

Code
Select All
fc.addFlowChartListener(new FlowChartAdapter()
{
	public void itemCreated(ItemEvent e)
	{
		if (e.getItem() instanceof Arrow)
		{
			Arrow arrow = (Arrow)e.getItem();
			distributeOutgoingLinks(arrow.getOrigin());
			distributeIncomingLinks(arrow.getDestination());
		}
	}
}

 void distributeOutgoingLinks(Node node)
 {
	ArrowList al = node.getOutgoingArrows();
	for (int i = 0; i < al.size(); ++i)
	{
		Arrow a = al.get(i);
		a.getControlPoints().get(0).y =
			node.getBounds().y + node.getBounds().height * (i+1) / (al.size() + 1);
		a.updateFromPoints();
	}
	for (int i = 0; i < al.size(); ++i)
	{
		Arrow a = al.get(i);
		a.route();
	}
 }

 void distributeIncomingLinks(Node node)
 {
	ArrowList al = node.getIncomingArrows();
	for (int i = 0; i < al.size(); ++i)
	{
		Arrow a = al.get(i);
		a.getControlPoints().get(a.getControlPoints().size() - 1).y =
			node.getBounds().y + node.getBounds().height * (i+1) / (al.size() + 1);
		a.updateFromPoints();
	}
	for (int i = 0; i < al.size(); ++i)
	{
		Arrow a = al.get(i);
		a.route();
	}
 }
 



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


I love YaBB 1G - SP1!
A little.

Posts: 14
Joined: Jul 27th, 2007
Re: Arrows and routing
Reply #2 - Feb 8th, 2008 at 4:12pm
Print Post  
My boxes have anchors attached to them (one on each side exactly in the middle) and are pregenerated and displayed as a .png file. FlowChartListener seems to be for a more dynamic situation.
  

Jdiagram-ing,&&&&Issam
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrows and routing
Reply #3 - Feb 8th, 2008 at 6:08pm
Print Post  
Well then, instead of using anchor points, calculate the point coordinates in the same manner (uniform distribution along one side of the box) while generating the diagram and pass them to createArrow. You will have to know how many outgoing and incoming links will be created, in order to find out at what distance from each other to place their end points. If you don't know that beforehand, just move the points after all links are created.

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


I love YaBB 1G - SP1!
A little.

Posts: 14
Joined: Jul 27th, 2007
Re: Arrows and routing
Reply #4 - Feb 11th, 2008 at 9:08pm
Print Post  
It's looking much better, thank you for yoru advice!

I find for the ones that are parallel that it looks better if I do not route them. However, when I use this there the flows lean to the side of the box:



I would like for the arrow to come out a bit and then turn as it does usually with th autorouting. Is this possible without auotorouting these arrows?
  

Jdiagram-ing,&&&&Issam
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrows and routing
Reply #5 - Feb 12th, 2008 at 6:37am
Print Post  
Try auto routing with a higher turn cost, then the control should tend to create fewer bends and parallel links might look better.

Otherwise, add more segments to the link using setSegmentCount(3) and assign the following coordinates to the control points:

p0 = [orgx, orgy]
p1 = [orgx + nodeDist, orgy]
p2 = [orgx + nodeDist, dsty]
p3 = [dstx, dsty]

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