Connection points not correct for multiple connections

Hi, please, share your ideas about this problem: when shape has multiple connections, connection points are set not correct (see attached screenshot with proper connectors and ponts in blue color: Multiple connectors.zip (8.5 KB))
Was using page.connectShapesViaConnector(), as in the documentation.

Resulting Visio file: iteraplan-InformationFlowDiagram-2018-07-06__15_58_48.zip (12.9 KB)

Using Aspose Diagram for Java, 18.5

@iteraplan

Thanks for contacting support.

Would you please share complete code snippet, which is able to replicate the issue you are mentioning. We will test the scenario in our environment and address it accordingly. Please make sure to test the scenario withAspose.Diagram for Java 18.6, before sharing the code snippet.

@asad.ali, here I’ve attached a project with the scenario: https://drive.google.com/open?id=1hZvaoECHBIxEpPyYtkz1tuBQG_oqdWt_

Connection points are added dynamically via method IteraplanVisioUtils.getConnectionPointPlace(from, to).
In our case Shape with name “Monetary txs RB # 2.0” is to be connected to shape “Account-Sys RB # 3.1” from TOP to BOTTOM in IFDDiagram.java, line 72. But as you will see in the result drawing (ifd1.vsdx) connection points for this connection are different.

Probably the reason is other connection points for “Monetary txs RB # 2.0” (on the LEFT and on the RIGHT).
When shape has simply one connection it is displayed correctly in the result drawing.

!To check the execution please, select Runner.java as main class and also don’t forget to attach your Aspose.Diagram.lic file to \src\main\resources\templ. Resulting drawing will be added to the project root.

@iteraplan

Thanks for sharing the sample project.

We were able to replicate the issue of incorrect shape connectors. For the sake of correction, we have logged it as DIAGRAMJAVA-50608 in our issue tracking system. We will further investigate the issue and keep you posted with the status of its resolution progress. Please be patient and spare us little time.

We are sorry for the inconvenience.

@iteraplan

We have further investigated the issue and found that there was no connection in the shapes. Please add connection in the shape first by adding following code snippet in IFDDiagram.java.

private void addConnections(Shape shape)
  {
      Connection top = new Connection();
      top.getX().setValue(shape.getXForm().getWidth().getValue()/2);
      top.getY().setValue(0);
      
      Connection bottom = new Connection();
      bottom.getX().setValue(shape.getXForm().getWidth().getValue()/2);
      bottom.getY().setValue(shape.getXForm().getHeight().getValue());
      
      Connection left = new Connection();
      left.getX().setValue(0);
      left.getY().setValue(shape.getXForm().getHeight().getValue()/2);
      
      Connection right = new Connection();
      right.getX().setValue(shape.getXForm().getWidth().getValue());
      right.getY().setValue(shape.getXForm().getHeight().getValue()/2);
      
      
      shape.getConnections().add(top);
      shape.getConnections().add(bottom);
      
      shape.getConnections().add(left);
      shape.getConnections().add(right);
  }
  
  @Override
  public Object createVisio(IFDVisioContext ctx) throws Exception {
    AffineTransform tr = ctx.getParentTransform();
    AffineTransform dt = new AffineTransform();
    dt.concatenate(tr);
    double xCentr = (getPosition().getX() + getRectangle().getCenterX());
    double yCentr = (getPosition().getY() + getRectangle().getCenterY());
    dt.translate(xCentr, -yCentr);
    double translateX = dt.getTranslateX();
    double translateY = dt.getTranslateY();
    long diagramShapeId = ctx.getCurrentPage().addShape(translateX, translateY, ctx.getMasterNodeName());

    Shape diagramShape = ctx.getCurrentPage().getShapes().getShape(diagramShapeId);
    diagramShape.setWidth(getRectangle().getWidth() / IteraplanVisioUtils.VISIO_SCALE);
    diagramShape.setHeight(getRectangle().getHeight() / IteraplanVisioUtils.VISIO_SCALE);

    diagramShape.getText().getValue().clear();
    diagramShape.getText().getValue().add(new Txt("DiagramShapes"));
    
    List<Shape> group = new ArrayList<Shape>();
    group.add(diagramShape);
    for (Node node : nodes) {
      Shape nodeShape = (Shape) node.createVisio(ctx);
      nodesShape.put(node.getId(), nodeShape);
      nodeShape.refreshData();
      group.add(nodeShape);
    }

    for (Edge edge : edges) {
      Shape edgeShape = (Shape) edge.createVisio(ctx);

      Shape from = nodesShape.get(edge.getFromNode());
      Shape to = nodesShape.get(edge.getToNode());
      addConnections(from);
      addConnections(to);
     
      ctx.getCurrentPage().connectShapesViaConnector(from.getID(), IteraplanVisioUtils.getConnectionPointPlace(from, to),
              to.getID(), IteraplanVisioUtils.getConnectionPointPlace(to, from), edgeShape.getID());
      group.add(edgeShape);
      
    }
    
    diagramShape.refreshData();
    return diagramShape;
  }

In case you face any other issue, please feel free to let us know.

@asad.ali, thanks for suggestion. I have applied your code snippet to the Sandbox project (which I have attached here for reference) and in the resulting Visio file connection points are drawn correctly now, BUT after moving connected shapes - their connectors remain on same positions.

Also applying your code snippet to my main project didn’t help to fix main problem, I’ll additionally investigate the code there after your reply about “the connectors position after moving connected shapes” problem.

P.S: using version 18.7 for Java

@iteraplan

Thanks for getting back to us.

Would you please share how and where in your shared project are you moving connected shapes. We will test the scenario in our environment and address it accordingly.

@asad.ali, please, add your code snippet in the Sandbox project and run Runner.java. The resulting Visio drawing “ifd1.vsdx” will be added to the root directory. I also attaching it here: ifd1.zip (11.5 KB)

The scenario in which I reproduce the issue is recorded in this GIF: Connectors remain on their positions after elements dragging.gif (275.8 KB)

@iteraplan

Thanks for further explaining the issue.

We have observed the same issue in our environment and logged these details along with the ticket. We will further investigate it accordingly and share our feedback. Please spare us little time.

We are sorry for the inconvenience.

@iteraplan

Please also set indices of connections in code to resolve the issue and final addConnections() method would be as this code:

private void addConnections(Shape shape) 
  { 
      Connection top = new Connection(); 
      top.setIX(0); //set index of connection 
      top.getX().setValue(shape.getXForm().getWidth().getValue()/2); 
      top.getY().setValue(0); 
       
      Connection bottom = new Connection(); 
      bottom.setIX(1); 
      bottom.getX().setValue(shape.getXForm().getWidth().getValue()/2); 
      bottom.getY().setValue(shape.getXForm().getHeight().getValue()); 

       
      Connection left = new Connection(); 
      left.setIX(2); 
      left.getX().setValue(0); 
      left.getY().setValue(shape.getXForm().getHeight().getValue()/2); 
       
       
      Connection right = new Connection(); 
      right.setIX(3); 
      right.getX().setValue(shape.getXForm().getWidth().getValue()); 
      right.getY().setValue(shape.getXForm().getHeight().getValue()/2); 
       
       
      shape.getConnections().add(top); 
      shape.getConnections().add(bottom); 
       
      shape.getConnections().add(left); 
      shape.getConnections().add(right); 
  } 

For your kind reference, we have attached output VSDX file as well. ifd1.zip (11.6 KB)

Hello, @asad.ali. Thanks for reply, last suggestion works for the sandbox project I’ve attached earlier and connectors remain on their shapes now. But the code in the main project was refactored - the structure of a data model (that is used for building a diagram shapes) changed a little. And addConnections(Shape shape) still have no effect for the resulted drawing :frowning:
I have updated the sources in the sandbox project, so you can investigate new scenario: https://drive.google.com/file/d/18uvS0srLcZV7UNGOIMtr_U1Y8qpimgHA/view?usp=sharing

The main change is that I have created abstract class Box.java for rectangular Shape which recursively adds child shapes in its group (it is possible that one shape can contain multiple ones). Also reusable classes and code were moved to common folder.

Refer to IFDDiagram.java, line 83-86, where all shapes are drawn and connected. Also, please check Node, Box, Edge classes where I use Aspose.Diagram (18.7) library for building shapes and connectors.

I assume that one more connections bug appeared or I use Aspose.Diagram not in the right way.
Please, share your findings on the new code.

!To check the scenario please, run Runner.java and also don’t forget to attach your Aspose.Diagram.lic file to \src\main\resources\templ. Resulting drawing will be added to the project root.

Also noticed right now: when resizing a shape in the resulting drawing - connector points’ positions are adjusted in a wrong way: image.png (17.4 KB). Then when dragging a shape, looks like connector points still moving with the shape.

@iteraplan

Thanks for sharing these details.

We have tested the scenario in our environment and managed to observe that connectors were overlapping the shapes in output diagram. Also, we have noticed that connectors got disconnected from shapes while resizing them. We have logged an investigation ticket as DIAGRAMJAVA-50614 in our issue tracking system. We will further check this and let you know about any updates. Please spare us little time.

We are sorry for the inconvenience.

@asad.ali, do you already have some results of your investigation ticket? This issue is making the resulting VISIO-file really confusing, and therefore it has no value for our customers.
Will this issue be fixed in the next release? Sorry for the impatience, but it is really important to us.

@iteraplan

Thanks for your inquiry.

I am afraid that earlier logged ticket is still pending for resolution. Please note that the ticket was logged under free support model and it has low priority. After an initial investigation it is found that the issue is related to grouping shapes and it does not occur when we do not group them. We need to look into this further and due to low priority, it will be investigated/resolved on first come first serve basis.

In case issue is blocker and needs to be resolved on urgent basis, you may please check paid support option where issues have high priority. As soon as we have some definite updates regarding issue resolution, we will surely inform you. Please spare us little time.

We are sorry for the inconvenience.

Hi, thanks for the info. But even after trying to connect shapes without grouping, connectors look weird. Here is another case with shapes and connectors: shapes and connections issue.zip (27.4 KB)
Also I have noticed if I select all elements in result drawing, drag and drop them, the result is almost like expected: shapes and connections issue (after dragging shapes and connectors).zip (28.5 KB). Connectors are reset and are pointing to the correct shapes now.

Here is what I try to achive: Expected result (SVG document).png (79.3 KB)

Hope this will also help to fix connectors issue,
kind regards

@iteraplan

We are testing the scenario and will get back to you shortly.

@iteraplan

We had logged provided details along with the investigation ticket and it definitely helped investigating and resolving the issue. We would also like to share with you that fix to your issue is expected to be included in upcoming 18.9 version of Aspose.Diagram for Java.

This is great news! Glad we could help you with resolving this issue. Thanks for your support. Kind regards

Hello, @asad.ali. The main issue is not reproduced with version 18.9. Thanks!

And what about DIAGRAMJAVA-50614, also reported in this topic (Shape resizing misplacing connection points)?