Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Manually defining link (Read 4972 times)
Miklos
YaBB Newbies
*
Offline



Posts: 5
Joined: Sep 30th, 2009
Manually defining link
Oct 5th, 2009 at 4:49pm
Print Post  
Hi,

I'm new to JDiagram and unfortunatelly I ran into a problem. I would like to make a flowchart, which contains a loop start and loop end node. I defined anchor points at the middle of the four side of the nodes. I've added a link which points from the loopstart's bottom anchor point to the loopend's top anchor point. That's fine. I also wanted to add another link which points from loopend's right side to the loopstart' right side. I set it to be a cascading link from 3 segments. The problem is that the link point straight from my loopend to my loopstart. I also tried setCascadeOrientation(Orientation.Horizontal) but nothing happened. I've maked the desired behavior with red.


Thanks in advance,
Miklos
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Manually defining link
Reply #1 - Oct 5th, 2009 at 6:00pm
Print Post  
Hi,

The default behavior it to place the control points on a straight line, which does not look nice in that case.

You might call the DiagramLink.route() method to find a path that goes further from the nodes, or set the AutoRoute property. You can control to some extent where links make their first and last bends by setting the NodeVicinityProperty in RoutingOptions.

Another option is to assign new point positions to the link's ControlPoints list.

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



Posts: 5
Joined: Sep 30th, 2009
Re: Manually defining link
Reply #2 - Oct 6th, 2009 at 11:14am
Print Post  
Hi Stoyo,

Thanks for the answer. The route() almost worked well. Here's the result:

It forgot to draw one line.

I found setNodeVicinityCost and setNodeVicinitySize in routing options. Can you explain how can I use this to achieve my goal?

Maybe the best solution would be to have exact control of the link positioning(I have to handle deleting/inserting nodes also). You mentioned Control Points. Can you tell me how can I assign new point positions to them?
Thanks in advance,
Miklos
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Manually defining link
Reply #3 - Oct 6th, 2009 at 11:27am
Print Post  
Could you email us this saved as xml when you get the disappearing link? What kind of OS are you using by the way?

Setting the link points from code should look like this:

link.setSegmentCount(3);
link.getControlPoints.set(0, p0);
link.getControlPoints.set(1, p1);
link.getControlPoints.set(2, p2);
link.getControlPoints.set(3, p3);
link.updateFromPoints();

Where the px variables are Point2D.Float objects whose coordinates correspond to the link shape you need.

Stoyan
  
Back to top
 
IP Logged
 
Miklos
YaBB Newbies
*
Offline



Posts: 5
Joined: Sep 30th, 2009
Re: Manually defining link
Reply #4 - Oct 6th, 2009 at 11:28am
Print Post  
Additionally to my previous questions I have another linking question.
In some case when I insert a node, I would like to add a link pointing out from my node. This link has no node at the endpoint it just indicates the position of the next node. Is it possible to do this with a link? Or do I have to create an invisible nodepoint for the ending of the link?
Another thing I would like to achieve is whenever I add a "condition node" I want to add links to the node to achieve the following result:

How can I do that?
Best Regards,
Miklos
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Manually defining link
Reply #5 - Oct 6th, 2009 at 11:35am
Print Post  
You could use the createDiagramLink(node, Point2D) method to create such links. You might also do that by adding some invisible nodes attached to the condition node and connecting the links to them. This will help if you need the "unconnected" link ends to follow the condition node when it is moved.
  
Back to top
 
IP Logged
 
Miklos
YaBB Newbies
*
Offline



Posts: 5
Joined: Sep 30th, 2009
Re: Manually defining link
Reply #6 - Oct 6th, 2009 at 11:42am
Print Post  
Thanks for the quick replys Stoyo.
Can i attach files to the post somehow?
I've uploaded the exported diagram to
http://senduit.com/379ccd

Edit: I forgot to answer for your previous question: I'm using linux.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Manually defining link
Reply #7 - Oct 6th, 2009 at 12:27pm
Print Post  
I couldn't open this diagram.xml, the XML parser is throwing some encoding exceptions. Could you try sending me one saved in binary format? You might email files to support@mindfusion.eu, I'll get a copy.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Manually defining link
Reply #8 - Oct 6th, 2009 at 1:30pm
Print Post  
The link is painted fine here after loading the file and also after route(). In case it's some repainting problem, could you try calling DiagramView.repaint() after route()?
  
Back to top
 
IP Logged
 
Miklos
YaBB Newbies
*
Offline



Posts: 5
Joined: Sep 30th, 2009
Re: Manually defining link
Reply #9 - Oct 7th, 2009 at 3:18pm
Print Post  
I modified the code since then at several places and the problem disappeared, so unfortunatelly(or fortunatelly) I can't reproduce it anymore. Thanks for helping
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint