Changing points of a link

Im building an option for the client to save the view’s layout. I save
the x,y of the node, label, link and also the x,y of the various points
of the links in xml. My issue is that when I bring back the view the
links which had several points now all contain only 2 and for some
reason the changes I’m trying to make to the location of the points
never come into effect.

int totalPointsLink = link.getNumPoints();
NodeList list = elementNode.getChildNodes();
int totalNodes = list.getLength();
int count = 0;
for(int i = 0; i < totalNodes; i++)
{
Node nodePoint = list.item(i);
if(nodePoint.getNodeType() == Node.ELEMENT_NODE)
{
count++;
NamedNodeMap map = nodePoint.getAttributes();
int point_x = Integer.parseInt(map.getNamedItem(“point_x”).getNodeValue()) ;
int point_y = Integer.parseInt(map.getNamedItem(“point_y”).getNodeValue()) ;
if(count <= totalPointsLink)
{

link.setPoint(count - 1,point_x,point_y); 
           
         
}    
       else
       {
       
 link.insertPoint(count

-1,point_x,point_y); &nbs p;
}
link.calculateStroke();

The call to JGoLink.calculateStroke will throw away the points you carefully set up, and instead decide on its own favorite route.
For efficiency most people just save all the points as X,Y pairs in a long string, rather than as separate elements.

Ok I managed to get both the nodes and the links to display properly
however Im still having problems with the labels. Its reading and
passing the correct x,y to the setTopLeft method however the label is
never in the correct location. Just wondering what Im doing wrong or
forgetting.

int totalPointsLink = link.getNumPoints();
String x_y[] = nameMap.getNamedItem(“points”).getNodeValue().split(",");
for(int i = 0; i < x_y.length; i++)
{
String point[] = x_y.split(“y”);
int point_x = Integer.parseInt(point[0]);
int point_y = Integer.parseInt(point[1]);
if(i + 1 <= totalPointsLink)
{
link.setPoint(i, point_x,point_y);
}
else
{

link.insertPoint(i,

point_x,point_y);
}
}
FlowLabel label = (FlowLabel)link.getMidLabel();
label.setTopLeft(label_x, label_y);
}

I suspect you are not initializing the FlowLabels with the correct Offset, Segment, and SegmentDistance property values. Those are used by FlowLink.layoutChildren to decide where to position the FlowLabel. That way if the path of the link changes (perhaps because a port moved), it will update its position reasonably.

so are you saying that I should also save the offset,segment and segmentdistance property values in order to set them once again

yes, instead of the position