I create and connect the arc like I think you do. And I connect it to the shape using Connectors that I created with this routine:
static void addAllControlPoints(String nodeId, Shape textShape, boolean bottomUp, boolean extend, boolean extendDown) throws Exception {
Connection conn;
String nodeCenter = "Width*0.5" ;
double pixelOffDown = 0 ;
double pixelOffUp = 0 ;
if(extend) {
if(extendDown) {
pixelOffDown = VisioGenerator.scale * 50;
} else {
pixelOffUp = VisioGenerator.scale * 40;
}
}
for(int anchor = 0 ; anchor < MAX_PRIMARY_IN; anchor++) {
String anchorPosition = nodeCenter + "+" + anchor * ANCHOR_GAP ;
String anchorName = anchorName(nodeId,PRIMARY_IN_PREFIX,anchor) ;
conn = makeAnchorPoint(textShape, anchorName, anchorPosition, "Height" + "+" + pixelOffUp);
}
for(int anchor = 0 ; anchor < MAX_PRIMARY_OUT; anchor++) {
String anchorPosition = nodeCenter + "+" + anchor * ANCHOR_GAP ;
String anchorName = anchorName(nodeId,PRIMARY_OUT_PREFIX,anchor) ;
conn = makeAnchorPoint(textShape, anchorName, anchorPosition, "" + -pixelOffDown);
}
for(int anchor = 0 ; anchor < MAX_SECONDARY_IN; anchor++) {
String anchorPosition = nodeCenter + "-" + anchor * ANCHOR_GAP ;
makeAnchorPoint(textShape,anchorName(nodeId,SECONDARY_IN_PREFIX,anchor), anchorPosition, "Height" + "+" + pixelOffUp);
}
for(int anchor = 0 ; anchor < MAX_SECONDARY_OUT; anchor++) {
String anchorPosition = nodeCenter + "-" + anchor * ANCHOR_GAP ;
makeAnchorPoint(textShape,anchorName(nodeId,SECONDARY_OUT_PREFIX,anchor), anchorPosition, "" + -pixelOffDown);
}
DBO(DB_ANCHORS_TRACE, ()->"anchorIndex:" + ModelDebug.dumpMap(anchorIndex));
textShape.refreshData();
}
private static Connection makeAnchorPoint(Shape shape, String name, String xPositionString, String yPositionString) {
Connection connection1 = new Connection();
connection1.setName(name);
connection1.getX().getUfe().setF(xPositionString);
connection1.getY().getUfe().setF(yPositionString);
int ix = shape.getConnections().add(connection1);
connection1.setIX(ix);
anchorIndex.put(name, ix);
return connection1;
}
I create the connector like this, looking up the correct connector for each arc.
Shape arcShape = new Shape();
arcShape.setName(connectionData.getId() + "-" + pageIndex);
long arcShapeId = visioPage.addShape(arcShape, CONNECTOR.getStencilName());
arcShape.bringToFront();
Shape fromNodeShape = shapeSource.getShape(idMapping.get(fromNodeId));
Shape fromNodeTextShape = shapeSource.getShape(idMapping.get(fromNodeId)).getShapes().getShape(fromNodeId + "-TEXT");
Shape toNodeTextShape = shapeSource.getShape(idMapping.get(toNodeId)).getShapes().getShape(toNodeId + "-TEXT");
long fromId = fromNodeTextShape.getID() ;
long toId = toNodeTextShape.getID() ;
int fromAnchorIndex;
int toAnchorIndex ;
//These tow indexes are looked up from a list of Connectors, the I ADDED!
fromAnchorIndex = getAnchorIndex(fromNodeId, connectionData,CONNECTION_IN) ;
toAnchorIndex = getAnchorIndex(toNodeId, connectionData,CONNECTION_OUT) ;
visioPage.connectShapesViaConnectorIndex(
fromId,fromAnchorIndex,
toId, toAnchorIndex,
arcShapeId);
visioPage.glueShapes(fromNodeShape, fromAnchorIndex, toNodeTextShape);
fromNodeTextShape.refreshData();
toNodeTextShape.refreshData();
arcShape.refreshData();
markOriginalLineForDeletion(arcShape);
Then I remove the original Geoms:
public static Point2D markOriginalLineForDeletion(Shape arcShape) {
Point2D end = null ;
for(int i = 0; i < arcShape.getGeoms().get(0).getCoordinateCol().getLineToCol().getCount(); i++) {
LineTo lineToDelete = arcShape.getGeoms().get(0).getCoordinateCol().getLineToCol().get(i);
end = new Point2D.Double(lineToDelete.getX().getValue(),lineToDelete.getY().getValue());
lineToDelete.setDel(BOOL.TRUE);
};
return end ;
}
Then I add the individual line segments where they are suppose to be in the chart created by our tool
public static void addLineTos(Shape arcShape, List<Point2D> arcPoints, boolean dbArcInteresting) {
arcPoints.stream().forEach(point->{
LineTo lineToVertice = new LineTo();
lineToVertice.getX().setValue(point.getX());
lineToVertice.getY().setValue(point.getY());
arcShape.getGeoms().get(0).getCoordinateCol().add(lineToVertice);
});
}
If I call arcShape.refreshNode() at this point, the resulting arc loses my line segments! So I call it before I modify the Geoms.
Here is an elaborate example:
diagram.zip (198.3 KB)
An interesting (and annoying) feature is that when I open one of these produced files in VISIO, and then I close it without changing it, it still asks me if I want to save the document. As well, as I think I said before, if I make a change like the orientation or page size, it does a redraw of the connectors, adding the little jumpers, and reseting the green dots to where I want them.
I hope this is enough information. The payment has just gone through to you for a full support license which I expect very soon. I have a lot more questions