Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] 2.2 suggestion: Draw2D LayoutManagers as decorators

As I've worked on several editors, I've run into limitations in the Draw2D layout and LayoutManager classes. In particular, there are times I'd like to restrict a layout to a specific area of the screen (a la XYLayout), but let the individual components arrange themselves (a la DelegatingLayout.)

Some layouts stand alone, while others have associated layout managers (and only work with those managers). This can make it difficult to choose an appropriate layout or to use the layout manager of one's choice. So I'd like to suggest a refactoring of the Layout code to use "decorators":
1. Allow a Layout to have a chain of Layout Managers, ending in a default "null" manager contained within AbstractLayout (replace setLayoutManager with addLayoutManager / removeLayoutManager)
2. replace (or extend) setConstraint with boolean addConstraint(IFigure, Object) & removeConstraint(IFigure, Object). These calls would be chained, and could "consume" the constraint (by returning true) in which case the chain ends. Unconsumed constraints could be caught by the null layout manager and either be swallowed silently (returning false at the top level) or raise an exception.

This would move us a long way toward having "toolkits" of layout managers that could be composed together to get the desired effect (as in the "arrange yourselves within this rectangle" example).

..Richard



Back to the top