Class ScreenBounds

java.lang.Object
com.massifmaps.core.ScreenBounds

public class ScreenBounds extends Object
A container class that defines a bounding box on the screen using minimum and maximum screen positions.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty ScreenBounds object.
    Constructs a ScreenBounds object from a minimum and maximum position.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Tests whether this screen bounds object contains a another screen bounds object.
    boolean
    Tests whether this screen bounds object contains a screen position.
    boolean
    Checks if this object is equal to the specified object.
    Calculates the center screen position of this screen envelope object.
    float
    Returns the height of the bounds object.
    Returns the maximum screen position of this screen envelope object.
    Returns the minimum screen position.
    float
    Returns the width of the bounds object.
    int
    Returns the hash value of this object.
    boolean
    Tests whether this screen bounds object intersects with a another screen bounds object.
    Creates a string representation of this screen bounds object, useful for logging.

    Methods inherited from class java.lang.Object

    clone, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ScreenBounds

      public ScreenBounds()
      Constructs an empty ScreenBounds object. The coordinates of the minimum position will be
      set to positive infinity and the coordinates of the maximum position will be
      set to negative infinity.
    • ScreenBounds

      public ScreenBounds(ScreenPos min, ScreenPos max)
      Constructs a ScreenBounds object from a minimum and maximum position. If a coordinate of the
      minimum positon is larger than the same coordinate of the maximum position then those
      coordinates will be swapped.
      Parameters:
      min - The minimum position.
      max - The maximum position.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Checks if this object is equal to the specified object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The reference object.
      Returns:
      True when objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash value of this object.
      Overrides:
      hashCode in class Object
      Returns:
      The hash value of this object.
    • getCenter

      public ScreenPos getCenter()
      Calculates the center screen position of this screen envelope object.
      Returns:
      The center postion if this screen envelope object.
    • getWidth

      public float getWidth()
      Returns the width of the bounds object.
      Returns:
      The width on the bounds object.
    • getHeight

      public float getHeight()
      Returns the height of the bounds object.
      Returns:
      The height on the bounds object.
    • getMin

      public ScreenPos getMin()
      Returns the minimum screen position.
      Returns:
      The minimum screen position.
    • getMax

      public ScreenPos getMax()
      Returns the maximum screen position of this screen envelope object.
      Returns:
      The maximum screen position of this screen envelope object.
    • contains

      public boolean contains(ScreenPos pos)
      Tests whether this screen bounds object contains a screen position.
      Parameters:
      pos - The screen position.
      Returns:
      True if this screen bounds object contains the screen position.
    • contains

      public boolean contains(ScreenBounds bounds)
      Tests whether this screen bounds object contains a another screen bounds object.
      Parameters:
      bounds - The other screen bounds object.
      Returns:
      True if this screen bounds object contains the other screen bounds object.
    • intersects

      public boolean intersects(ScreenBounds bounds)
      Tests whether this screen bounds object intersects with a another screen bounds object.
      Parameters:
      bounds - The other screen bounds object.
      Returns:
      True if this screen bounds object intersects with the other screen bounds object.
    • toString

      public String toString()
      Creates a string representation of this screen bounds object, useful for logging.
      Overrides:
      toString in class Object
      Returns:
      The string representation of this screen bounds object.