Discussion:
[Freecol-developers] InformationPanel fail
Michael T. Pope
2015-05-27 11:41:20 UTC
Permalink
Something strange is happening to InformationPanels, where the text
gets cut off on the right edge --- see attached. git bisect
identifies git.555af3b as the commit where it started. Is this just me
or are you seeing it wintertime?

Cheers,
Mike Pope
w***@genial.ms
2015-05-27 21:14:51 UTC
Permalink
Hi,

thats unfortunate.
The problem is, the code for sizing the text area to add line-breaks
always had a really weird imaginary number of characters to specify this.
This never worked, as its dependent on several font parameters,
which font Java decided to use and even which characters are used
in the displayed text, causing sometimes half of the width being unused
and sometimes too wide text getting cut off.

I recently tweaked the values and made it adapt to the scaling factor.
I thought its better than it was before, but I only used the warning
panel you see when loading a foreign savegame to check if it looked right.
There are separate numbers for panels with and without an icon. You
can see what was changed in git.555af3b3, if you like to tweak the
values for your usecase. Otherwise, I would need a savegame where the
dialog appears.
In the future, I'd like to see someone refactoring the code in Utility
for text areas to take a pixel size, avoiding such guessing and
tedious repeated tweaking.


Greetings,

wintertime


> Gesendet: Mittwoch, 27. Mai 2015 um 13:41 Uhr
> Von: "Michael T. Pope" <***@computer.org>
> An: "FreeCol Developers" <freecol-***@lists.sourceforge.net>
> Betreff: [Freecol-developers] InformationPanel fail
>
> Something strange is happening to InformationPanels, where the text
> gets cut off on the right edge --- see attached. git bisect
> identifies git.555af3b as the commit where it started. Is this just me
> or are you seeing it wintertime?
>
> Cheers,
> Mike Pope

------------------------------------------------------------------------------
Michael T. Pope
2015-06-07 07:27:31 UTC
Permalink
On Wed, 27 May 2015 23:14:51 +0200
***@genial.ms wrote:
> I recently tweaked the values and made it adapt to the scaling factor.
> I thought its better than it was before, but I only used the warning
> panel you see when loading a foreign savegame to check if it looked right.

It might be somewhat better, I am not sure. However I am still seeing
truncation on the opening tutorial message, and AFAICT any other
InformationPanel with enough text, such as the independence declaration
response (attached). This needs to be fixed.

Cheers,
Mike Pope
w***@genial.ms
2015-06-07 08:59:57 UTC
Permalink
Hello,

as I already told this number is very weakly defined and its effect
can vary. I reduced it a bit again, but I cant see your screen.
Font size is the height of a letter, but these are variable width fonts.
Its impossible to predict the column size from the height, yet this
badly designed Java API does not take a pixel size (I did look for such
an alternative method now). If the word near the end of line is
a bit longer it may insert the line break before it and it looks right.
Each letter can be a different size and have differently sized gap
inbetween letters and Java loads a different font depending on your system.
I checked the history on why we are not using the fonts from the data
directory (as that would provide a little more consistency) and instead
let Java decide on some system font, but it was changed a few times
together with other edits to the FreeCol code.
Was that accidental or had there been a deeper reason for that?


Regards,

wintertime


> Gesendet: Sonntag, 07. Juni 2015 um 09:27 Uhr
> Von: "Michael T. Pope" <***@computer.org>
> An: "FreeCol Developers" <freecol-***@lists.sourceforge.net>
> Betreff: Re: [Freecol-developers] InformationPanel fail
>
> On Wed, 27 May 2015 23:14:51 +0200
> ***@genial.ms wrote:
> > I recently tweaked the values and made it adapt to the scaling factor.
> > I thought its better than it was before, but I only used the warning
> > panel you see when loading a foreign savegame to check if it looked right.
>
> It might be somewhat better, I am not sure. However I am still seeing
> truncation on the opening tutorial message, and AFAICT any other
> InformationPanel with enough text, such as the independence declaration
> response (attached). This needs to be fixed.
>
> Cheers,
> Mike Pope

------------------------------------------------------------------------------
Michael T. Pope
2015-06-07 09:34:24 UTC
Permalink
On Sun, 7 Jun 2015 10:59:57 +0200
***@genial.ms wrote:
> Was that accidental or had there been a deeper reason for that?

I doubt there was anything deliberate that is relevant to the current
problem. Anything I did was probably just for consistency, but its not an
area I recall doing much with.

Cheers,
Mike Pope
Michael T. Pope
2015-06-07 10:27:22 UTC
Permalink
On Sun, 7 Jun 2015 10:59:57 +0200
***@genial.ms wrote:
> as I already told this number is very weakly defined and its effect
> can vary. I reduced it a bit again, but I cant see your screen.

Understood. Alas the tutorial remains broken, and by a fair bit
still (the phrase "claim it for the Crown." is displayed as "cla" and "the
Crown"). I doubt that twiddling the magic numbers is going to help here.
Something more fundamental seems called for.

> Font size is the height of a letter, but these are variable width fonts.
> Its impossible to predict the column size from the height, yet this
> badly designed Java API does not take a pixel size

So is there an API available that does allow us to work out if the text
will fit? I can see that the reliance on a number of columns in
getDefaultTextArea is going to be a problem for variable width fonts, so
that may be the place FreeCol needs to be changed. That may even be a
hold over from a time when FreeCol was using a fixed width font for all I
know.

Cheers,
Mike Pope
w***@genial.ms
2015-06-07 19:59:48 UTC
Permalink
Hi,

> So is there an API available that does allow us to work out if the text
> will fit? I can see that the reliance on a number of columns in
> getDefaultTextArea is going to be a problem for variable width fonts, so
> that may be the place FreeCol needs to be changed. That may even be a
> hold over from a time when FreeCol was using a fixed width font for all I
> know.
>

I googled a bit and found someone praising the broken way of setting a column
size and warning against ignoring it and just using setPreferredSize as that
would override it and not adapt to the font.
This is actually what we want, so I would say we should try and do this
everywhere in Utility.
I also found something on Oracle website mentioning to call setPreferredSize
on the JScrollPane containing the JTextArea.
Its just that I found I've come to detest fiddling with getting all these GUI
elements to look right, so it may take some time.


Greetings,

wintertime

------------------------------------------------------------------------------
Michael T. Pope
2015-06-10 11:06:59 UTC
Permalink
On Sun, 7 Jun 2015 21:59:48 +0200
***@genial.ms wrote:
> This is actually what we want, so I would say we should try and do this
> everywhere in Utility.

Agreed.

> I also found something on Oracle website mentioning to call setPreferredSize
> on the JScrollPane containing the JTextArea.
> Its just that I found I've come to detest fiddling with getting all these GUI
> elements to look right, so it may take some time.

Understood. Its galling when there is no clear guaranteed working path.

Cheers,
Mike Pope
Loading...