getx和getminx之间的区别

Jac*_*III 3 java

我有一个关于Java的Rectangle类的问题.我想知道rectangle.getX()和之间的区别是什么 rectangle.getMinX().当我谷歌搜索它时,在Java文档中我读了这个getX():

以double精度返回边界Rectangle的X坐标.

因为getMinX()我读过以下内容:

以double精度返回Shape的框架矩形的最小X坐标.

现在我想知道:如果对于一个Rectangle,怎么会有不同的X坐标,应该只有一个:

new Rectangle(0,0,100,100) = p1(0,0)|p2(100,0)|p3(0,100)|p4(100,100).
Run Code Online (Sandbox Code Playgroud)

我会理解,例如getMaxX(),是什么样的getX()+getWidth(),但那会getMinX()是什么?我对此非常困惑.

我只需要一个简短的解释,我将非常感激.

Ste*_* P. 7

矩形由下式定义:(x 1,y 1),(x 2,y 2).为了我们的目的,让我们表示(x 1,y 1)和矩形的左上角以及(x 2,y 2)作为右下角.

rectangle.getX()返回x 1,而rectangle.getMinX()返回x k,使得:对于X中的所有x i(x坐标的集合),x k <= x i.通过构造,矩形类定义x 1,使得x 1 = x k,如源代码中所示:

public double getMinX() 
{
    return getX();
}

public double getX()
{
    return x;
}
Run Code Online (Sandbox Code Playgroud)

并在构造函数中进一步解释:

Rectangle(int x,int y,int width,int height)构造一个新的Rectangle,其左上角指定为(x,y),其宽度和高度由同名的参数指定.

 public Rectangle(int x, int y, int width, int height) 
 {
     this.x = x;
     this.y = y;
     this.width = width;
     this.height = height;
 }
Run Code Online (Sandbox Code Playgroud)

注意:其他构造函数调用上面的构造函数.