I had some time on the plane so I decided to experiment with some
ideas I've had for painters. I've just committed the following two
AlphaPainter: this is a CompoundPainter subclass which adds the
ability to set the alpha for the entire stack of painters. It does it
by setting a new composite which means it will multiple the alpha by
the alpha of any colors you use. For most cases this does exactly
what you want and lets you fade an entire stack of painters very
easily. Great for rollover animations. If we decide we like this I
may merge the alpha functionality down into the CompoundPainter
JXBoxPanel: this is a JXPanel subclass with support for CSS Box
Model like sizing. A box in CSS has margins, borders, and padding,
each of which can be independently set. This allows for a great about
of styling control without having to change your hierarchy.
JComponents only borders. This means you must sometimes resort to
funky layout managers or painting hacks to get your components to be
inset correctly. For example, if you had a panel with a round rect
painter with a glow border you would need to give it extra room for
the glow effect. This means you would need to inset your child
components somewhat. To do that you either must set a wide empty
border to act as padding or else customize the layout (like the
insets args on GridBagConstraints). This is even more complicated if
you still want to have a real javax.swing.Border as well. The CSS
Box Model solves this by adding setPadding(Insets) and setMargins
(Insets) to the existing setBorder(Border) method.
JXBoxPanel.getInsets() will now return the *sum* of the various
insets and the background painter will be resized to only fill the
padding area (per the CSS spec). With this simple addition it will
be a lot easier to do custom styling of components, as well as set us
up for the day when we can actually use CSS files to style Swing
components. I have done this work in the JXBoxPanel subclass until
we decide what to do with it.
- Blasting forth in three part harmony!