Hello,
This is somewhat a continuation of (or at least related to) Trevor’s thread over here: How to get connection point of a line on a shape
The long and short of it is that we’re trying to attach connectors to their correct locations on shapes, using Diagram for Java. We are now utilizing the connectorRule referenced in the patch notes for 22.11, and are successfully getting the connection points on the originating shape, as well as on the left and right faces of the receiving shape, which is excellent.
We have noticed issues when attaching to the top and bottom faces, which we have narrowed down to incorrect X values received when performing:
connectorShape.getConnectorRule().getEndShapeConnection().getX().getValue()
We are getting -1.7976931348623157E308 as the result, instead of the expected coordinate of approximately 0.25, which our error checking replaces with zero, and we end up with the connection point set in the corner instead of the correct point along the face. The Y value of the endShapeConnection, and both the X and Y of the startShapeConnection, appear to behave correctly.
I have attached a simple visio diagram that reproduces this issue in our code. Here is an abbreviated sample of the code flow:
private static Point2D.Double getConnectionPoint(Connection connection)
{
Point2D.Double connectorPoint;
if (connection != null)
{
double connectorStartX = connection.getX().getValue();
connectorStartX = connectorStartX == -Double.MAX_VALUE ? 0.0 : connectorStartX;
double connectorStartY = connection.getY().getValue();
connectorStartY = connectorStartY == -Double.MAX_VALUE ? 0.0 : connectorStartY;
connectorPoint = new Point2D.Double(connectorStartX, connectorStartY);
}
else
{
connectorPoint = new Point2D.Double(0.0, 0.0);
}
return connectorPoint;
}
private static void addLine(Shape connectorShape) throws Exception
{
ConnectorRule connectorRule = connectorShape.getConnectorRule();
Connection startConnection = connectorRule.getStartShapeConnection();
Connection endConnection = connectorRule.getEndShapeConnection();
Point2D.Double startPoint = getConnectionPoint(startConnection);
Point2D.Double endPoint = getConnectionPoint(endConnection);
}
Running the addLine function above results in (approximately) the following values:
startPoint = [0.246, 0.787]
endPoint = [0.0, 1.063]
Because we are connecting to the top face, we then look at the X value of the endPoint, we get 0 instead of the expected value (which should be around 0.25)
We would greatly appreciate any help and insights you can provide.
Sincerely,
Avery Norris
VisioDiagramForAsposeSupport.zip (143.9 KB)