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.

\n

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.

\n

Thank you very much for your help!

asked 14 Mar '12, 21:48

Lofi's gravatar image

Lofi
1.0k1221
accept rate: 37%

edited 14 Mar '12, 22:00


Here is an example.

link

answered 14 Mar '12, 23:18

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

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

\n

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.

\n

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.

\n

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.

\n

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

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
×50

Asked: 14 Mar '12, 21:48

Seen: 1,563 times

Last updated: 16 Mar '12, 21:15