The Source for Java Technology Collaboration
User: Password:



Hans Muller's Blog

March 2006 Archives


MultiSplitPane: Splitting Without Nesting [Shameless Plug]

Posted by hansmuller on March 23, 2006 at 08:23 AM | Permalink | Comments (10)

One aspect of many docking GUIs is support for reconfiguring tiled subwindows by dragging shared subwindow edges. MultiSplitPane and MultiSplitLayout support arbitraily complex tiled layouts that can be reconfigured interactively and programatically.

As introductory paragraphs go, the previous one has to set a new record for "not catchy". It always seems easier to start these things with a personal story or recollection. So how about this:

Earlier this year I was arguing with Tim Boudreau about docking frameworks and how best to compute an initial layout, when it occurred to me that a tree structured model would be a nice way to encode the relative sizes and positions of the tiles. If nodes in the tree corresponded to tiles arranged in rows and columns, and if tiles were allocated space proportionally, it seemed like only a small project to build a two dimensional analag of JSplitPane. Tim suggested that my project estimating skills were suspect and besides, there were more important things to do. He was right on both counts, and yet. Sometimes, when you're orbiting around an idea, headed somewhere else, you find yourself captured by the idea's gravitational field. As it turns out, I was in the software-idea equivalent of a tractor beam.

Over the next two days, I implemented the idea. Since subwindow tiles were always allocated a fixed percentage of the available space, it was easy to write a recursive layout algorithm that arranged the rows and columns. As I was just finishing up, Josh Marinacci dropped by, and so I proudly demo'd my creation. The nice way to respond to someone's new demo, on Friday afternoon, is to smile, deliver a bland compliment, and suggest that it's time for a cold one. Josh said: "that's nice, but I don't think anyone would really want to use it". After I stopped crying, he pointed out that people expect subwindow tile boundaries to stay put when the window is resized. This is true, and it makes the problem substantially more difficult. It means that growing and shrinking the layout aren't symmetrical, and it implies that the layout should honor preferred tile sizes, until the user has indicated otherwise by dragging an edge. So, with tears in my eyes, I started over again.

Version two of the layout algorithm took considerably longer than the original version. The result is the aforementioned MultiSplitPane and MultiSplitLayout classes, a small set of demos, a smattering of unit tests, javadoc, a nod to accessibility (more on that later), and an article that explains how it all works. The article bows today on java.net, it's called MultiSplitPane: Multi-Way Splitting Without Nesting. I hope you'll find the time to read it. The classes will become part of the SwingLabs project now and perhaps be incorporated into a future Java release.





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds