Doktor_DOOM
Doktor_DOOM

Reputation: 13

JUNG change the color of specific vertex

at the moment, I'm trying to change the color of a specific vertex in JUNG. I know i can use the following function to change the color of all nodes. Is it possible to substitute v from the following line with a specific node.

vv.getRenderContext().setVertexFillPaintFunction(v -> Color.blue);

Or should i use transformer classes?

Upvotes: 0

Views: 62

Answers (1)

Joshua O'Madadhain
Joshua O'Madadhain

Reputation: 2704

You can certainly supply a more complex Function than v -> Color.blue if you like; for instance:

vv.getRenderContext().setVertexFillPaintFunction(
    v -> v.equals(specialNode) ? Color.red : Color.blue);

For more information on specifying Functions (using lambda expressions or not), see https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html.

Upvotes: 1

Related Questions