getBounds vs getBounds2D
While reading the Java documentation on a Polygon, i discovered there is a getBounds
method and a ge开发者_StackOverflow中文版tBounds2D
method. It was noted that the first one was less accurate than the second one.
I was wondering what exactly is meant by 'less accurate'? Does getBounds
return a false value or is it about 256 vs 256.3 (example)? Or is it something completely different?
Thanks for any enlightenment,
Samuel
getBounds
returns a Rectangle, composed of integers, but getBounds2D
returns a Rectangle2D, which is composed of floating point numbers, so greater precision is possible.
For Polygon
, it shouldn't make a difference, because all of a Polygon
's points are integer-based, but for the more general Shape
, which Polygon
implements, it can matter.
精彩评论