简体   繁体   English

Rectangle.contains()方法从不返回true

[英]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). 我使用的图返回了一个坐标为Rectangle(20.0,450.0,0.0,0.0)的org.eclipse.draw2d.geometry.Rectangle。 I want to check if a point (20,450) is present within it. 我想检查其中是否存在一个点(20,450)。

I have tried this with contains and equals method. 我已经尝试过包含和等于方法。 but it doesn't return true. 但它不会返回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. 返回给定的坐标是否在此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. 您的意思是右下角。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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