Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rectangle2D getY() returns value less than getMaxY()

Tags:

java

geometry

awt

As I interpret the documentation, getY() is supposed to return the upper-left hand Y coordinate of a rectangle; i.e the biggest Y coordinate. However, when calling getMaxY() (which is inherited from the RectangularShape class) I get back a bigger value!

In code:

Path2D bg = polygons.get(polyId2GeoId.get(id));
Rectangle2D bgBox = bg.getBounds2D();
boolean omgwtfbbqrsvp = bgBox.getY()<bgBox.getMaxY();

omgwtfbbqrsvp is true... What am I missing here?

My x values contain negative numbers idk if that makes a difference. It sames like bgBox.getY() == bgBox.getMinY() (which is wrong if getY is upper coord) but bgBox.getX() == bgBox.getMinX() (which is correct if getX is left coord). The heights and widths appear correct.

Thanks!

like image 207
Junier Avatar asked Aug 10 '26 04:08

Junier


1 Answers

The problem is that the coordinate system used here has its point (0,0) on the upper left corner. The point (n,n) is on the lower right corner.

like image 156
RoflcoptrException Avatar answered Aug 11 '26 17:08

RoflcoptrException