The MindFusion Forums
Flow Diagramming Components >> Android >> Define 4 corners of a shape node
https://mindfusion.eu/Forum/YaBB.pl?num=1562641589

Message started by Ngo Duc Quang on Jul 9th, 2019 at 3:06am

Title: Define 4 corners of a shape node
Post by Ngo Duc Quang on Jul 9th, 2019 at 3: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.


Screenshot_20190709-095027.png ( 169 KB | 214 Downloads )

Title: Re: Define 4 corners of a shape node
Post by Slavcho on Jul 9th, 2019 at 7: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()[/code]


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

Title: Re: Define 4 corners of a shape node
Post by Ngo Duc Quang on Aug 2nd, 2019 at 1:43am
setOriginAnchor/setDestinationAnchor?
I read the document: An integer value specifying the index of the origin anchor point.
what values ​​are received?

Title: Re: Define 4 corners of a shape node
Post by Slavcho on Aug 2nd, 2019 at 6: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

Title: Re: Define 4 corners of a shape node
Post by Ngo Duc Quang on Aug 2nd, 2019 at 9: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


Title: Re: Define 4 corners of a shape node
Post by Slavcho on Aug 2nd, 2019 at 10:42am
Yes, these are correct sides if you mean the comments.

Title: Re: Define 4 corners of a shape node
Post by Ngo Duc Quang on Aug 5th, 2019 at 2:29am
Thank you very much!  ;D

The MindFusion Forums » Powered by YaBB 2.6.11!
YaBB Forum Software © 2000-2024. All Rights Reserved.