RFR: 8316518 javafx.print.Paper getWidth / getHeight rounds values, causing errors.

Andy Goryachev angorya at openjdk.org
Fri Sep 22 17:37:24 UTC 2023


On Tue, 19 Sep 2023 11:56:39 GMT, Florian Kirmaier <fkirmaier at openjdk.org> wrote:

> The Method javafx.print.getWidth and getHeight returns a double of points.
> But the values are always rounded to full integers. This causes especially problems,
> with mm based Papers.
> 
> I asked in the mailing list, with the conclusion (me and John Hendrix) that is best to just fix this behavior by removing the rounding.

modules/javafx.graphics/src/main/java/javafx/print/Paper.java line 83:

> 81:             case POINT : return dim;
> 82:             case INCH  : return dim * 72;
> 83:             case MM    : return (dim * 72) / 25.4;

yeah,  I also don't quite understand why we have the rounding (I mean, floor'ing) here.
I would vote to remove the typecast as the OP proposes.

But there is more:
1. why in the world the constructor is not public?  what if I need to print a Commercial 8-5/8 envelope? 
see https://www.papersizes.org/us-envelope-sizes.htm

2. what is going on in hashCode??

    public final int hashCode() {
        return (int)width+((int)height<<16)+units.hashCode();
    }

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1244#discussion_r1334659707


More information about the openjfx-dev mailing list