I have an AggregateLayout containing several CircleLayouts. The first time I create all the sublayouts, everything works as expected.
However, if I change the Graph held by one of the CircleLayouts (e.g. by adding a few more vertices), the newly added Vertices appear at seemingly random locations. I've worked out why this is happening and proposed a workaround below. The actual fix should be fairly trivial.
1. radius autocalculation only happens the first time. (I would advise that 'radius' is not saved to the field if auto-calculated in 'initialize'.)
Workaround: augment the above setSize to recalculate radius (Side effect: means that direct changing of radius is overridden)
@Override
public void setSize(Dimension size) {
super.setSize(size);
if (getSize() != null) {
setRadius(0.45 * (getSize().height < getSize().width ? getSize().height : getSize().width));
}
}
2. The newly added vertices are not being drawn on the circle. This is because the lazy initialization of vertex_ordered_list is not recalculated (similar to the 'radius' bug above).
Workaround: also override setGraph
@Override
public void setGraph(Graph<V, E> graph) {
super.setGraph(graph);
setVertexOrder(new ArrayList<V>(getGraph().getVertices()));
}
3. circleVertexDataMap doesn't appear to be used anywhere! I would suggest it is simply removed - it was probably useful debugging info for the developer and is therefore more suitable in a testcase.
4. AbstractLayout.adjustLocations appears to be using sizes as if they were offsets. (I don't understand this and I wonder if it could be impacting some other problems I'm seeing)
Due to these issues, I recomend a rewrite of CircleLayout and reconsider what is going on in AbstractLayout.setSize.