From what I can see the way the current aspect ratio is calculated and then
used is biased towards an increase in width. In that context I can see why you
call it a minimum aspect ratio.
To make what I want work I need the bias to be for the height to increase so
that really the aspect ratio is a maximum. So what I have done is to say that
if the aspect ratio is +ve then the current behaviour applies but if it is -ve
then the aspect ratio is a maximum and the height needs to be increased. Using
a negative number has just been a simple way of getting a result without
having to change to much code.
---
In getPreferredWidth() nothing changes.
In getPrefereedHeight() the calculation using aspect ratio is:
// Adjust for preferred aspect ratio
if (!Float.isNaN(minimumPreferredAspectRatio)
&& minimumPreferredAspectRatio < 0.0
&& (float)width / (float)preferredHeight > -
minimumPreferredAspectRatio) {
preferredHeight = (int)(width / -minimumPreferredAspectRatio);
}
In getPreferredSize() it is:
// Adjust for preferred aspect ratio
if (!Float.isNaN(minimumPreferredAspectRatio)
&& (float)preferredWidth / (float)preferredHeight <
minimumPreferredAspectRatio) {
preferredWidth = (int)(preferredHeight *
minimumPreferredAspectRatio);
}
else if (!Float.isNaN(minimumPreferredAspectRatio)
&& minimumPreferredAspectRatio < 0.0
&& (float)preferredWidth / (float)preferredHeight > -
minimumPreferredAspectRatio) {
preferredHeight = (int)(preferredWidth / -
minimumPreferredAspectRatio);
}
---
The height not being changed when the aspect ratio is +ve doesn't appear to
affect either of our use cases. I can't think what affect this will have in
general.
On Tue, 11 Aug 2009 10:04:26 am Greg Brown wrote:
> OK. How about a high-level description of the change?
>
> On Aug 10, 2009, at 6:31 PM, Scott Lanham wrote:
> > I'll give it a go but I will need to change what I have done. It is
> > not
> > suitable to submit as a patch.
> >
> > On Mon, 10 Aug 2009 10:38:34 pm Greg Brown wrote:
> >> It is worth considering. Can you provide a patch that implements your
> >> proposed solution so we can take a look?