RFR: 8325154: resizeColumnToFitContent is slower than it needs to be

Robert Lichtenberger rlichten at openjdk.org
Wed Feb 7 07:42:59 UTC 2024


On Tue, 6 Feb 2024 15:53:07 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

> > So maybe we should:
> > 
> > * Provide an API that let's the client specify how many rows should be taken into account
> > * Make resizeColumnToFitContent available for clients
> 
> Let's create an RFE. What would be your recommendation for the specific API?

At first I had only thought about a simple "setColumnFitSamplSize(int sampleSize)" method. However, @hjohn s suggestion of a strategy pattern seems convincing to me: It allows the client to specify how the required column width is calculated.

I'm not quite sure how to approach this however. If we have a "ColumnFitStrategy" interface/baseclass with just a simple "calculateColumnWidth(int column)" this would not help clients since they don't have access to a lot of the stuff that's happening inside resizeColumnToFitContent.
If, on the other hand, we only allow a "ColumnFitRowSelection" interface/baseclass that will return the rows to be used for measuring, the client code will not be able to optimize in some cases (e.g. you have graphics in your table; loading them is expensive; but you know the size of the graphics and could thus give a "correct" required size without really loading/applying css).

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1358#issuecomment-1931449204


More information about the openjfx-dev mailing list