Aha*_*med 8 java double awt dimension
我很惊讶地看到吸气鬼height和width成员都有return类型double,尽管他们是int.此外,setSize具有双参数的方法具有以下定义:
/**
* Sets the size of this <code>Dimension</code> object to
* the specified width and height in double precision.
* Note that if <code>width</code> or <code>height</code>
* are larger than <code>Integer.MAX_VALUE</code>, they will
* be reset to <code>Integer.MAX_VALUE</code>.
*
* @param width the new width for the <code>Dimension</code> object
* @param height the new height for the <code>Dimension</code> object
*/
public void setSize(double width, double height) {
this.width = (int) Math.ceil(width);
this.height = (int) Math.ceil(height);
}
Run Code Online (Sandbox Code Playgroud)
请看一下Dimension类.上面的评论说,值不能超过Integer.MAX_VALUE.为什么?我们为什么double介于两者之间?有什么微妙的原因吗?有人可以向我解释一下吗?对不起我的坚持!
java.awt.Dimension经过改装以适合java.awt.geom包装,以便可以在任何Dimension2D需要的地方使用。后者的接口处理浮点,所以Dimension也必须处理。由于仅限于字段,只能表示 sint的子集。也同样受到限制。doubleDimension2D.Float