pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill van Melle <bill.van.me...@gmail.com>
Subject Re: Does ButtonDataRenderer#setFillIcon not work?
Date Wed, 23 Mar 2011 22:50:58 GMT
>
> Could you use a LinkButton with an image as its button data? Link buttons
> don't draw any additional decoration.
>

Okay.  It wasn't really clear to me from the tutorials what the intended use
for one type over the other was, but lack of extra decoration is an
interesting distinction in this case.  But LinkButtonDataRenderer doesn't
even have a setFillIcon method, so I'd have to do something about that.


> > ((ButtonDataRenderer)button.getDataRenderer()).setFillIcon(true);
>
> FYI - by default, all buttons share a common renderer instance. Unless you
> have previously called setDataRenderer() on this button with a new instance,
> you will actually be modifying the default renderer (probably not what you
> want).


Perhaps not (though I'm not sure why I wouldn't always want my images to
size to the button they're in).  But that doesn't tell me why setFillIcon
didn't do what I wanted.  I thought about it a little more and realized that
the ImageView must not be getting a size constraint.  Sure
enough, ButtonDataRenderer is our old friend BoxPane, and it does not have
its fill style set to true.  Thus, the following workaround does the trick:

public class ButtonDataRendererWithFill extends ButtonDataRenderer {
public ButtonDataRendererWithFill() {
imageView.getStyles().put("fill", true);
this.getStyles().put("fill", true);
}
}

and then in my user code

    button.setDataRenderer(new ButtonDataRendererWithFill());

So indeed, setFillIcon has no effect as ButtonDataRenderer is currently
written.  Seems like a bug.  If you agree, I can create a ticket and suggest
the one-line fix of doing

    getStyles().put("fill", true);

in the ButtonDataRenderer constructor.

I note that setFillIcon has additional problems when the ButtonData contains
text, which this one-liner doesn't fix.  Not sure if that's a bug in
BoxPane, ImageView, or a fundamental shortcoming of the measurement system.

Mime
View raw message