Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] Why is converting from double to int done using the Math.floor?

Hi all,

since the GEF forum is basically dead I would like to ask you here. Why is used Math.floor in all Precision* classes?

Let me give you an example:

First of all, I use PrecisionPoint, PrecisionRectangle, PrecisionDimension everywhere.

So there is a line with y coordinate 31.14. You have a rectangle with height 18.315 that you would like to draw exactly above the line so its bottom edge overlaps the line. But since the converting from double to int is done using Math.floor the coordinates
are as such:

the line:
    y: 31.14 -> 31
the rectangle
    y: 31.14 - 18.315 =  12.825 -> 12
    height: 18.315 -> 18

As you can see the rectangle will be rendered above the line. They don't overlap. Why aren't double coordinates rounded?
Do I compute the y of the rectangle in wrong way?

Thanks, Jan Krakora.


Back to the top