Module technology.sola.engine
Record Class Position
java.lang.Object
java.lang.Record
technology.sola.engine.graphics.gui.style.property.Position
- Record Components:
x
- the x position of the elementy
- the y position of the element
- All Implemented Interfaces:
MergeableProperty<Position>
@NullMarked
public record Position(@Nullable StyleValue x, @Nullable StyleValue y)
extends Record
implements MergeableProperty<Position>
Position contains the properties for absolutely positioning a
GuiElement
within its container. If x and y are both null then the element is not considered absolutely positioned.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPosition()
Creates a new Position instance with x and y not set.Creates a new Position instance with x and y set.Position
(@Nullable StyleValue x, @Nullable StyleValue y) Creates an instance of aPosition
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.boolean
Checks if this Position is absolute or not.Returns a new instance of the property with the resulting values being a merge of the right on top of the left.final String
toString()
Returns a string representation of this record class.@Nullable StyleValue
x()
Returns the value of thex
record component.@Nullable StyleValue
y()
Returns the value of they
record component.
-
Field Details
-
NONE
Position with x and y not set. Element will be relatively positioned in the flow.
-
-
Constructor Details
-
Position
public Position()Creates a new Position instance with x and y not set. Element will be relatively positioned in the flow. -
Position
Creates a new Position instance with x and y set.- Parameters:
x
- the x position of the elementy
- the y position of the element
-
Position
Creates an instance of aPosition
record class.
-
-
Method Details
-
isAbsolute
public boolean isAbsolute()Checks if this Position is absolute or not. Position is considered absolute if x or y is not null.- Returns:
- true if absolute
-
mergeWith
Description copied from interface:MergeableProperty
Returns a new instance of the property with the resulting values being a merge of the right on top of the left.- Specified by:
mergeWith
in interfaceMergeableProperty<Position>
- Parameters:
otherProperty
- the other property object to merge values on top of this one- Returns:
- a new instance with the merged properties
-
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 withObjects::equals(Object,Object)
. -
x
Returns the value of thex
record component.- Returns:
- the value of the
x
record component
-
y
Returns the value of they
record component.- Returns:
- the value of the
y
record component
-