From fbf5a51ea5f700be8d92a4485e468ebfb67cf310 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Tue, 10 Mar 2015 23:05:14 +0100 Subject: [PATCH] Add missing @Override tags, use final for private fields where possible. --- .../geometry/enclosing/WelzlEncloser.java | 1 + .../geometry/euclidean/oned/Euclidean1D.java | 2 ++ .../geometry/euclidean/oned/IntervalsSet.java | 4 +++ .../euclidean/oned/OrientedPoint.java | 9 +++++- .../euclidean/threed/Euclidean3D.java | 2 ++ .../math4/geometry/euclidean/threed/Line.java | 2 ++ .../euclidean/threed/OutlineExtractor.java | 9 ++++-- .../geometry/euclidean/threed/Plane.java | 9 ++++++ .../euclidean/threed/PolyhedronsSet.java | 15 ++++++++-- .../euclidean/threed/SphereGenerator.java | 1 + .../euclidean/twod/DiskGenerator.java | 1 + .../geometry/euclidean/twod/Euclidean2D.java | 2 ++ .../math4/geometry/euclidean/twod/Line.java | 30 +++++++++++++------ .../geometry/euclidean/twod/PolygonsSet.java | 3 ++ .../hull/AbstractConvexHullGenerator2D.java | 1 + .../euclidean/twod/hull/ConvexHull2D.java | 2 ++ .../twod/hull/ConvexHullGenerator2D.java | 1 + .../euclidean/twod/hull/MonotoneChain.java | 1 + .../geometry/partitioning/AbstractRegion.java | 19 ++++++++++++ .../partitioning/AbstractSubHyperplane.java | 7 +++++ .../partitioning/BoundaryBuilder.java | 3 ++ .../partitioning/BoundaryProjector.java | 3 ++ .../partitioning/BoundarySizeVisitor.java | 3 ++ .../math4/geometry/partitioning/NodesSet.java | 3 +- .../geometry/partitioning/RegionFactory.java | 9 ++++++ .../geometry/spherical/oned/ArcsSet.java | 4 +++ .../geometry/spherical/oned/LimitAngle.java | 11 +++++-- .../geometry/spherical/oned/S1Point.java | 3 ++ .../geometry/spherical/oned/Sphere1D.java | 2 ++ .../math4/geometry/spherical/twod/Circle.java | 12 ++++++++ .../geometry/spherical/twod/EdgesBuilder.java | 3 ++ .../spherical/twod/PropertiesComputer.java | 3 ++ .../geometry/spherical/twod/S2Point.java | 3 ++ .../geometry/spherical/twod/Sphere2D.java | 2 ++ 34 files changed, 166 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser.java b/src/main/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser.java index 0891d9946..9cd111278 100644 --- a/src/main/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser.java +++ b/src/main/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser.java @@ -58,6 +58,7 @@ public class WelzlEncloser> implements Enclo } /** {@inheritDoc} */ + @Override public EnclosingBall enclose(final Iterable

points) { if (points == null || !points.iterator().hasNext()) { diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Euclidean1D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Euclidean1D.java index 91610d941..91e97f5ac 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Euclidean1D.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/Euclidean1D.java @@ -45,6 +45,7 @@ public class Euclidean1D implements Serializable, Space { } /** {@inheritDoc} */ + @Override public int getDimension() { return 1; } @@ -57,6 +58,7 @@ public class Euclidean1D implements Serializable, Space { * @return nothing * @throws NoSubSpaceException in all cases */ + @Override public Space getSubSpace() throws NoSubSpaceException { throw new NoSubSpaceException(); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java index e75c5a0c5..e8bd4d4d8 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSet.java @@ -511,6 +511,7 @@ public class IntervalsSet extends AbstractRegion imple *

* @since 3.3 */ + @Override public Iterator iterator() { return new SubIntervalsIterator(); } @@ -599,11 +600,13 @@ public class IntervalsSet extends AbstractRegion imple } /** {@inheritDoc} */ + @Override public boolean hasNext() { return pending != null; } /** {@inheritDoc} */ + @Override public double[] next() { if (pending == null) { throw new NoSuchElementException(); @@ -614,6 +617,7 @@ public class IntervalsSet extends AbstractRegion imple } /** {@inheritDoc} */ + @Override public void remove() { throw new UnsupportedOperationException(); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/OrientedPoint.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/OrientedPoint.java index 71c3333fb..93af5b843 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/OrientedPoint.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/oned/OrientedPoint.java @@ -29,7 +29,7 @@ import org.apache.commons.math4.geometry.partitioning.Hyperplane; public class OrientedPoint implements Hyperplane { /** Vector location. */ - private Vector1D location; + private final Vector1D location; /** Orientation. */ private boolean direct; @@ -55,6 +55,7 @@ public class OrientedPoint implements Hyperplane { * the instance.

* @return the instance itself */ + @Override public OrientedPoint copySelf() { return this; } @@ -68,6 +69,7 @@ public class OrientedPoint implements Hyperplane { } /** {@inheritDoc} */ + @Override public double getOffset(final Point point) { final double delta = ((Vector1D) point).getX() - location.getX(); return direct ? delta : -delta; @@ -84,6 +86,7 @@ public class OrientedPoint implements Hyperplane { * not be used otherwise.

* @return a dummy sub hyperplane */ + @Override public SubOrientedPoint wholeHyperplane() { return new SubOrientedPoint(this, null); } @@ -92,11 +95,13 @@ public class OrientedPoint implements Hyperplane { * @return a region containing the instance (really an {@link * IntervalsSet IntervalsSet} instance) */ + @Override public IntervalsSet wholeSpace() { return new IntervalsSet(tolerance); } /** {@inheritDoc} */ + @Override public boolean sameOrientationAs(final Hyperplane other) { return !(direct ^ ((OrientedPoint) other).direct); } @@ -104,6 +109,7 @@ public class OrientedPoint implements Hyperplane { /** {@inheritDoc} * @since 3.3 */ + @Override public Point project(Point point) { return location; } @@ -111,6 +117,7 @@ public class OrientedPoint implements Hyperplane { /** {@inheritDoc} * @since 3.3 */ + @Override public double getTolerance() { return tolerance; } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Euclidean3D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Euclidean3D.java index 20138a76f..cde306f23 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Euclidean3D.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Euclidean3D.java @@ -44,11 +44,13 @@ public class Euclidean3D implements Serializable, Space { } /** {@inheritDoc} */ + @Override public int getDimension() { return 3; } /** {@inheritDoc} */ + @Override public Euclidean2D getSubSpace() { return Euclidean2D.getInstance(); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java index d5ba1e973..3173ac266 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java @@ -159,6 +159,7 @@ public class Line implements Embedding { /** {@inheritDoc} * @see #getAbscissa(Vector3D) */ + @Override public Vector1D toSubSpace(final Point point) { return new Vector1D(getAbscissa((Vector3D) point)); } @@ -166,6 +167,7 @@ public class Line implements Embedding { /** {@inheritDoc} * @see #pointAt(double) */ + @Override public Vector3D toSpace(final Point point) { return pointAt(((Vector1D) point).getX()); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java index cd9c8b077..2e1bfb4e9 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java @@ -38,13 +38,13 @@ import org.apache.commons.math4.util.FastMath; public class OutlineExtractor { /** Abscissa axis of the projection plane. */ - private Vector3D u; + private final Vector3D u; /** Ordinate axis of the projection plane. */ - private Vector3D v; + private final Vector3D v; /** Normal of the projection plane (viewing direction). */ - private Vector3D w; + private final Vector3D w; /** Build an extractor for a specific projection plane. * @param u abscissa axis of the projection point @@ -136,11 +136,13 @@ public class OutlineExtractor { } /** {@inheritDoc} */ + @Override public Order visitOrder(final BSPTree node) { return Order.MINUS_SUB_PLUS; } /** {@inheritDoc} */ + @Override public void visitInternalNode(final BSPTree node) { @SuppressWarnings("unchecked") final BoundaryAttribute attribute = @@ -154,6 +156,7 @@ public class OutlineExtractor { } /** {@inheritDoc} */ + @Override public void visitLeafNode(final BSPTree node) { } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java index 96e715500..b8f2fa6fb 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java @@ -117,6 +117,7 @@ public class Plane implements Hyperplane, Embedding * @return a new hyperplane, copy of the instance */ + @Override public Plane copySelf() { return new Plane(this); } @@ -215,6 +216,7 @@ public class Plane implements Hyperplane, Embedding project(Point point) { return toSpace(toSubSpace(point)); } @@ -222,6 +224,7 @@ public class Plane implements Hyperplane, Embedding, Embedding point) { final Vector3D p3D = (Vector3D) point; return new Vector2D(p3D.dotProduct(u), p3D.dotProduct(v)); @@ -281,6 +285,7 @@ public class Plane implements Hyperplane, Embedding point) { final Vector2D p2D = (Vector2D) point; return new Vector3D(p2D.getX(), u, p2D.getY(), v, -originOffset, w); @@ -422,6 +427,7 @@ public class Plane implements Hyperplane, Embedding, Embedding, Embedding point) { return ((Vector3D) point).dotProduct(w) + originOffset; } @@ -481,6 +489,7 @@ public class Plane implements Hyperplane, Embedding other) { return (((Plane) other).w).dotProduct(w) > 0.0; } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java index 26b05d99d..9c46ae303 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java @@ -183,11 +183,13 @@ public class PolyhedronsSet extends AbstractRegion { } /** {@inheritDoc} */ + @Override public Order visitOrder(final BSPTree node) { return Order.MINUS_SUB_PLUS; } /** {@inheritDoc} */ + @Override public void visitInternalNode(final BSPTree node) { @SuppressWarnings("unchecked") final BoundaryAttribute attribute = @@ -201,6 +203,7 @@ public class PolyhedronsSet extends AbstractRegion { } /** {@inheritDoc} */ + @Override public void visitLeafNode(final BSPTree node) { } @@ -345,10 +348,10 @@ public class PolyhedronsSet extends AbstractRegion { private static class RotationTransform implements Transform { /** Center point of the rotation. */ - private Vector3D center; + private final Vector3D center; /** Vectorial rotation. */ - private Rotation rotation; + private final Rotation rotation; /** Cached original hyperplane. */ private Plane cachedOriginal; @@ -366,17 +369,20 @@ public class PolyhedronsSet extends AbstractRegion { } /** {@inheritDoc} */ + @Override public Vector3D apply(final Point point) { final Vector3D delta = ((Vector3D) point).subtract(center); return new Vector3D(1.0, center, 1.0, rotation.applyTo(delta)); } /** {@inheritDoc} */ + @Override public Plane apply(final Hyperplane hyperplane) { return ((Plane) hyperplane).rotate(center, rotation); } /** {@inheritDoc} */ + @Override public SubHyperplane apply(final SubHyperplane sub, final Hyperplane original, final Hyperplane transformed) { @@ -418,7 +424,7 @@ public class PolyhedronsSet extends AbstractRegion { private static class TranslationTransform implements Transform { /** Translation vector. */ - private Vector3D translation; + private final Vector3D translation; /** Cached original hyperplane. */ private Plane cachedOriginal; @@ -434,16 +440,19 @@ public class PolyhedronsSet extends AbstractRegion { } /** {@inheritDoc} */ + @Override public Vector3D apply(final Point point) { return new Vector3D(1.0, (Vector3D) point, 1.0, translation); } /** {@inheritDoc} */ + @Override public Plane apply(final Hyperplane hyperplane) { return ((Plane) hyperplane).translate(translation); } /** {@inheritDoc} */ + @Override public SubHyperplane apply(final SubHyperplane sub, final Hyperplane original, final Hyperplane transformed) { diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java index 9604b0db6..f28a76299 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java @@ -33,6 +33,7 @@ import org.apache.commons.math4.util.FastMath; public class SphereGenerator implements SupportBallGenerator { /** {@inheritDoc} */ + @Override public EnclosingBall ballOnSupport(final List support) { if (support.size() < 1) { diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java index 6ab1cfa13..4cc3546f6 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java @@ -29,6 +29,7 @@ import org.apache.commons.math4.util.FastMath; public class DiskGenerator implements SupportBallGenerator { /** {@inheritDoc} */ + @Override public EnclosingBall ballOnSupport(final List support) { if (support.size() < 1) { diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Euclidean2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Euclidean2D.java index 3e6aa3c11..dc30c9838 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Euclidean2D.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Euclidean2D.java @@ -44,11 +44,13 @@ public class Euclidean2D implements Serializable, Space { } /** {@inheritDoc} */ + @Override public int getDimension() { return 2; } /** {@inheritDoc} */ + @Override public Euclidean1D getSubSpace() { return Euclidean1D.getInstance(); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java index 00763dea7..3bfae8dd3 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java @@ -136,6 +136,7 @@ public class Line implements Hyperplane, Embedding, Embedding point) { Vector2D p2 = (Vector2D) point; return new Vector1D(MathArrays.linearCombination(cos, p2.getX(), sin, p2.getY())); } /** {@inheritDoc} */ + @Override public Vector2D toSpace(final Point point) { final double abscissa = ((Vector1D) point).getX(); return new Vector2D(MathArrays.linearCombination(abscissa, cos, -originOffset, sin), @@ -270,6 +273,7 @@ public class Line implements Hyperplane, Embedding project(Point point) { return toSpace(toSubSpace(point)); } @@ -277,11 +281,13 @@ public class Line implements Hyperplane, Embedding, Embedding, Embedding point) { Vector2D p2 = (Vector2D) point; return MathArrays.linearCombination(sin, p2.getX(), -cos, p2.getY(), 1.0, originOffset); } /** {@inheritDoc} */ + @Override public boolean sameOrientationAs(final Hyperplane other) { final Line otherL = (Line) other; return MathArrays.linearCombination(sin, otherL.sin, cos, otherL.cos) >= 0.0; @@ -439,16 +448,16 @@ public class Line implements Hyperplane, Embedding { // CHECKSTYLE: stop JavadocVariable check - private double cXX; - private double cXY; - private double cX1; - private double cYX; - private double cYY; - private double cY1; + private final double cXX; + private final double cXY; + private final double cX1; + private final double cYX; + private final double cYY; + private final double cY1; - private double c1Y; - private double c1X; - private double c11; + private final double c1Y; + private final double c1X; + private final double c11; // CHECKSTYLE: resume JavadocVariable check /** Build an affine line transform from a n {@code AffineTransform}. @@ -479,6 +488,7 @@ public class Line implements Hyperplane, Embedding point) { final Vector2D p2D = (Vector2D) point; final double x = p2D.getX(); @@ -488,6 +498,7 @@ public class Line implements Hyperplane, Embedding hyperplane) { final Line line = (Line) hyperplane; final double rOffset = MathArrays.linearCombination(c1X, line.cos, c1Y, line.sin, c11, line.originOffset); @@ -500,6 +511,7 @@ public class Line implements Hyperplane, Embedding apply(final SubHyperplane sub, final Hyperplane original, final Hyperplane transformed) { diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java index e542461f8..696878360 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java @@ -1002,11 +1002,13 @@ public class PolygonsSet extends AbstractRegion { } /** {@inheritDoc} */ + @Override public Order visitOrder(final BSPTree node) { return Order.MINUS_SUB_PLUS; } /** {@inheritDoc} */ + @Override public void visitInternalNode(final BSPTree node) { @SuppressWarnings("unchecked") final BoundaryAttribute attribute = (BoundaryAttribute) node.getAttribute(); @@ -1020,6 +1022,7 @@ public class PolygonsSet extends AbstractRegion { } /** {@inheritDoc} */ + @Override public void visitLeafNode(final BSPTree node) { } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java index ff2b43545..9293b4e1d 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java @@ -85,6 +85,7 @@ abstract class AbstractConvexHullGenerator2D implements ConvexHullGenerator2D { } /** {@inheritDoc} */ + @Override public ConvexHull2D generate(final Collection points) throws NullArgumentException, ConvergenceException { // check for null points diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java index dadfaa898..b973e13c3 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java @@ -106,6 +106,7 @@ public class ConvexHull2D implements ConvexHull, Serializ } /** {@inheritDoc} */ + @Override public Vector2D[] getVertices() { return vertices.clone(); } @@ -157,6 +158,7 @@ public class ConvexHull2D implements ConvexHull, Serializ } /** {@inheritDoc} */ + @Override public Region createRegion() throws InsufficientDataException { if (vertices.length < 3) { throw new InsufficientDataException(); diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java index a7febe3ce..35571470a 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java @@ -32,6 +32,7 @@ import org.apache.commons.math4.geometry.hull.ConvexHullGenerator; public interface ConvexHullGenerator2D extends ConvexHullGenerator { /** {@inheritDoc} */ + @Override ConvexHull2D generate(Collection points) throws NullArgumentException, ConvergenceException; } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java index bbd0532c0..9f9d2c44c 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java @@ -80,6 +80,7 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D { // sort the points in increasing order on the x-axis Collections.sort(pointsSortedByXAxis, new Comparator() { + @Override public int compare(final Vector2D o1, final Vector2D o2) { final double tolerance = getTolerance(); // need to take the tolerance value into account, otherwise collinear points diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java index 71e552f14..f75c0b3a9 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java @@ -110,6 +110,7 @@ public abstract class AbstractRegion implement // (we don't want equal size elements to be removed, so // we use a trick to fool the TreeSet) final TreeSet> ordered = new TreeSet>(new Comparator>() { + @Override public int compare(final SubHyperplane o1, final SubHyperplane o2) { final double size1 = o1.getSize(); final double size2 = o2.getSize(); @@ -126,15 +127,18 @@ public abstract class AbstractRegion implement tree.visit(new BSPTreeVisitor() { /** {@inheritDoc} */ + @Override public Order visitOrder(final BSPTree node) { return Order.PLUS_SUB_MINUS; } /** {@inheritDoc} */ + @Override public void visitInternalNode(final BSPTree node) { } /** {@inheritDoc} */ + @Override public void visitLeafNode(final BSPTree node) { if (node.getParent() == null || node == node.getParent().getMinus()) { node.setAttribute(Boolean.TRUE); @@ -179,6 +183,7 @@ public abstract class AbstractRegion implement } /** {@inheritDoc} */ + @Override public abstract AbstractRegion buildNew(BSPTree newTree); /** Get the tolerance below which points are considered to belong to hyperplanes. @@ -240,16 +245,19 @@ public abstract class AbstractRegion implement } /** {@inheritDoc} */ + @Override public AbstractRegion copySelf() { return buildNew(tree.copySelf()); } /** {@inheritDoc} */ + @Override public boolean isEmpty() { return isEmpty(tree); } /** {@inheritDoc} */ + @Override public boolean isEmpty(final BSPTree node) { // we use a recursive function rather than the BSPTreeVisitor @@ -267,11 +275,13 @@ public abstract class AbstractRegion implement } /** {@inheritDoc} */ + @Override public boolean isFull() { return isFull(tree); } /** {@inheritDoc} */ + @Override public boolean isFull(final BSPTree node) { // we use a recursive function rather than the BSPTreeVisitor @@ -289,6 +299,7 @@ public abstract class AbstractRegion implement } /** {@inheritDoc} */ + @Override public boolean contains(final Region region) { return new RegionFactory().difference(region, this).isEmpty(); } @@ -296,6 +307,7 @@ public abstract class AbstractRegion implement /** {@inheritDoc} * @since 3.3 */ + @Override public BoundaryProjection projectToBoundary(final Point point) { final BoundaryProjector projector = new BoundaryProjector(point); getTree(true).visit(projector); @@ -313,6 +325,7 @@ public abstract class AbstractRegion implement } /** {@inheritDoc} */ + @Override public Location checkPoint(final Point point) { return checkPoint(tree, point); } @@ -350,6 +363,7 @@ public abstract class AbstractRegion implement } /** {@inheritDoc} */ + @Override public BSPTree getTree(final boolean includeBoundaryAttributes) { if (includeBoundaryAttributes && (tree.getCut() != null) && (tree.getAttribute() == null)) { // compute the boundary attributes @@ -359,6 +373,7 @@ public abstract class AbstractRegion implement } /** {@inheritDoc} */ + @Override public double getBoundarySize() { final BoundarySizeVisitor visitor = new BoundarySizeVisitor(); getTree(true).visit(visitor); @@ -366,6 +381,7 @@ public abstract class AbstractRegion implement } /** {@inheritDoc} */ + @Override public double getSize() { if (barycenter == null) { computeGeometricalProperties(); @@ -381,6 +397,7 @@ public abstract class AbstractRegion implement } /** {@inheritDoc} */ + @Override public Point getBarycenter() { if (barycenter == null) { computeGeometricalProperties(); @@ -408,6 +425,7 @@ public abstract class AbstractRegion implement protected abstract void computeGeometricalProperties(); /** {@inheritDoc} */ + @Override public Side side(final Hyperplane hyperplane) { final InsideFinder finder = new InsideFinder(this); finder.recurseSides(tree, hyperplane.wholeHyperplane()); @@ -417,6 +435,7 @@ public abstract class AbstractRegion implement } /** {@inheritDoc} */ + @Override public SubHyperplane intersection(final SubHyperplane sub) { return recurseIntersection(tree, sub); } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java index 5c62ae7d7..f75998c59 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java @@ -63,6 +63,7 @@ public abstract class AbstractSubHyperplane final Region remaining); /** {@inheritDoc} */ + @Override public AbstractSubHyperplane copySelf() { return buildNew(hyperplane.copySelf(), remainingRegion); } @@ -70,6 +71,7 @@ public abstract class AbstractSubHyperplane /** Get the underlying hyperplane. * @return underlying hyperplane */ + @Override public Hyperplane getHyperplane() { return hyperplane; } @@ -86,11 +88,13 @@ public abstract class AbstractSubHyperplane } /** {@inheritDoc} */ + @Override public double getSize() { return remainingRegion.getSize(); } /** {@inheritDoc} */ + @Override public AbstractSubHyperplane reunite(final SubHyperplane other) { @SuppressWarnings("unchecked") AbstractSubHyperplane o = (AbstractSubHyperplane) other; @@ -175,12 +179,15 @@ public abstract class AbstractSubHyperplane } /** {@inheritDoc} */ + @Override public abstract Side side(Hyperplane hyper); /** {@inheritDoc} */ + @Override public abstract SplitSubHyperplane split(Hyperplane hyper); /** {@inheritDoc} */ + @Override public boolean isEmpty() { return remainingRegion.isEmpty(); } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java index 8e82e4f9e..2b35eb9a2 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java @@ -29,11 +29,13 @@ import org.apache.commons.math4.geometry.Space; class BoundaryBuilder implements BSPTreeVisitor { /** {@inheritDoc} */ + @Override public Order visitOrder(BSPTree node) { return Order.PLUS_MINUS_SUB; } /** {@inheritDoc} */ + @Override public void visitInternalNode(BSPTree node) { SubHyperplane plusOutside = null; @@ -89,6 +91,7 @@ class BoundaryBuilder implements BSPTreeVisitor { } /** {@inheritDoc} */ + @Override public void visitLeafNode(BSPTree node) { } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java index cfc45617f..655aaa299 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java @@ -54,6 +54,7 @@ class BoundaryProjector implements BSPTreeVisi } /** {@inheritDoc} */ + @Override public Order visitOrder(final BSPTree node) { // we want to visit the tree so that the first encountered // leaf is the one closest to the test point @@ -65,6 +66,7 @@ class BoundaryProjector implements BSPTreeVisi } /** {@inheritDoc} */ + @Override public void visitInternalNode(final BSPTree node) { // project the point on the cut sub-hyperplane @@ -111,6 +113,7 @@ class BoundaryProjector implements BSPTreeVisi } /** {@inheritDoc} */ + @Override public void visitLeafNode(final BSPTree node) { if (leaf == null) { // this is the first leaf we visit, diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundarySizeVisitor.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundarySizeVisitor.java index b97f6535e..dae1806f2 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundarySizeVisitor.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundarySizeVisitor.java @@ -34,11 +34,13 @@ class BoundarySizeVisitor implements BSPTreeVisitor { } /** {@inheritDoc}*/ + @Override public Order visitOrder(final BSPTree node) { return Order.MINUS_SUB_PLUS; } /** {@inheritDoc}*/ + @Override public void visitInternalNode(final BSPTree node) { @SuppressWarnings("unchecked") final BoundaryAttribute attribute = @@ -52,6 +54,7 @@ class BoundarySizeVisitor implements BSPTreeVisitor { } /** {@inheritDoc}*/ + @Override public void visitLeafNode(final BSPTree node) { } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java index d3099c27f..e7588e0aa 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java @@ -30,7 +30,7 @@ import org.apache.commons.math4.geometry.Space; public class NodesSet implements Iterable> { /** List of sub-hyperplanes. */ - private List> list; + private final List> list; /** Simple constructor. */ @@ -65,6 +65,7 @@ public class NodesSet implements Iterable> { } /** {@inheritDoc} */ + @Override public Iterator> iterator() { return list.iterator(); } diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java index d8679ec01..cf9619253 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java @@ -206,6 +206,7 @@ public class RegionFactory { /** BSP tree leaf merger computing union of two regions. */ private class UnionMerger implements BSPTree.LeafMerger { /** {@inheritDoc} */ + @Override public BSPTree merge(final BSPTree leaf, final BSPTree tree, final BSPTree parentTree, final boolean isPlusChild, final boolean leafFromInstance) { @@ -223,6 +224,7 @@ public class RegionFactory { /** BSP tree leaf merger computing intersection of two regions. */ private class IntersectionMerger implements BSPTree.LeafMerger { /** {@inheritDoc} */ + @Override public BSPTree merge(final BSPTree leaf, final BSPTree tree, final BSPTree parentTree, final boolean isPlusChild, final boolean leafFromInstance) { @@ -240,6 +242,7 @@ public class RegionFactory { /** BSP tree leaf merger computing symmetric difference (exclusive or) of two regions. */ private class XorMerger implements BSPTree.LeafMerger { /** {@inheritDoc} */ + @Override public BSPTree merge(final BSPTree leaf, final BSPTree tree, final BSPTree parentTree, final boolean isPlusChild, final boolean leafFromInstance) { @@ -272,6 +275,7 @@ public class RegionFactory { } /** {@inheritDoc} */ + @Override public BSPTree merge(final BSPTree leaf, final BSPTree tree, final BSPTree parentTree, final boolean isPlusChild, final boolean leafFromInstance) { @@ -290,6 +294,7 @@ public class RegionFactory { } /** {@inheritDoc} */ + @Override public BSPTree fixNode(final BSPTree node) { // get a representative point in the degenerate cell final BSPTree cell = node.pruneAroundConvexCell(Boolean.TRUE, Boolean.FALSE, null); @@ -305,16 +310,19 @@ public class RegionFactory { private class NodesCleaner implements BSPTreeVisitor { /** {@inheritDoc} */ + @Override public Order visitOrder(final BSPTree node) { return Order.PLUS_SUB_MINUS; } /** {@inheritDoc} */ + @Override public void visitInternalNode(final BSPTree node) { node.setAttribute(null); } /** {@inheritDoc} */ + @Override public void visitLeafNode(final BSPTree node) { } @@ -334,6 +342,7 @@ public class RegionFactory { } /** {@inheritDoc} */ + @Override public BSPTree fixNode(final BSPTree node) { if (node.getPlus().getAttribute().equals(node.getMinus().getAttribute())) { // no ambiguity diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java index 7479a22fe..bd195c0e4 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java @@ -580,6 +580,7 @@ public class ArcsSet extends AbstractRegion implements Itera * The iterator does not support the optional {@code remove} operation. *

*/ + @Override public Iterator iterator() { return new SubArcsIterator(); } @@ -676,11 +677,13 @@ public class ArcsSet extends AbstractRegion implements Itera } /** {@inheritDoc} */ + @Override public boolean hasNext() { return pending != null; } /** {@inheritDoc} */ + @Override public double[] next() { if (pending == null) { throw new NoSuchElementException(); @@ -691,6 +694,7 @@ public class ArcsSet extends AbstractRegion implements Itera } /** {@inheritDoc} */ + @Override public void remove() { throw new UnsupportedOperationException(); } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/LimitAngle.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/LimitAngle.java index bfd7894a3..086931ceb 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/LimitAngle.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/LimitAngle.java @@ -27,10 +27,10 @@ import org.apache.commons.math4.geometry.partitioning.Hyperplane; public class LimitAngle implements Hyperplane { /** Angle location. */ - private S1Point location; + private final S1Point location; /** Orientation. */ - private boolean direct; + private final boolean direct; /** Tolerance below which angles are considered identical. */ private final double tolerance; @@ -52,11 +52,13 @@ public class LimitAngle implements Hyperplane { * the instance.

* @return the instance itself */ + @Override public LimitAngle copySelf() { return this; } /** {@inheritDoc} */ + @Override public double getOffset(final Point point) { final double delta = ((S1Point) point).getAlpha() - location.getAlpha(); return direct ? delta : -delta; @@ -90,6 +92,7 @@ public class LimitAngle implements Hyperplane { * not be used otherwise.

* @return a dummy sub hyperplane */ + @Override public SubLimitAngle wholeHyperplane() { return new SubLimitAngle(this, null); } @@ -98,11 +101,13 @@ public class LimitAngle implements Hyperplane { * @return a region containing the instance (really an {@link * ArcsSet IntervalsSet} instance) */ + @Override public ArcsSet wholeSpace() { return new ArcsSet(tolerance); } /** {@inheritDoc} */ + @Override public boolean sameOrientationAs(final Hyperplane other) { return !(direct ^ ((LimitAngle) other).direct); } @@ -115,11 +120,13 @@ public class LimitAngle implements Hyperplane { } /** {@inheritDoc} */ + @Override public Point project(Point point) { return location; } /** {@inheritDoc} */ + @Override public double getTolerance() { return tolerance; } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java index 66d21cc56..2395fd29b 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java @@ -77,16 +77,19 @@ public class S1Point implements Point { } /** {@inheritDoc} */ + @Override public Space getSpace() { return Sphere1D.getInstance(); } /** {@inheritDoc} */ + @Override public boolean isNaN() { return Double.isNaN(alpha); } /** {@inheritDoc} */ + @Override public double distance(final Point point) { return distance(this, (S1Point) point); } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/Sphere1D.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/Sphere1D.java index cdd397fc4..18f1a5d68 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/Sphere1D.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/Sphere1D.java @@ -51,6 +51,7 @@ public class Sphere1D implements Serializable, Space { } /** {@inheritDoc} */ + @Override public int getDimension() { return 1; } @@ -63,6 +64,7 @@ public class Sphere1D implements Serializable, Space { * @return nothing * @throws NoSubSpaceException in all cases */ + @Override public Space getSubSpace() throws NoSubSpaceException { throw new NoSubSpaceException(); } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java index f4a554d35..0989bad69 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java @@ -102,6 +102,7 @@ public class Circle implements Hyperplane, Embedding, Embedding project(Point point) { return toSpace(toSubSpace(point)); } /** {@inheritDoc} */ + @Override public double getTolerance() { return tolerance; } @@ -146,6 +149,7 @@ public class Circle implements Hyperplane, Embedding point) { return new S1Point(getPhase(((S2Point) point).getVector())); } @@ -167,6 +171,7 @@ public class Circle implements Hyperplane, Embedding point) { return new S2Point(getPointAt(((S1Point) point).getAlpha())); } @@ -236,6 +241,7 @@ public class Circle implements Hyperplane, Embedding, Embedding, Embedding point) { return getOffset(((S2Point) point).getVector()); } @@ -269,6 +277,7 @@ public class Circle implements Hyperplane, Embedding other) { final Circle otherC = (Circle) other; return Vector3D.dotProduct(pole, otherC.pole) >= 0.0; @@ -300,11 +309,13 @@ public class Circle implements Hyperplane, Embedding point) { return new S2Point(rotation.applyTo(((S2Point) point).getVector())); } /** {@inheritDoc} */ + @Override public Circle apply(final Hyperplane hyperplane) { final Circle circle = (Circle) hyperplane; return new Circle(rotation.applyTo(circle.pole), @@ -314,6 +325,7 @@ public class Circle implements Hyperplane, Embedding apply(final SubHyperplane sub, final Hyperplane original, final Hyperplane transformed) { diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java index 64e7d3704..aac7aef7b 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java @@ -60,11 +60,13 @@ class EdgesBuilder implements BSPTreeVisitor { } /** {@inheritDoc} */ + @Override public Order visitOrder(final BSPTree node) { return Order.MINUS_SUB_PLUS; } /** {@inheritDoc} */ + @Override public void visitInternalNode(final BSPTree node) { nodeToEdgesList.put(node, new ArrayList()); @SuppressWarnings("unchecked") @@ -78,6 +80,7 @@ class EdgesBuilder implements BSPTreeVisitor { } /** {@inheritDoc} */ + @Override public void visitLeafNode(final BSPTree node) { } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java index 7987f3134..7721320f4 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java @@ -54,16 +54,19 @@ class PropertiesComputer implements BSPTreeVisitor { } /** {@inheritDoc} */ + @Override public Order visitOrder(final BSPTree node) { return Order.MINUS_SUB_PLUS; } /** {@inheritDoc} */ + @Override public void visitInternalNode(final BSPTree node) { // nothing to do here } /** {@inheritDoc} */ + @Override public void visitLeafNode(final BSPTree node) { if ((Boolean) node.getAttribute()) { diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java index fb02807db..94fc0c55c 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java @@ -152,11 +152,13 @@ public class S2Point implements Point { } /** {@inheritDoc} */ + @Override public Space getSpace() { return Sphere2D.getInstance(); } /** {@inheritDoc} */ + @Override public boolean isNaN() { return Double.isNaN(theta) || Double.isNaN(phi); } @@ -169,6 +171,7 @@ public class S2Point implements Point { } /** {@inheritDoc} */ + @Override public double distance(final Point point) { return distance(this, (S2Point) point); } diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Sphere2D.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Sphere2D.java index 0f87462e6..8ada69f29 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Sphere2D.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Sphere2D.java @@ -50,11 +50,13 @@ public class Sphere2D implements Serializable, Space { } /** {@inheritDoc} */ + @Override public int getDimension() { return 2; } /** {@inheritDoc} */ + @Override public Sphere1D getSubSpace() { return Sphere1D.getInstance(); }