Interface Bounds<B extends Bounds<B,​P,​D>,​P extends Point<P>,​D extends Drawable<P>>

  • Type Parameters:
    B - The bounds type (2d or 3d)
    P - The point type (2d or 3d)
    D - The Drawable type (2d or 3d)
    All Known Implementing Classes:
    Bounds2d, Bounds3d

    public interface Bounds<B extends Bounds<B,​P,​D>,​P extends Point<P>,​D extends Drawable<P>>
    Bounds is the generic tagging interface that indicates the bounds for an object, where the simplest implementation is minX, minY, maxX and maxY for 2D, and minX, minY, minZ and maxX, maxY and maxZ for 3D. Other bounds such as a BoundingCircle, BoundingSphere or BoundingPolytope could also be defined.

    Copyright (c) 2020-2021 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See DJUTILS License.

    Author:
    Alexander Verbraeck, Peter Knoppers
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      boolean contains​(D drawable)
      Check if this Bounds completely contains a Drawable.
      boolean contains​(P point)
      Check if a point is contained in this Bounds.
      boolean covers​(D drawable)
      Check if no part of a Drawable is outside this Bounds.
      boolean covers​(P point)
      Check if this Bounds covers or touches a point.
      boolean disjoint​(D drawable)
      Return whether a Drawable is disjoint from this Bounds.
      default double getDeltaX()
      Return the extent of this Bounds2d in the x-direction.
      default double getDeltaY()
      Return the extent of this Bounds2d in the y-direction.
      double getMaxX()
      Return the absolute upper bound for x.
      double getMaxY()
      Return the absolute upper bound for y.
      double getMinX()
      Return the absolute lower bound for x.
      double getMinY()
      Return the absolute lower bound for y.
      B intersection​(B otherBounds)
      Return the intersecting Bounds of this Bounds and another Bounds.
      boolean intersects​(B otherBounds)
      Return whether this Bounds intersects another Bounds.
      P midPoint()
      Return the mid point of this Bounds object.
    • Method Detail

      • getMinX

        double getMinX()
        Return the absolute lower bound for x.
        Returns:
        double; the absolute lower bound for x
      • getMaxX

        double getMaxX()
        Return the absolute upper bound for x.
        Returns:
        double; the absolute upper bound for x
      • getMinY

        double getMinY()
        Return the absolute lower bound for y.
        Returns:
        double; the absolute lower bound for y
      • getMaxY

        double getMaxY()
        Return the absolute upper bound for y.
        Returns:
        double; the absolute upper bound for y
      • getDeltaX

        default double getDeltaX()
        Return the extent of this Bounds2d in the x-direction.
        Returns:
        double; the extent of this Bounds2d in the x-direction
      • getDeltaY

        default double getDeltaY()
        Return the extent of this Bounds2d in the y-direction.
        Returns:
        double; the extent of this Bounds2d in the y-direction
      • midPoint

        P midPoint()
        Return the mid point of this Bounds object.
        Returns:
        P; the mid point of this Bounds object
      • contains

        boolean contains​(P point)
                  throws NullPointerException
        Check if a point is contained in this Bounds.
        Parameters:
        point - P; the point
        Returns:
        boolean; true if the point is within this Bounds; false if the point is not within this Bounds, or on an edge of this Bounds
        Throws:
        NullPointerException - when point is null
      • contains

        boolean contains​(D drawable)
                  throws NullPointerException
        Check if this Bounds completely contains a Drawable. If any point of the Drawable lies on an edge (2d) or surface (3d) of this Bounds, this method returns false.
        Parameters:
        drawable - D; the object for which to check if it is completely contained within this Bounds.
        Returns:
        boolean; false if any point of D is on or outside one of the borders of this Bounds; true when all points of D are contained within this Bounds.
        Throws:
        NullPointerException - when drawable2d is null
      • covers

        boolean covers​(P point)
                throws NullPointerException
        Check if this Bounds covers or touches a point.
        Parameters:
        point - P; the Point for which to check if it is covered/touched by this Bounds
        Returns:
        boolean; whether this Bounds covers or touches the point
        Throws:
        NullPointerException - when point is null
      • covers

        boolean covers​(D drawable)
                throws NullPointerException
        Check if no part of a Drawable is outside this Bounds. The edges/surfaces of this Bounds are considered inside.
        Parameters:
        drawable - D; the Drawable for which to check if it is contained within this Bounds
        Returns:
        boolean; whether this Bounds contains the provided Bounds, including overlapping borders
        Throws:
        NullPointerException - when otherBounds is null
      • disjoint

        boolean disjoint​(D drawable)
                  throws NullPointerException
        Return whether a Drawable is disjoint from this Bounds. Only touching at an edge is considered disjoint. A Drawable that completely surrounds this Drawable is not disjoint.
        Parameters:
        drawable - D; the drawable
        Returns:
        boolean; true if the drawable is disjoint from this Bounds, or only touches an edge; false if any point of the drawable is inside this Bounds, or the drawable surrounds this Bounds
        Throws:
        NullPointerException - when bounds is null
      • intersects

        boolean intersects​(B otherBounds)
        Return whether this Bounds intersects another Bounds. Only touching at an edge is not seen as intersecting.
        Parameters:
        otherBounds - B; the other Bounds
        Returns:
        boolean; whether this bounding box/rectangle intersects the other Bounds
        Throws:
        NullPointerException - when otherBounds is null
      • intersection

        B intersection​(B otherBounds)
        Return the intersecting Bounds of this Bounds and another Bounds. Touching at the edge is not seen as intersecting. In case there is no intersection, null is returned.
        Parameters:
        otherBounds - B; the other Bounds
        Returns:
        Bounds; the intersecting Bounds of this Bounds and another Bounds. Touching at the edge is not seen as intersecting. If not intersecting; null is returned
        Throws:
        NullPointerException - when otherBounds is null