Rectangle.contains() 方法永远不会 returns true
Rectangle.contains() method never returns true
我使用 return 的图表 org.eclipse.draw2d.geometry.Rectangle 坐标为矩形 (20.0, 450.0, 0.0, 0.0)。我想检查其中是否存在一个点 (20,450)。
我已经用 contains 和 equals 方法试过了。但它 return 不是真的。我做错了什么?
if (rectangle.contains(new Point(20, 450)))
{
return true;
}
我除了输出为真。我可以改变点的坐标,但不能改变矩形的坐标。
The documentation 从字面上解释了这一点。
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.
你的点在右下角。
我使用 return 的图表 org.eclipse.draw2d.geometry.Rectangle 坐标为矩形 (20.0, 450.0, 0.0, 0.0)。我想检查其中是否存在一个点 (20,450)。
我已经用 contains 和 equals 方法试过了。但它 return 不是真的。我做错了什么?
if (rectangle.contains(new Point(20, 450)))
{
return true;
}
我除了输出为真。我可以改变点的坐标,但不能改变矩形的坐标。
The documentation 从字面上解释了这一点。
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.
你的点在右下角。