- Welcome, Guest. Please Login or Register
MindFusion  
  We have released initial version of MindFusion.JavaScript pack. It includes chart, diagram, calendar, map, virtual keyboard, gauge and UI components. Here are more details and live demo for anyone interested.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Define 4 corners of a shape node
Read 274 times

Ngo Duc Quang   Offline
YaBB Newbies
*
Posts: 14
Gender: male
Ha Noi
I Love MindFusion!


   
     
 
Define 4 corners of a shape node
Jul 9th, 2019 at 4:06am
 
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.

 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1829
Gender: male
tech.support


   
     
 
Re: Define 4 corners of a shape node
Reply #1 - Jul 9th, 2019 at 8:45am
 
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:
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
 
 
 
IP Logged    
 
     

Ngo Duc Quang   Offline
YaBB Newbies
*
Posts: 14
Gender: male
Ha Noi
I Love MindFusion!


   
     
 
Re: Define 4 corners of a shape node
Reply #2 - Aug 2nd, 2019 at 2:43am
 
setOriginAnchor/setDestinationAnchor?
I read the document: An integer value specifying the index of the origin anchor point.
what values ​​are received?
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1829
Gender: male
tech.support


   
     
 
Re: Define 4 corners of a shape node
Reply #3 - Aug 2nd, 2019 at 7:06am
 
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
 
 
 
IP Logged    
 
     

Ngo Duc Quang   Offline
YaBB Newbies
*
Posts: 14
Gender: male
Ha Noi
I Love MindFusion!


   
     
 
Re: Define 4 corners of a shape node
Reply #4 - Aug 2nd, 2019 at 10:20am
 
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

 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1829
Gender: male
tech.support


   
     
 
Re: Define 4 corners of a shape node
Reply #5 - Aug 2nd, 2019 at 11:42am
 
Yes, these are correct sides if you mean the comments.
 
 
 
IP Logged    
 
     

Ngo Duc Quang   Offline
YaBB Newbies
*
Posts: 14
Gender: male
Ha Noi
I Love MindFusion!


   
     
 
Re: Define 4 corners of a shape node
Reply #6 - Aug 5th, 2019 at 3:29am
 
Thank you very much!  Grin
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print