Hi again,

I customize edge routing by changing the x-coordinate of an edge's AbsolutePoints after adding it to the graph by:

graph.getView().getState(currentEdge).getAbsolutePoint(1).setX( aNewValueForX );

This works fine, however, after adding another cell to the graph (or folding a swimlane, or something else that refreshes the graph), the edge's control points reset to their original values. Why do they "forget" my change of x-coordinate?

My style definition for those edges look like this:

<add as="edgeSl">
    <add as="shape" value="connector"/>
    <add as="edgeStyle" value="elbowEdgeStyle"/>
    <add as="elbow" value="horizontal"/>
    <add as="noLabel" value="true"/>
    <add as="startArrow" value="none"/>
    <add as="endArrow" value="none"/>
    <add as="rounded" value="true"/
    <add as="exitX" value="0"/>
    <add as="exitY" value="0"/> 

asked 11 Jan '13, 09:33

fachexot's gravatar image

accept rate: 11%

The state is always updated when something changes, try changing the points in the edge's geometry instead or implement a custom edge style.


answered 11 Jan '13, 10:29

Gaudenz's gravatar image

accept rate: 39%

Urgh! Thanks a lot!

(11 Jan '13, 10:31) fachexot

However there is a problem: Edges do not have any geometry set at all. When I want to change the x-coordinate of an edge's control point, I get a NullPointerException with something like:

currentEdge.getGeometry().getPoints() [...]

Debugging the values brings com.mxgraph.model.mxGeometry[x=0.0,y=0.0,w=0.0,h=0.0] for any edge's geometry.

(12 Jan '13, 06:05) fachexot

Try setting points to a new array.


answered 12 Jan '13, 06:25

Gaudenz's gravatar image

accept rate: 39%

This worked for me, but unfortunately another problem comes up:

I create a new array of control points by taking the state's absolute points, changing their x-coordinate and copy them to the new array. This one I set to the edge's geometry and all is fine. When the graph now changes, for example by folding other cells, the coordinates of the geometry's points cause a wrong visualisation of the graph, because they are absolute.

Hmm, what I needed to do, is to dynamically customize the geometry's point depending on the current state of the edge.

Originally, what I wanted to do, was to change the X-position of the [horizontal elbow] edge's vertical segment dynamically, depending on how much cells lay out in one column (column created with mxStackLayout).

Perhaps you have any idea how to solve that? Maybe there is an event fired when the state of an edge is changed, so that I can customize the geometry at this moment?

(14 Jan '13, 09:24) fachexot
Your answer
toggle preview

Follow this question

By Email:

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



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



Asked: 11 Jan '13, 09:33

Seen: 1,564 times

Last updated: 14 Jan '13, 09:25