Module technology.sola.engine
Record Class GuiElementBounds
java.lang.Object
java.lang.Record
technology.sola.engine.graphics.gui.GuiElementBounds
- Record Components:
x
- the left most coordinatey
- the top most coordinatewidth
- the widthheight
- the height
GuiElementBounds holds the information for the bounding box for part of
GuiElement
.-
Constructor Summary
ConstructorsConstructorDescriptionGuiElementBounds
(int x, int y, int width, int height) Creates an instance of aGuiElementBounds
record class. -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(int x, int y) Checks to see if a point is within bounds.boolean
contains
(MouseEvent mouseEvent) Checks to see if aMouseEvent
is within bounds.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.int
height()
Returns the value of theheight
record component.setDimensions
(int width, int height) Creates a newGuiElementBounds
instance with width and height set to the desired values.setPosition
(int x, int y) Creates a newGuiElementBounds
instance with position set to the desired x and y.final String
toString()
Returns a string representation of this record class.int
width()
Returns the value of thewidth
record component.int
x()
Returns the value of thex
record component.int
y()
Returns the value of they
record component.
-
Constructor Details
-
GuiElementBounds
public GuiElementBounds(int x, int y, int width, int height) Creates an instance of aGuiElementBounds
record class.
-
-
Method Details
-
setPosition
Creates a newGuiElementBounds
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 instancey
- the y of the new instance- Returns:
- the new instance
-
setDimensions
Creates a newGuiElementBounds
instance with width and height set to the desired values. The position values are kept the same.- Parameters:
width
- the width of the new instanceheight
- 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 checky
- the y of the point to check- Returns:
- true if the point is within the bounds
-
contains
Checks to see if aMouseEvent
is within bounds.- Parameters:
mouseEvent
- the mouse event- Returns:
- true if the mouse event is within the bounds
-
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. -
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. -
equals
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 '=='. -
x
public int x()Returns the value of thex
record component.- Returns:
- the value of the
x
record component
-
y
public int y()Returns the value of they
record component.- Returns:
- the value of the
y
record component
-
width
public int width()Returns the value of thewidth
record component.- Returns:
- the value of the
width
record component
-
height
public int height()Returns the value of theheight
record component.- Returns:
- the value of the
height
record component
-