Menu

#183 RFE: AggregateLayout rendering ordering

open
nobody
None
5
2012-07-28
2012-07-28
Anonymous
No

(this has a pretty neat workaround)

I have many sublayouts in an AggregateLayout, with vertices being shared between layouts.

I need to have a "priority list" of layouts, so that a vertex (which is in several layouts) will be prioritised into one of them. JUNG does not support this, however the following workaround allows this to be done, e.g. for a CircleLayout

Layout<V, E> subLayout = new CircleLayout<V, E>(dummy) {
// HACK: forces ordering when drawing subLayouts
// relies on AggregateLayout.transform use of layouts.keySet (HashMap)
@Override
public int hashCode() {
return PRIORITY_OF_LAYOUT;
}
};

A higher number will mean the layout will have priority to gather the vertices - but you need to know how many 'layouts' there are in order to know how high your integer can go (the user must read the HashMap docs to understand this further).

(Note that I need to create a 'dummy' Graph here, even though I set the real graph later. This is an API problem that exists in much of JUNG).

Please support ordering directly. One way of doing this would be to use a SortedSet and insist that Layouts implement Sortable, but that might break other things. A more direct solution could be for the user to provide a SortedSet of Layout keys (but then you'd need to check for user error - extra/missing Layouts).

Discussion


Log in to post a comment.