This is an automated email from the ASF dual-hosted git repository. mattjuntunen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
The following commit(s) were added to refs/heads/master by this push: new 1410a0e Minor Improvement 1410a0e is described below commit 1410a0ee436e6dfef835e6b6d95d2746577f6e3c Author: Arturo Bernal <arturobern...@gmail.com> AuthorDate: Fri Dec 18 18:16:39 2020 +0100 Minor Improvement * 'for' loop replaceable with enhanced 'for' loop * Unnecessary unboxing * Explicit type can be replaced with <> * Statement lambda can be replaced with expression lambda * Call to 'Arrays.asList()' with too few arguments --- .../AbstractConvexHyperplaneBoundedRegion.java | 2 +- .../commons/geometry/core/GeometryTestUtils.java | 26 ------- .../core/internal/IteratorTransformTest.java | 2 +- .../core/partitioning/BoundaryListTest.java | 16 ++--- .../geometry/core/partitioning/SplitTest.java | 8 +-- .../core/partitioning/test/TestLineSegment.java | 16 ++--- .../test/TestLineSegmentCollection.java | 2 +- .../euclidean/threed/AbstractConvexPolygon3D.java | 4 +- .../geometry/euclidean/threed/Bounds3D.java | 2 +- .../threed/AffineTransformMatrix3DTest.java | 82 +++++++++------------- .../euclidean/threed/BoundaryList3DTest.java | 7 +- .../euclidean/threed/RegionBSPTree3DTest.java | 8 +-- .../threed/mesh/SimpleTriangleMeshTest.java | 3 +- .../threed/rotation/QuaternionRotationTest.java | 22 ++---- .../twod/AffineTransformMatrix2DTest.java | 68 +++++++----------- .../euclidean/twod/BoundaryList2DTest.java | 7 +- .../io/threed/DefaultModelIOHandlerRegistry.java | 6 +- .../threed/DefaultModelIOHandlerRegistryTest.java | 2 +- .../io/threed/ModelIOHandlerRegistryTest.java | 2 +- .../io/threed/obj/OBJModelIOHandlerTest.java | 2 +- .../examples/io/threed/obj/OBJReaderTest.java | 2 +- .../twod/ConvexHullGenerator2DAbstractTest.java | 4 +- .../geometry/spherical/oned/RegionBSPTree1S.java | 4 +- .../spherical/twod/BoundaryList2STest.java | 7 +- .../geometry/spherical/twod/GreatArcPathTest.java | 82 +++++++++------------- .../spherical/twod/RegionBSPTree2STest.java | 4 +- 26 files changed, 150 insertions(+), 240 deletions(-) diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegion.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegion.java index e449955..9cd9d89 100644 --- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegion.java +++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegion.java @@ -161,7 +161,7 @@ public abstract class AbstractConvexHyperplaneBoundedRegion<P extends Point<P>, */ protected <R extends AbstractConvexHyperplaneBoundedRegion<P, S>> R transformInternal( final Transform<P> transform, final R thisInstance, final Class<S> boundaryType, - final Function<List<S>, R> factory) { + final Function<? super List<S>, R> factory) { if (isFull()) { return thisInstance; diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java index 23774b9..5d8a802 100644 --- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java +++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/GeometryTestUtils.java @@ -16,10 +16,6 @@ */ package org.apache.commons.geometry.core; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.util.regex.Pattern; import org.junit.jupiter.api.Assertions; @@ -102,26 +98,4 @@ public final class GeometryTestUtils { Assertions.assertTrue(obj.equals(obj), "Object should equal itself"); } - - /** - * Serializes and then recovers an object from a byte array. Returns the deserialized object. - * - * @param obj object to serialize and recover - * @return the recovered, deserialized object - */ - public static Object serializeAndRecover(final Object obj) { - try { - // serialize the Object - final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - final ObjectOutputStream so = new ObjectOutputStream(bos); - so.writeObject(obj); - - // deserialize the Object - final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); - final ObjectInputStream si = new ObjectInputStream(bis); - return si.readObject(); - } catch (final Exception e) { - throw new RuntimeException(e); - } - } } diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/IteratorTransformTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/IteratorTransformTest.java index cb8a019..64f1189 100644 --- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/IteratorTransformTest.java +++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/IteratorTransformTest.java @@ -70,7 +70,7 @@ public class IteratorTransformTest { @Override protected void acceptInput(final Integer input) { // filter out odd integers - final int value = input.intValue(); + final int value = input; if (value % 2 == 0) { final char[] chars = (value + "").toCharArray(); diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/BoundaryListTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/BoundaryListTest.java index 62827a5..71cb040 100644 --- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/BoundaryListTest.java +++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/BoundaryListTest.java @@ -54,18 +54,16 @@ public class BoundaryListTest { final BoundaryList<TestPoint2D, TestLineSegment> list = new BoundaryList<>(boundaries); // act/assert - Assertions.assertThrows(UnsupportedOperationException.class, () -> { - list.getBoundaries().add(new TestLineSegment(1, 1, 0, 2)); - }); + Assertions.assertThrows(UnsupportedOperationException.class, () -> list.getBoundaries().add(new TestLineSegment(1, 1, 0, 2))); } @Test public void testCount() { // act/assert Assertions.assertEquals(0, new BoundaryList<>(Collections.emptyList()).count()); - Assertions.assertEquals(1, new BoundaryList<>(Arrays.asList( - new TestLineSegment(0, 0, 1, 1) - )).count()); + Assertions.assertEquals(1, new BoundaryList<>(Collections.singletonList( + new TestLineSegment(0, 0, 1, 1) + )).count()); Assertions.assertEquals(2, new BoundaryList<>(Arrays.asList( new TestLineSegment(0, 0, 1, 1), new TestLineSegment(1, 1, 0, 2) @@ -76,9 +74,9 @@ public class BoundaryListTest { public void testToString() { // arrange final BoundaryList<TestPoint2D, TestLineSegment> empty = new BoundaryList<>(Collections.emptyList()); - final BoundaryList<TestPoint2D, TestLineSegment> single = new BoundaryList<>(Arrays.asList( - new TestLineSegment(0, 0, 1, 1) - )); + final BoundaryList<TestPoint2D, TestLineSegment> single = new BoundaryList<>(Collections.singletonList( + new TestLineSegment(0, 0, 1, 1) + )); // act Assertions.assertEquals("BoundaryList[count= 0]", empty.toString()); diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/SplitTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/SplitTest.java index 1bbdcf6..809b4b7 100644 --- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/SplitTest.java +++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/SplitTest.java @@ -42,10 +42,10 @@ public class SplitTest { final Object b = new Object(); // act/assert - Assertions.assertEquals(SplitLocation.NEITHER, new Split<Object>(null, null).getLocation()); - Assertions.assertEquals(SplitLocation.MINUS, new Split<Object>(a, null).getLocation()); - Assertions.assertEquals(SplitLocation.PLUS, new Split<Object>(null, b).getLocation()); - Assertions.assertEquals(SplitLocation.BOTH, new Split<Object>(a, b).getLocation()); + Assertions.assertEquals(SplitLocation.NEITHER, new Split<>(null, null).getLocation()); + Assertions.assertEquals(SplitLocation.MINUS, new Split<>(a, null).getLocation()); + Assertions.assertEquals(SplitLocation.PLUS, new Split<>(null, b).getLocation()); + Assertions.assertEquals(SplitLocation.BOTH, new Split<>(a, b).getLocation()); } @Test diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegment.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegment.java index 965bf39..2d992bf 100644 --- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegment.java +++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegment.java @@ -249,11 +249,11 @@ public class TestLineSegment implements HyperplaneConvexSubset<TestPoint2D> { final int sign = PartitionTestUtils.PRECISION.sign(originOffset); if (sign < 0) { - return new Split<TestLineSegment>(this, null); + return new Split<>(this, null); } else if (sign > 0) { - return new Split<TestLineSegment>(null, this); + return new Split<>(null, this); } - return new Split<TestLineSegment>(null, null); + return new Split<>(null, null); } else { // the lines intersect final double intersectionAbscissa = line.toSubspaceValue(intersection); @@ -274,7 +274,7 @@ public class TestLineSegment implements HyperplaneConvexSubset<TestPoint2D> { final TestLineSegment minus = (startCmp > 0) ? endSegment : startSegment; final TestLineSegment plus = (startCmp > 0) ? startSegment : endSegment; - return new Split<TestLineSegment>(minus, plus); + return new Split<>(minus, plus); } } @@ -305,13 +305,13 @@ public class TestLineSegment implements HyperplaneConvexSubset<TestPoint2D> { if (startCmp == 0 && endCmp == 0) { // the entire line segment is directly on the splitter line - return new Split<TestLineSegment>(null, null); + return new Split<>(null, null); } else if (startCmp < 1 && endCmp < 1) { // the entire line segment is on the minus side - return new Split<TestLineSegment>(this, null); + return new Split<>(this, null); } else if (startCmp > -1 && endCmp > -1) { // the entire line segment is on the plus side - return new Split<TestLineSegment>(null, this); + return new Split<>(null, this); } // we need to split the line @@ -324,6 +324,6 @@ public class TestLineSegment implements HyperplaneConvexSubset<TestPoint2D> { final TestLineSegment minus = (startCmp > 0) ? endSegment : startSegment; final TestLineSegment plus = (startCmp > 0) ? startSegment : endSegment; - return new Split<TestLineSegment>(minus, plus); + return new Split<>(minus, plus); } } diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegmentCollection.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegmentCollection.java index b1d7ba6..eb09c63 100644 --- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegmentCollection.java +++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegmentCollection.java @@ -140,7 +140,7 @@ public class TestLineSegmentCollection implements HyperplaneSubset<TestPoint2D> null : new TestLineSegmentCollection(plusList); - return new Split<TestLineSegmentCollection>(minus, plus); + return new Split<>(minus, plus); } /** {@inheritDoc} */ diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractConvexPolygon3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractConvexPolygon3D.java index 28f2c95..c6d78ea 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractConvexPolygon3D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractConvexPolygon3D.java @@ -111,7 +111,7 @@ abstract class AbstractConvexPolygon3D extends AbstractPlaneSubset implements Co Vector3D curPt; Vector3D prevVec = startPt.vectorTo(prevPt); - Vector3D curVec = null; + Vector3D curVec; double triArea; Vector3D triCentroid; @@ -231,7 +231,7 @@ abstract class AbstractConvexPolygon3D extends AbstractPlaneSubset implements Co Vector3D boundaryVec; double boundaryPointT; - Vector3D boundaryPoint = null; + Vector3D boundaryPoint; double boundaryPointDistSq; double closestBoundaryPointDistSq = Double.POSITIVE_INFINITY; diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Bounds3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Bounds3D.java index 1edc2b3..c0a8ddb 100644 --- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Bounds3D.java +++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Bounds3D.java @@ -233,7 +233,7 @@ public final class Bounds3D extends AbstractBounds<Vector3D, Bounds3D> { * @param pts points to add * @return this instance */ - public Builder addAll(final Iterable<Vector3D> pts) { + public Builder addAll(final Iterable<? extends Vector3D> pts) { for (final Vector3D pt : pts) { add(pt); } diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java index 744c626..bd0fe41 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java @@ -970,54 +970,40 @@ public class AffineTransformMatrix3DTest { @Test public void testInverse_nonInvertible() { // act/assert - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix3D.of( - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; matrix determinant is 0.0"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix3D.of( - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, Double.NaN, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix3D.of( - 1, 0, 0, 0, - 0, Double.NEGATIVE_INFINITY, 0, 0, - 0, 0, 1, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix3D.of( - Double.POSITIVE_INFINITY, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix3D.of( - 1, 0, 0, Double.NaN, - 0, 1, 0, 0, - 0, 0, 1, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: NaN"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix3D.of( - 1, 0, 0, 0, - 0, 1, 0, Double.POSITIVE_INFINITY, - 0, 0, 1, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: Infinity"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix3D.of( - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, Double.NEGATIVE_INFINITY).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: -Infinity"); + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix3D.of( + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; matrix determinant is 0.0"); + + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix3D.of( + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, Double.NaN, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN"); + + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix3D.of( + 1, 0, 0, 0, + 0, Double.NEGATIVE_INFINITY, 0, 0, + 0, 0, 1, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN"); + + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix3D.of( + Double.POSITIVE_INFINITY, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN"); + + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix3D.of( + 1, 0, 0, Double.NaN, + 0, 1, 0, 0, + 0, 0, 1, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; invalid matrix element: NaN"); + + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix3D.of( + 1, 0, 0, 0, + 0, 1, 0, Double.POSITIVE_INFINITY, + 0, 0, 1, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; invalid matrix element: Infinity"); + + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix3D.of( + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, Double.NEGATIVE_INFINITY).inverse(), IllegalStateException.class, "Matrix is not invertible; invalid matrix element: -Infinity"); } @Test diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/BoundaryList3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/BoundaryList3DTest.java index 723dae6..7ff8fe8 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/BoundaryList3DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/BoundaryList3DTest.java @@ -16,7 +16,6 @@ */ package org.apache.commons.geometry.euclidean.threed; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -35,9 +34,9 @@ public class BoundaryList3DTest { @Test public void testCtor() { // arrange - final List<PlaneConvexSubset> boundaries = Arrays.asList( - Planes.fromNormal(Vector3D.Unit.PLUS_X, TEST_PRECISION).span() - ); + final List<PlaneConvexSubset> boundaries = Collections.singletonList( + Planes.fromNormal(Vector3D.Unit.PLUS_X, TEST_PRECISION).span() + ); // act final BoundaryList3D list = new BoundaryList3D(boundaries); diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java index 1c9ccb6..3e3e20c 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java @@ -1854,11 +1854,9 @@ public class RegionBSPTree3DTest { final List<Vector3D> vertexList = new ArrayList<>(); - for (int i = 0; i < facets.length; ++i) { - final int[] indices = facets[i]; - - for (int j = 0; j < indices.length; ++j) { - vertexList.add(vertices[indices[j]]); + for (final int[] indices : facets) { + for (final int index : indices) { + vertexList.add(vertices[index]); } // insert into an embedded tree and convert to convex polygons so that we can support diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/mesh/SimpleTriangleMeshTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/mesh/SimpleTriangleMeshTest.java index 4c3c18e..0fffebb 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/mesh/SimpleTriangleMeshTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/mesh/SimpleTriangleMeshTest.java @@ -261,8 +261,7 @@ public class SimpleTriangleMeshTest { Vector3D.of(0, 1, 0) ); - final List<int[]> faceIndices = Arrays.asList( - new int[] {0, 1, 2} + final List<int[]> faceIndices = Collections.singletonList(new int[]{0, 1, 2} ); final SimpleTriangleMesh mesh = SimpleTriangleMesh.from(vertices, faceIndices, TEST_PRECISION); diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java index 40c9f17..6fe635f 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java @@ -585,9 +585,9 @@ public class QuaternionRotationTest { // act/assert // test each rotation against all of the others (including itself) - for (int i = 0; i < rotations.length; ++i) { - for (int j = 0; j < rotations.length; ++j) { - checkSlerpCombination(rotations[i], rotations[j]); + for (final QuaternionRotation quaternionRotation : rotations) { + for (final QuaternionRotation rotation : rotations) { + checkSlerpCombination(quaternionRotation, rotation); } } } @@ -822,9 +822,7 @@ public class QuaternionRotationTest { final AxisReferenceFrame frame = AxisReferenceFrame.RELATIVE; for (final AxisSequence axes : getAxes(AxisSequenceType.EULER)) { - for (int i = 0; i < eulerSingularities.length; ++i) { - - final double singularityAngle = eulerSingularities[i]; + for (final double singularityAngle : eulerSingularities) { final AxisAngleSequence inputSeq = new AxisAngleSequence(frame, axes, angle1, singularityAngle, angle2); final QuaternionRotation inputQuat = QuaternionRotation.fromAxisAngleSequence(inputSeq); @@ -859,9 +857,7 @@ public class QuaternionRotationTest { final AxisReferenceFrame frame = AxisReferenceFrame.ABSOLUTE; for (final AxisSequence axes : getAxes(AxisSequenceType.EULER)) { - for (int i = 0; i < eulerSingularities.length; ++i) { - - final double singularityAngle = eulerSingularities[i]; + for (final double singularityAngle : eulerSingularities) { final AxisAngleSequence inputSeq = new AxisAngleSequence(frame, axes, angle1, singularityAngle, angle2); final QuaternionRotation inputQuat = QuaternionRotation.fromAxisAngleSequence(inputSeq); @@ -896,9 +892,7 @@ public class QuaternionRotationTest { final AxisReferenceFrame frame = AxisReferenceFrame.RELATIVE; for (final AxisSequence axes : getAxes(AxisSequenceType.TAIT_BRYAN)) { - for (int i = 0; i < taitBryanSingularities.length; ++i) { - - final double singularityAngle = taitBryanSingularities[i]; + for (final double singularityAngle : taitBryanSingularities) { final AxisAngleSequence inputSeq = new AxisAngleSequence(frame, axes, angle1, singularityAngle, angle2); final QuaternionRotation inputQuat = QuaternionRotation.fromAxisAngleSequence(inputSeq); @@ -933,9 +927,7 @@ public class QuaternionRotationTest { final AxisReferenceFrame frame = AxisReferenceFrame.ABSOLUTE; for (final AxisSequence axes : getAxes(AxisSequenceType.TAIT_BRYAN)) { - for (int i = 0; i < taitBryanSingularities.length; ++i) { - - final double singularityAngle = taitBryanSingularities[i]; + for (final double singularityAngle : taitBryanSingularities) { final AxisAngleSequence inputSeq = new AxisAngleSequence(frame, axes, angle1, singularityAngle, angle2); final QuaternionRotation inputQuat = QuaternionRotation.fromAxisAngleSequence(inputSeq); diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java index 85f3eef..1a14d3d 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java @@ -998,47 +998,33 @@ public class AffineTransformMatrix2DTest { @Test public void testInverse_nonInvertible() { // act/assert - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix2D.of( - 0, 0, 0, - 0, 0, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; matrix determinant is 0.0"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix2D.of( - 1, 0, 0, - 0, Double.NaN, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix2D.of( - 1, 0, 0, - 0, Double.NEGATIVE_INFINITY, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; matrix determinant is -Infinity"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix2D.of( - Double.POSITIVE_INFINITY, 0, 0, - 0, 1, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; matrix determinant is Infinity"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix2D.of( - 1, 0, Double.NaN, - 0, 1, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: NaN"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix2D.of( - 1, 0, Double.POSITIVE_INFINITY, - 0, 1, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: Infinity"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - AffineTransformMatrix2D.of( - 1, 0, Double.NEGATIVE_INFINITY, - 0, 1, 0).inverse(); - }, IllegalStateException.class, "Matrix is not invertible; invalid matrix element: -Infinity"); + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix2D.of( + 0, 0, 0, + 0, 0, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; matrix determinant is 0.0"); + + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix2D.of( + 1, 0, 0, + 0, Double.NaN, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; matrix determinant is NaN"); + + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix2D.of( + 1, 0, 0, + 0, Double.NEGATIVE_INFINITY, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; matrix determinant is -Infinity"); + + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix2D.of( + Double.POSITIVE_INFINITY, 0, 0, + 0, 1, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; matrix determinant is Infinity"); + + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix2D.of( + 1, 0, Double.NaN, + 0, 1, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; invalid matrix element: NaN"); + + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix2D.of( + 1, 0, Double.POSITIVE_INFINITY, + 0, 1, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; invalid matrix element: Infinity"); + + GeometryTestUtils.assertThrowsWithMessage(() -> AffineTransformMatrix2D.of( + 1, 0, Double.NEGATIVE_INFINITY, + 0, 1, 0).inverse(), IllegalStateException.class, "Matrix is not invertible; invalid matrix element: -Infinity"); } @Test diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/BoundaryList2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/BoundaryList2DTest.java index 816af97..2f5ef44 100644 --- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/BoundaryList2DTest.java +++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/BoundaryList2DTest.java @@ -16,7 +16,6 @@ */ package org.apache.commons.geometry.euclidean.twod; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -35,9 +34,9 @@ public class BoundaryList2DTest { @Test public void testCtor() { // arrange - final List<LineConvexSubset> boundaries = Arrays.asList( - Lines.segmentFromPoints(Vector2D.ZERO, Vector2D.of(1, 1), TEST_PRECISION) - ); + final List<LineConvexSubset> boundaries = Collections.singletonList( + Lines.segmentFromPoints(Vector2D.ZERO, Vector2D.of(1, 1), TEST_PRECISION) + ); // act final BoundaryList2D list = new BoundaryList2D(boundaries); diff --git a/commons-geometry-examples/examples-io/src/main/java/org/apache/commons/geometry/examples/io/threed/DefaultModelIOHandlerRegistry.java b/commons-geometry-examples/examples-io/src/main/java/org/apache/commons/geometry/examples/io/threed/DefaultModelIOHandlerRegistry.java index 0410b3d..e019c07 100644 --- a/commons-geometry-examples/examples-io/src/main/java/org/apache/commons/geometry/examples/io/threed/DefaultModelIOHandlerRegistry.java +++ b/commons-geometry-examples/examples-io/src/main/java/org/apache/commons/geometry/examples/io/threed/DefaultModelIOHandlerRegistry.java @@ -16,7 +16,7 @@ */ package org.apache.commons.geometry.examples.io.threed; -import java.util.Arrays; +import java.util.Collections; import org.apache.commons.geometry.examples.io.threed.obj.OBJModelIOHandler; @@ -28,8 +28,6 @@ public class DefaultModelIOHandlerRegistry extends ModelIOHandlerRegistry { /** Construct a new instance and register known handlers. */ public DefaultModelIOHandlerRegistry() { - setHandlers(Arrays.asList( - new OBJModelIOHandler() - )); + setHandlers(Collections.singletonList(new OBJModelIOHandler())); } } diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/DefaultModelIOHandlerRegistryTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/DefaultModelIOHandlerRegistryTest.java index 3073132..deeba97 100644 --- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/DefaultModelIOHandlerRegistryTest.java +++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/DefaultModelIOHandlerRegistryTest.java @@ -38,7 +38,7 @@ public class DefaultModelIOHandlerRegistryTest { private static final DoublePrecisionContext TEST_PRECISION = new EpsilonDoublePrecisionContext(TEST_EPS); - private DefaultModelIOHandlerRegistry registry = new DefaultModelIOHandlerRegistry(); + private final DefaultModelIOHandlerRegistry registry = new DefaultModelIOHandlerRegistry(); @Test public void testDefaultHandlers() { diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOHandlerRegistryTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOHandlerRegistryTest.java index dcb8fd1..55320fe 100644 --- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOHandlerRegistryTest.java +++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOHandlerRegistryTest.java @@ -42,7 +42,7 @@ public class ModelIOHandlerRegistryTest { private static final BoundarySource3D SRC_B = BoundarySource3D.from(); - private ModelIOHandlerRegistry registry = new ModelIOHandlerRegistry(); + private final ModelIOHandlerRegistry registry = new ModelIOHandlerRegistry(); @Test public void testGetSetHandlers() { diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJModelIOHandlerTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJModelIOHandlerTest.java index 845307b..dc7bcd8 100644 --- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJModelIOHandlerTest.java +++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJModelIOHandlerTest.java @@ -53,7 +53,7 @@ public class OBJModelIOHandlerTest { @TempDir protected File anotherTempDir; - private OBJModelIOHandler handler = new OBJModelIOHandler(); + private final OBJModelIOHandler handler = new OBJModelIOHandler(); @Test public void testHandlesType() { diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJReaderTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJReaderTest.java index a568ffc..d39723d 100644 --- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJReaderTest.java +++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJReaderTest.java @@ -45,7 +45,7 @@ public class OBJReaderTest { private static final int CUBE_MINUS_SPHERE_FACES = 728; - private OBJReader reader = new OBJReader(); + private final OBJReader reader = new OBJReader(); @Test public void testReadMesh_emptyInput() throws Exception { diff --git a/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/ConvexHullGenerator2DAbstractTest.java b/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/ConvexHullGenerator2DAbstractTest.java index 20dda2f..107045e 100644 --- a/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/ConvexHullGenerator2DAbstractTest.java +++ b/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/ConvexHullGenerator2DAbstractTest.java @@ -423,8 +423,8 @@ public abstract class ConvexHullGenerator2DAbstractTest { } Assertions.assertEquals(perimeter, hullRegion.getBoundarySize(), 1.0e-12); - for (int i = 0; i < referenceHull.length; ++i) { - Assertions.assertEquals(RegionLocation.BOUNDARY, hullRegion.classify(referenceHull[i])); + for (final Vector2D vector2D : referenceHull) { + Assertions.assertEquals(RegionLocation.BOUNDARY, hullRegion.classify(vector2D)); } } diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java index f1313b5..27d417a 100644 --- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java +++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java @@ -223,7 +223,7 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre BoundaryPair start = null; BoundaryPair end = null; - BoundaryPair current = null; + BoundaryPair current; for (int i = 0; i < boundaryPairCount; ++i) { current = insideBoundaryPairs.get((i + startOffset) % boundaryPairCount); @@ -262,7 +262,7 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre final int size = boundaryPairs.size(); if (size > 0) { - BoundaryPair current = null; + BoundaryPair current; BoundaryPair previous = boundaryPairs.get(size - 1); for (int i = 0; i < size; ++i, previous = current) { diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/BoundaryList2STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/BoundaryList2STest.java index c36c850..0c8ae6b 100644 --- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/BoundaryList2STest.java +++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/BoundaryList2STest.java @@ -16,7 +16,6 @@ */ package org.apache.commons.geometry.spherical.twod; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -35,9 +34,9 @@ public class BoundaryList2STest { @Test public void testCtor() { // arrange - final List<GreatArc> boundaries = Arrays.asList( - GreatCircles.arcFromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION) - ); + final List<GreatArc> boundaries = Collections.singletonList( + GreatCircles.arcFromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION) + ); // act final BoundaryList2S list = new BoundaryList2S(boundaries); diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcPathTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcPathTest.java index ffc64d9..db82ae2 100644 --- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcPathTest.java +++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcPathTest.java @@ -518,77 +518,59 @@ public class GreatArcPathTest { @Test public void testBuilder_points_noPrecisionGiven() { // act/assert - GeometryTestUtils.assertThrowsWithMessage(() -> { - GreatArcPath.builder(null) - .append(Point2S.PLUS_I) - .append(Point2S.PLUS_J); - }, IllegalStateException.class, "Unable to create arc: no point precision specified"); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - GreatArcPath.builder(null) - .prepend(Point2S.PLUS_I) - .prepend(Point2S.PLUS_J); - }, IllegalStateException.class, "Unable to create arc: no point precision specified"); + GeometryTestUtils.assertThrowsWithMessage(() -> GreatArcPath.builder(null) + .append(Point2S.PLUS_I) + .append(Point2S.PLUS_J), IllegalStateException.class, "Unable to create arc: no point precision specified"); + + GeometryTestUtils.assertThrowsWithMessage(() -> GreatArcPath.builder(null) + .prepend(Point2S.PLUS_I) + .prepend(Point2S.PLUS_J), IllegalStateException.class, "Unable to create arc: no point precision specified"); } @Test public void testBuilder_arcsNotConnected() { // act/assert - GeometryTestUtils.assertThrowsWithMessage(() -> { - GreatArcPath.builder(TEST_PRECISION) - .append(Point2S.PLUS_I) - .append(Point2S.PLUS_J) - .append(GreatCircles.arcFromPoints(Point2S.PLUS_K, Point2S.MINUS_J, TEST_PRECISION)); - }, IllegalStateException.class, Pattern.compile("^Path arcs are not connected.*")); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - GreatArcPath.builder(TEST_PRECISION) - .prepend(Point2S.PLUS_I) - .prepend(Point2S.PLUS_J) - .prepend(GreatCircles.arcFromPoints(Point2S.PLUS_K, Point2S.MINUS_J, TEST_PRECISION)); - }, IllegalStateException.class, Pattern.compile("^Path arcs are not connected.*")); + GeometryTestUtils.assertThrowsWithMessage(() -> GreatArcPath.builder(TEST_PRECISION) + .append(Point2S.PLUS_I) + .append(Point2S.PLUS_J) + .append(GreatCircles.arcFromPoints(Point2S.PLUS_K, Point2S.MINUS_J, TEST_PRECISION)), IllegalStateException.class, Pattern.compile("^Path arcs are not connected.*")); + + GeometryTestUtils.assertThrowsWithMessage(() -> GreatArcPath.builder(TEST_PRECISION) + .prepend(Point2S.PLUS_I) + .prepend(Point2S.PLUS_J) + .prepend(GreatCircles.arcFromPoints(Point2S.PLUS_K, Point2S.MINUS_J, TEST_PRECISION)), IllegalStateException.class, Pattern.compile("^Path arcs are not connected.*")); } @Test public void testBuilder_addToFullArc() { // act/assert - GeometryTestUtils.assertThrowsWithMessage(() -> { - GreatArcPath.builder(TEST_PRECISION) - .append(GreatCircles.fromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION).span()) - .append(Point2S.PLUS_J); - }, IllegalStateException.class, Pattern.compile("^Cannot add point .* after full arc.*")); - - GeometryTestUtils.assertThrowsWithMessage(() -> { - GreatArcPath.builder(TEST_PRECISION) - .prepend(GreatCircles.fromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION).span()) - .prepend(Point2S.PLUS_J); - }, IllegalStateException.class, Pattern.compile("^Cannot add point .* before full arc.*")); + GeometryTestUtils.assertThrowsWithMessage(() -> GreatArcPath.builder(TEST_PRECISION) + .append(GreatCircles.fromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION).span()) + .append(Point2S.PLUS_J), IllegalStateException.class, Pattern.compile("^Cannot add point .* after full arc.*")); + + GeometryTestUtils.assertThrowsWithMessage(() -> GreatArcPath.builder(TEST_PRECISION) + .prepend(GreatCircles.fromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION).span()) + .prepend(Point2S.PLUS_J), IllegalStateException.class, Pattern.compile("^Cannot add point .* before full arc.*")); } @Test public void testBuilder_onlySinglePointGiven() { // act/assert - GeometryTestUtils.assertThrowsWithMessage(() -> { - GreatArcPath.builder(TEST_PRECISION) - .append(Point2S.PLUS_J) - .build(); - }, IllegalStateException.class, Pattern.compile("^Unable to create path; only a single point provided.*")); + GeometryTestUtils.assertThrowsWithMessage(() -> GreatArcPath.builder(TEST_PRECISION) + .append(Point2S.PLUS_J) + .build(), IllegalStateException.class, Pattern.compile("^Unable to create path; only a single point provided.*")); - GeometryTestUtils.assertThrowsWithMessage(() -> { - GreatArcPath.builder(TEST_PRECISION) - .prepend(Point2S.PLUS_J) - .build(); - }, IllegalStateException.class, Pattern.compile("^Unable to create path; only a single point provided.*")); + GeometryTestUtils.assertThrowsWithMessage(() -> GreatArcPath.builder(TEST_PRECISION) + .prepend(Point2S.PLUS_J) + .build(), IllegalStateException.class, Pattern.compile("^Unable to create path; only a single point provided.*")); } @Test public void testBuilder_cannotClose() { // act/assert - GeometryTestUtils.assertThrowsWithMessage(() -> { - GreatArcPath.builder(TEST_PRECISION) - .append(GreatCircles.fromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION).span()) - .close(); - }, IllegalStateException.class, "Unable to close path: path is full"); + GeometryTestUtils.assertThrowsWithMessage(() -> GreatArcPath.builder(TEST_PRECISION) + .append(GreatCircles.fromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION).span()) + .close(), IllegalStateException.class, "Unable to close path: path is full"); } @Test diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java index 16259ad..2bf4db8 100644 --- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java +++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java @@ -1037,8 +1037,8 @@ public class RegionBSPTree2STest { private static RegionBSPTree2S latLongToTree(final DoublePrecisionContext precision, final double[][] points) { final GreatArcPath.Builder pathBuilder = GreatArcPath.builder(precision); - for (int i = 0; i < points.length; ++i) { - pathBuilder.append(latLongToPoint(points[i][0], points[i][1])); + for (final double[] point : points) { + pathBuilder.append(latLongToPoint(point[0], point[1])); } return pathBuilder.close().toTree();