I have e. g. 3 nodes with these user objects: RED, GREEN, BLUE. If I connect RED to GREEN, then I want to have the edge painted in red. If I connect GREEN to BLUE, then I want the edge painted in green. In other words: The edge is supposed to have the color of the source cell.


Where is the proper place to set/change this color? I don't want to set all style colors every time I modify the graph.


Thank you very much for your help!

asked 14 Mar '12, 21:48

Lofi's gravatar image

accept rate: 37%

edited 14 Mar '12, 22:00

Here is an example.


answered 14 Mar '12, 23:18

Gaudenz's gravatar image

accept rate: 39%

Thank you very much, Gaudenz, but your example sets the styles already in the insertVertex method.


My problem is that I need to draw the edge in green, when I create a connection from the green Vertex to the blue Vertex. And in Red, when I create a connection from the red vertex to the blue vertex. So I can't use the default edge styles.


My first thought was to subclass mxGraphModel and override the method "public String getStyle(Object cell)", but I'm not sure if that's the proper place. when I load a graph from xml, the styles would also adapt automatically.


I need it for Java.

(15 Mar '12, 18:51) Lofi

The example overrides mxGraphModel.getStyle.

(15 Mar '12, 22:13) Gaudenz

Oh, then I was on the right track. Sorry that I didn't get that from your Javascript code. Now I see it. I should get myself a proper code formatter and not use the one from Firefox.


Thank you very much for your help, Gaudenz! It's very appreciated :-)

(16 Mar '12, 21:15) Lofi
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: 14 Mar '12, 21:48

Seen: 1,563 times

Last updated: 16 Mar '12, 21:15