Record Class GuiElementBounds

java.lang.Object
java.lang.Record
technology.sola.engine.graphics.gui.GuiElementBounds
Record Components:
x - the left most coordinate
y - the top most coordinate
width - the width
height - the height

@NullMarked public record GuiElementBounds(int x, int y, int width, int height) extends Record
GuiElementBounds holds the information for the bounding box for part of GuiElement.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GuiElementBounds(int x, int y, int width, int height)
    Creates an instance of a GuiElementBounds record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(int x, int y)
    Checks to see if a point is within bounds.
    boolean
    contains(MouseEvent mouseEvent)
    Checks to see if a MouseEvent is within bounds.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the height record component.
    setDimensions(int width, int height)
    Creates a new GuiElementBounds instance with width and height set to the desired values.
    setPosition(int x, int y)
    Creates a new GuiElementBounds instance with position set to the desired x and y.
    final String
    Returns a string representation of this record class.
    int
    Returns the value of the width record component.
    int
    x()
    Returns the value of the x record component.
    int
    y()
    Returns the value of the y record component.

    Methods inherited from class java.lang.Object

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

    • GuiElementBounds

      public GuiElementBounds(int x, int y, int width, int height)
      Creates an instance of a GuiElementBounds record class.
      Parameters:
      x - the value for the x record component
      y - the value for the y record component
      width - the value for the width record component
      height - the value for the height record component
  • Method Details

    • setPosition

      public GuiElementBounds setPosition(int x, int y)
      Creates a new GuiElementBounds instance with position set to the desired x and y. The width and height are kept the same.
      Parameters:
      x - the x of the new instance
      y - the y of the new instance
      Returns:
      the new instance
    • setDimensions

      public GuiElementBounds setDimensions(int width, int height)
      Creates a new GuiElementBounds instance with width and height set to the desired values. The position values are kept the same.
      Parameters:
      width - the width of the new instance
      height - the height of the new instance
      Returns:
      the new instance
    • contains

      public boolean contains(int x, int y)
      Checks to see if a point is within bounds.
      Parameters:
      x - the x of the point to check
      y - the y of the point to check
      Returns:
      true if the point is within the bounds
    • contains

      public boolean contains(MouseEvent mouseEvent)
      Checks to see if a MouseEvent is within bounds.
      Parameters:
      mouseEvent - the mouse event
      Returns:
      true if the mouse event is within the bounds
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • x

      public int x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public int y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component
    • width

      public int width()
      Returns the value of the width record component.
      Returns:
      the value of the width record component
    • height

      public int height()
      Returns the value of the height record component.
      Returns:
      the value of the height record component