Search code examples
eclipseeclipse-rcpzest

Change color of a node in Zest


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.


Solution

  • 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.