Here's my situation: I have used the EntityRelation style for the edges in this manner:

Map<string, object=""> style = graph.getStylesheet().getDefaultEdgeStyle();
style.put(mxConstants.STYLE_EDGE, mxEdgeStyle.EntityRelation);

Every time I create a new cell (a rectangular vertex) it is connected to an already existing cell, which is to its left, by an edge that starts from the right side of that already existing cell and enters on the left side of the newly created one. However, if I then move the new cell (where the edge connects to the left) to the left side of the other cell, the edge switches position and now comes out of the left side of the existing cell to enter the right side of the new one, but what I would like is for the edge to come out of and enter from the same place on each cell despite of how I move things every time.

To put it simply, I would like for every edge to come out on the right side of existing cells and to enter on the left side of new cells, despite the positions in which they are moved. How can I make sure this happens?

Below is a diagram to further explain this problem I am having and the outcome I wish to achieve. The sides coloured in green are the correct sides from which I want the edges to start and finish. The sides coloured in red are indicating what I do not want to happen.

alt text

Thank you.

asked 05 May '11, 07:30

vinnie's gravatar image

vinnie
95210
accept rate: 9%

edited 31 Dec '12, 15:15

David's gravatar image

David
4.9k21831


On the edge, set the orthogonal edge style:

edgeStyle=orthogonalEdgeStyle

Then either set portConstraints on the vertices:

portConstraint=north
portConstraint=east
portConstraint=southwestnorth

using any combination of north,south,east and west. Or set connection constraints on the vertices (fixed ports) where the ports are on the boundary of the bounding rectangle of the vertices.

link

answered 05 May '11, 11:22

David's gravatar image

David
4.9k21831
accept rate: 47%

edited 31 Dec '12, 15:15

Everything works fine if I set "edgeStyle=orthogonalEdgeStyle" but what if I still want to use the same style I used before?

I need to use the "entityRelationEdgeStyle" instead of the "orthogonalEdgeStyle" but, when i set that style for the edge, the port constraints are not respected. What can I do to fix this?

I'll copy a portion of the code I wrote

This is an "Existing Cell" (as seen in the diagram):

vettorePlus[i]=graph.insertVertex(tab, null, null, 140, (i+1)*25, 26, 25,"portConstraint=east");

And this is a "New Cell":

vettoreCampiS[i]=(mxCell)graph.insertVertex(tabS, null, campiS.get(i), 0, (i+1)*25, 140, 25,"portConstraint=west");

This is the way to set the edge that makes the portConstraints work:

mxCell e=(mxCell)graph.insertEdge(parent, null, null, source, vettoreCampiS[i],"edgeStyle=orthogonalEdgeStyle");

And this is the way to set the edge (with the style that I need) that doesn't make the portConstraints works:

mxCell e=(mxCell)graph.insertEdge(parent, null, null, source, vettoreCampiS[i],"edgeStyle=entityRelationEdgeStyle");

(05 May '11, 13:46) vinnie

what if I want to use entityRelationEdgeStyle instead of orthogonalEdgeStyle?

(06 May '11, 15:00) vinnie

We don't support port constraints on any other edge style yet.

(09 May '11, 03:16) David

Is there a way to switch from an edge style to another when the cells connected by the edge are in some particular positions?

I'll try to explain better this question.

When I use the entityRelationEdgeStyle if the cells are really close to one another it seems to "switch" to an orthogonalEdgeStyle but it still doesn't support port constraints. So I thought that if there's something in the code that allows that " visual switch" perhaps there's a way to obtain a "complete switch" from a style (entityRelationEdgeStyle that doesn't supports port constraints) to another (orthogonalEdgeStyle that supports port constraints) and viceversa.

link

answered 06 Sep '11, 10:25

vinnie's gravatar image

vinnie
95210
accept rate: 9%

edited 31 Dec '12, 15:16

David's gravatar image

David
4.9k21831

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×100
×79
×66
×37

Asked: 05 May '11, 07:30

Seen: 3,821 times

Last updated: 31 Dec '12, 15:16