简体   繁体   中英

Rectangle.contains() method never returns true

The diagram that i use returns a org.eclipse.draw2d.geometry.Rectangle with co-ordinates Rectangle(20.0, 450.0, 0.0, 0.0). I want to check if a point (20,450) is present within it.

I have tried this with contains and equals method. but it doesn't return true. what am i doing wrong?

if (rectangle.contains(new Point(20, 450)))
{
   return true;
}

I except the output to be true. I can change the co-ordinates of the point but not the co-ordinates of the rectangle.

The documentation literally explains this.

 public boolean contains(double x, double y) 

Returns whether the given coordinates are within the boundaries of this Rectangle. The boundaries are inclusive of the top and left edges, but exclusive of the bottom and right edges.

Your point is the bottom right corner.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM