2

I'm using Zest to draw a graph. However, I want to change the default color of the graphnode to another color based on its label. For example: Label: red => color of the node is red.

thd
  • 2,380
  • 1
  • 25
  • 33

1 Answers1

4

If you are using the GraphViewer API of Zest (similar to JFace viewers), let your LabelProvider extend IEntityStyleProvider that provides the necessary getBackgroundColor() callback method (among others).

However, if you are using the base Graph API, then you have to set the color of all the nodes manually using the GraphNodes set*Color methods.

Zoltán Ujhelyi
  • 13,788
  • 2
  • 32
  • 37
  • Hello, i'm trying to do this now and I can't see these Classes from my IDE having added the Zest packages in. Is this old functionality or do I need another import to allow it? – Link19 Feb 05 '14 at 17:27
  • 1
    If you are using Zest 1.x (downloadable from the Kepler update site), then it shouldn't be necessary. If you are using the GEF4 Zest version, you have to add the org.eclipse.gef4.zest.jface plug-in as an additional dependency (but you are already using this if you are using the GraphViewer API). – Zoltán Ujhelyi Feb 05 '14 at 19:13
  • It was my fault, I was not understanding that I just had to implement the extra interfaces with my label provider. – Link19 Feb 11 '14 at 09:35