RFR: 8176501: Method Shape.getBounds2D() incorrectly includes Bezier control points in bounding box [v2]

Laurent Bourgès lbourges at openjdk.java.net
Fri Nov 5 10:48:12 UTC 2021


On Fri, 5 Nov 2021 09:59:09 GMT, Laurent Bourgès <lbourges at openjdk.org> wrote:

>> Jeremy has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8176501: Method Shape.getBounds2D() incorrectly includes Bezier control points in bounding box
>>   
>>   Addressing some of Laurent's code review recommendations/comments:
>>   
>>   1. use the convention t for the parametric variable x(t),y(t)
>>   2. solve the quadratic equation using QuadCurve2d.solveQuadratic() or like Helpers.quadraticRoots()
>>   3. always use braces for x = (a < b) ? ...
>>   4. always use double-precision constants in math or logical operations: (2 * x => 2.0 * x) and (coefficients[3] != 0) => (coefficients[3] != 0.0)
>>   
>>   (There are two additional recommendations not in this commit that I'll ask about shortly.)
>>   
>>   See https://github.com/openjdk/jdk/pull/6227#issuecomment-959757954
>
> src/java.desktop/share/classes/java/awt/geom/Path2D.java line 2118:
> 
>> 2116:         double lastY = 0.0;
>> 2117: 
>> 2118:         pathIteratorLoop : while (!pi.isDone()) {
> 
> remove the label `pathIteratorLoop` (trivial)

I prefer also for loops:
for (final PathIterator it = shape.getPathIterator(null); !it.isDone(); it.next()) {
            int type = it.currentSegment(coords);
...
}

-------------

PR: https://git.openjdk.java.net/jdk/pull/6227



More information about the client-libs-dev mailing list