Reputation: 37
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.
Upvotes: 0
Views: 763
Reputation: 44150
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.
Upvotes: 3