Integrated: 8176501: Method Shape.getBounds2D() incorrectly includes Bezier control points in bounding box
Jeremy
duke at openjdk.java.net
Wed Apr 27 18:45:59 UTC 2022
On Wed, 3 Nov 2021 07:27:03 GMT, Jeremy <duke at openjdk.java.net> wrote:
> This removes code that relied on consulting the Bezier control points to calculate the Rectangle2D bounding box. Instead it's pretty straight-forward to convert the Bezier control points into the x & y parametric equations. At their most complex these equations are cubic polynomials, so calculating their extrema is just a matter of applying the quadratic formula to calculate their extrema. (Or in path segments that are quadratic/linear/constant: we do even less work.)
>
> The bug writeup indicated they wanted Path2D#getBounds2D() to be more accurate/concise. They didn't explicitly say they wanted CubicCurve2D and QuadCurve2D to become more accurate too. But a preexisting unit test failed when Path2D#getBounds2D() was updated and those other classes weren't. At this point I considered either:
> A. Updating CubicCurve2D and QuadCurve2D to use the new more accurate getBounds2D() or
> B. Updating the unit test to forgive the discrepancy.
>
> I chose A. Which might technically be seen as scope creep, but it feels like a more holistic/better approach.
>
> Other shapes in java.awt.geom should not require updating, because they already identify concise bounds.
>
> This also includes a new unit test (in Path2D/UnitTest.java) that fails without the changes in this commit.
This pull request has now been integrated.
Changeset: 8a16842b
Author: jeremy <jeremy.wood at mac.com>
Committer: Phil Race <prr at openjdk.org>
URL: https://git.openjdk.java.net/jdk/commit/8a16842b4e906b2eede0c01914f41010cabc51c2
Stats: 713 lines in 6 files changed: 594 ins; 114 del; 5 mod
8176501: Method Shape.getBounds2D() incorrectly includes Bezier control points in bounding box
Reviewed-by: prr
-------------
PR: https://git.openjdk.java.net/jdk/pull/6227
More information about the client-libs-dev
mailing list