Class EncompassingArea

java.lang.Object
org.empirewar.orbis.area.EncompassingArea
All Implemented Interfaces:
Iterable<org.joml.Vector3ic>, Area
Direct Known Subclasses:
CuboidArea, PolygonArea, SphericalArea

public abstract sealed class EncompassingArea extends Object implements Area permits CuboidArea, PolygonArea, SphericalArea
  • Field Details

    • points

      protected final Set<org.joml.Vector3ic> points
    • boundaryPoints

      protected final Set<org.joml.Vector3ic> boundaryPoints
    • min

      protected final org.joml.Vector3i min
    • max

      protected final org.joml.Vector3i max
  • Method Details

    • addUpdateListener

      public void addUpdateListener(Runnable listener)
    • removeUpdateListener

      public void removeUpdateListener(Runnable listener)
    • calculateEncompassingArea

      protected void calculateEncompassingArea()
      Calculates the minimum and maximum points of this area.
    • clearPoints

      public void clearPoints()
      Description copied from interface: Area
      Removes all points from this area.
      Specified by:
      clearPoints in interface Area
    • addPoint

      public boolean addPoint(org.joml.Vector3ic point)
      Description copied from interface: Area
      Attempts to add a point to this area.

      This method will return false if the area does not support the addition of another point, e.g. a cuboid exceeding 4 points.

      Specified by:
      addPoint in interface Area
      Parameters:
      point - the point to add
      Returns:
      true if the point is able to fit into this area
    • removePoint

      public boolean removePoint(org.joml.Vector3ic point)
      Description copied from interface: Area
      Attempts to remove a point from this area.

      This method will return as specified by Set.remove(Object).

      Specified by:
      removePoint in interface Area
      Parameters:
      point - the point to remove
      Returns:
      specified by Set.remove(Object)
    • getMin

      public org.joml.Vector3ic getMin()
      Description copied from interface: Area
      Gets the minimum point of this area.

      This method does not guarantee returning a Vector3i from Area.points(); it is the minimum bounds point.

      Specified by:
      getMin in interface Area
      Returns:
      the minimum point
    • getMax

      public org.joml.Vector3ic getMax()
      Description copied from interface: Area
      Gets the maximum point of this area.

      This method does not guarantee returning a Vector3i from Area.points(); it is the maximum bounds point.

      Specified by:
      getMax in interface Area
      Returns:
      the maximum point
    • points

      public Set<org.joml.Vector3ic> points()
      Description copied from interface: Area
      Gets the set of points that make up this area.

      The returned set cannot be modified.

      Specified by:
      points in interface Area
      Returns:
      set of points of this area
    • getBoundaryPoints

      public Set<org.joml.Vector3ic> getBoundaryPoints()
      Description copied from interface: Area
      Returns a set of points representing the boundary of this area.
      Specified by:
      getBoundaryPoints in interface Area
    • generateBoundaryPoints

      protected abstract Set<org.joml.Vector3ic> generateBoundaryPoints()
    • getMaximumPoints

      public abstract Optional<Integer> getMaximumPoints()
      Gets the maximum number of points for this area.

      For some shapes such as polygons this is not applicable. In these cases, this method should instead return Optional.empty().

      Returns:
      an Optional with the number of maximum points, else Optional.empty() if any number of points is applicable.
    • getMinimumPoints

      public abstract int getMinimumPoints()
      Gets the minimum number of points for this area.
      Returns:
      the minimum number of points required to build this area
    • iterator

      @NotNull public @NotNull Iterator<org.joml.Vector3ic> iterator()
      Specified by:
      iterator in interface Iterable<org.joml.Vector3ic>