Intro
I'm working on a project, that renders the vertices in a graph in different sizes (according to their relative workload).
Problem
How I expected it to work
This is what happens when I turn off the dynmaic resizing of vertices:
So here everything is correct. The connection-circles are placed just on the border of the cirular shapes.
This result is achieved by the code in Listing 1.
What actually happens on dynamic resizing
Here you can see, that the connection-circles are placed somewhere near the border, but always lack the correct position.
This result is achieved by the code in Listing 2.
Listing 1 - Without resizing
viewer.getRenderContext().setVertexShapeTransformer(vertex -> {
return vertex.getShape();
});
Listing 2 - With resizing
viewer.getRenderContext().setVertexShapeTransformer(vertex -> {
double localWorkload = vertex.getLocalWorkload();
double globalWorkload = graph.getGlobalWorkload();
double relation = local / global;
return AffineTransform.getScaledInstance(relation, relation).createTransformedShape(vertex.getShape());
});
Actually I'm lazily precalculating 10 different sizes of the vertex' shape within the vertex. But this code snippet is more clear and achieves the same result (though not as performant).
What I already tried and looked at
This all happens in the edu.uci.ics.jung.visualization.renderers
Package.
- checked the
BasicEdgeArrowRenderingSupport
class for anything I might utilize to correct this issue - checked if it was the `flatness` of the
PathIterator
in theBasicEdgeArrowRenderingSupport
- checked if it was the
arrowPlacementTollerance
parameter
Question
How do I achieve the desired result which is produced by Listing 1 but with dynamically resizing shapes as in Listing 2?
I guess the answer to this question will be resulting in either:
- There is some essential failure (logically or programatically) I did
- Or it is a basic problem of the edge arrow rendering support