Class CoordinatePositions


  • public class CoordinatePositions
    extends Object
    Computes coordinate positions relative to a rectangle.
    • Constructor Detail

      • CoordinatePositions

        public CoordinatePositions()
    • Method Detail

      • onRectangleAndEdges

        public static EnumSet<CoordinatePosition> onRectangleAndEdges​(Rectangle2D rectangle,
                                                                      Point2D point,
                                                                      double edgeTolerance)
        Returns all positions the specified point has regarding the specified rectangle and its edges (using the specified tolerance).
        Parameters:
        rectangle - the rectangle relative to which the point will be checked
        point - the checked point
        edgeTolerance - the tolerance in pixels used to determine whether the coordinates are on some edge
        Returns:
        a set of those positions the coordinates have regarding the specified rectangle
      • inRectangle

        public static CoordinatePosition inRectangle​(Rectangle2D rectangle,
                                                     Point2D point)
        Returns the position the specified coordinates have regarding the specified rectangle. Edges are not checked.
        Parameters:
        rectangle - the rectangle relative to which the point will be checked
        point - the checked point
        Returns:
        depending on the point either IN_RECTANGLE or OUT_OF_RECTANGLE
      • onEdges

        public static CoordinatePosition onEdges​(Rectangle2D rectangle,
                                                 Point2D point,
                                                 double edgeTolerance)
        Returns the position the specified coordinates have regarding the specified rectangle's edges using the specified tolerance.
        Parameters:
        rectangle - the rectangle relative to which the point will be checked
        point - the checked point
        edgeTolerance - the tolerance in pixels used to determine whether the coordinates are on some edge
        Returns:
        the edge position the coordinates have regarding the specified rectangle; the value will be null if the point is not near any edge