Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Define 4 corners of a shape node (Read 3854 times)
Ngo Duc Quang
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Location: Ha Noi
Joined: Jun 10th, 2019
Define 4 corners of a shape node
Jul 9th, 2019 at 3:06am
Print Post  
Hi, I have a Json string that contains data of a node list and a link list (json retrieved from the server), I have some problems:
- In the image file I have attached, in the red circle area, the node creates the link itself. how to fix it?
- I want to define 4 corners of a shape node (top, bottom, left, right) to create the correct link?

I want to show you a part of my Json data:
"linkDataArray" : [
{
"from" : 1, // id shape node from
"to" : 3, // id shape node to
"fromPort" : R, // The starting position of the link (R: right, L: left, T: top, B: bottom)
"toPort" : L, // End position of link
"visible" : true,
"text" : Điều kiện,
"isDeletable" : false,
"points" : null
}
]
The above json section shows when creating the link.

  

Screenshot_20190709-095027.png ( 169 KB | 212 Downloads )
Screenshot_20190709-095027.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3146
Joined: Oct 19th, 2005
Re: Define 4 corners of a shape node
Reply #1 - Jul 9th, 2019 at 7:45am
Print Post  
Quote:
- In the image file I have attached, in the red circle area, the node creates the link itself. how to fix it?


If you call createDiagramLink(sameNode, sameNode), the control assigns a self-loop Bezier shape to it, but that doesn't seem to consider the case when the self-loop link connects different anchor points. After creating the link and assigning the anchor points, you can set the link shape to whatever you like, e.g. try something like this -

Code
Select All
PointF start = link.getStartPoint();
PointF end = link.getEndPoint();
link.setShape(LinkShape.Polyline);
link.setSegmentCount(4);

// case for right to top directon
PointList points = link.getControlPoints();
points.set(0, start);
points.set(1, new PointF(start.x + offset, start.y));
points.set(2, new PointF(start.x + offset, end.y - offset));
points.set(3, new PointF(end.x, end.y - offset));
points.set(4, end));
link.updateFromPoints() 



Quote:
- I want to define 4 corners of a shape node (top, bottom, left, right) to create the correct link?


Copy the first AnchorPattern definition from AnchorPoints sample project and assign it to your nodes, and then match your R/L/T/B port values to the respective point indices when you call setOriginAnchor / setDestinationAnchor.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Ngo Duc Quang
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Location: Ha Noi
Joined: Jun 10th, 2019
Re: Define 4 corners of a shape node
Reply #2 - Aug 2nd, 2019 at 1:43am
Print Post  
setOriginAnchor/setDestinationAnchor?
I read the document: An integer value specifying the index of the origin anchor point.
what values ​​are received?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3146
Joined: Oct 19th, 2005
Re: Define 4 corners of a shape node
Reply #3 - Aug 2nd, 2019 at 6:06am
Print Post  
Value is the index of AnchorPoint element within AnchorPattern's list. Try setting these from within the AnchorPoints sample project to see how they work.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Ngo Duc Quang
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Location: Ha Noi
Joined: Jun 10th, 2019
Re: Define 4 corners of a shape node
Reply #4 - Aug 2nd, 2019 at 9:20am
Print Post  
Is this the correct answer?:

new AnchorPoint(50, 0, true, true), // TOP
new AnchorPoint(100, 50, true, true), // RIGHT
new AnchorPoint(50, 100, true, true), // BOTTOM
new AnchorPoint(0, 50, true, true) // LEFT

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3146
Joined: Oct 19th, 2005
Re: Define 4 corners of a shape node
Reply #5 - Aug 2nd, 2019 at 10:42am
Print Post  
Yes, these are correct sides if you mean the comments.
  
Back to top
 
IP Logged
 
Ngo Duc Quang
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Location: Ha Noi
Joined: Jun 10th, 2019
Re: Define 4 corners of a shape node
Reply #6 - Aug 5th, 2019 at 2:29am
Print Post  
Thank you very much!  Grin
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint