The basic idea is to write something like
Transformer<V, Paint> vertexPaintRed = new Transformer<V, Paint>() {
public Paint transform(V input) {
if (hasOnlyOutgoingEdges(input)) return Color.RED;
if (hasOnlyIncomingEdges(input)) return Color.GREEN;
return Color.BLUE;
}
};
with an appropriate implementation of the methods checking the type of the vertex.
For example, if you know the JUNG Graph
that contains the vertex, at the place where the Transformer is created, you could simply write
Transformer<V, Paint> vertexPaintRed = new Transformer<V, Paint>() {
public Paint transform(V input) {
if (jungGraph.inDegree(input) == 0) return Color.RED;
if (jungGraph.outDegree(input) == 0) return Color.GREEN;
return Color.BLUE;
}
};