1

I'm visualizing a graph in a java swing application using jgrapht/jgraphx.

By default the connections (the arrows that point from one node to an other) between 2 nodes are rendered in light blue. When I select a connection by clicking on it, the color changes from light blue to green.

How can I change this color? I didn't find a way to do this so far. I'm using jgrapht 0.9.1, jgraphx 2.0.0.1, jgraph 5.13.0.0.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
kibu Kuhn
  • 81
  • 5

2 Answers2

1

And here is the proper way (I think)

    mxCellTracker trackColor = new mxCellTracker(myGraphComponent, Color.CYAN);
Nieke Aerts
  • 209
  • 2
  • 11
0

(EDIT: tested this for JgraphX 3.4.1.3)

This selection color is defined in mxSwingConstants.java.

It can be overwritten by:

     mxSwingConstants.EDGE_SELECTION_COLOR = new Color(255,0,0,255);

But this is not so pretty I would say, and you cannot set it differently for different edges like this. Probably you can change it after some event.

A pretty solution would be if one could add it to an edge style...

Nieke Aerts
  • 209
  • 2
  • 11