We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Connector line spacing to small

How do I force more distance between horizontal and vertical line segments in aspose java? Or even in the application?

image.png (43.0 KB)

@Thinian

We need to investigate these requirements. Can you please provide sample file and the code snippet you used to create it? We will log an investigation ticket and share the ID with you.

This is the file after I created it:

diagram.zip (189.5 KB)

If you select All and change select the right click menu item “Right Angle Connectors” you will see the result.

I create a number of connections for each node along the top and the bottom using:

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 then use this to create the connector:

			visioPage.connectShapesViaConnectorIndex(
					fromId,fromAnchorIndex, 
					toId, toAnchorIndex, 
					arcShapeId);

Then I mark the connector line segment for deletion:

public static void markOriginalLineForDeletion(Shape arcShape, boolean dbArcInteresting) {
	for(int i = 0; i < arcShape.getGeoms().get(0).getCoordinateCol().getLineToCol().getCount(); i++) {
		LineTo lineToDelete = arcShape.getGeoms().get(0).getCoordinateCol().getLineToCol().get(i);
		lineToDelete.setDel(BOOL.TRUE);
	};
}

Finally I add new line segments:

public static void addLineTos(Shape arcShape, List<Point2D> arcPoints, boolean dbArcInteresting) {
	ModelDebug.DBO(DB_CONNECTORS_LABELS,dbArcInteresting, ()->"\taddLineTos arcPoints:" + dumpList("",arcPoints));
	arcPoints.stream().forEach(point->{
		DoubleValue finalX = new DoubleValue(point.getX(), MeasureConst.IN) ;
		DoubleValue finalY = new DoubleValue(point.getY(), MeasureConst.IN) ;
		LineTo lineToVertice = new LineTo();
		// Set X value
		lineToVertice.setX(finalX);
		// Set Y value
		lineToVertice.setY(finalY);
		// Add connector geometry
		arcShape.getGeoms().get(0).getCoordinateCol().add(lineToVertice);			
	});
}

And it looks as you see it, but when I reformat the entire graph, the lines end up too close together.

@Thinian
Please try this sample code to set space distance of shapes
// initialize auto space options
AutoSpaceOptions atopt = new AutoSpaceOptions();
// set horizontal and vertical distances
atopt.setDistanceInHorizontal( 2);
atopt.setDistanceInVertical( 2);
// set auto space
ShapeCollection SrvsCollection = page.getShapes();

        page.autoSpaceShapes(page.getShapes(), atopt); 

Thanks.

ShapeCollection SrvsCollection = page.getShapes();

I don’t understand that line.

@Thinian

Apparently, this line does not seem to take any part in the suggested code snippet. The code snippet might be a part of some project and that line just got included. Weren’t you able to achieve your requirements? Please share in case you have some concerns.