java.lang.Object
java.lang.Record
technology.sola.engine.graphics.gui.style.property.Position
Record Components:
x - the x position of the element
y - 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
    Modifier and Type
    Field
    Description
    static final Position
    Position with x and y not set.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new Position instance with x and y not set.
    Position(@Nullable String x, @Nullable String y)
    Creates a new Position instance with x and y set.
    Position(@Nullable StyleValue x, @Nullable StyleValue y)
    Creates an instance of a Position record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Checks if this Position is absolute or not.
    mergeWith(@Nullable Position otherProperty)
    Returns a new instance of the property with the resulting values being a merge of the right on top of the left.
    final String
    Returns a string representation of this record class.
    @Nullable StyleValue
    x()
    Returns the value of the x record component.
    @Nullable StyleValue
    y()
    Returns the value of the y record component.

    Methods inherited from class java.lang.Object

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

    • NONE

      public static final Position 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

      public Position(@Nullable String x, @Nullable String y)
      Creates a new Position instance with x and y set.
      Parameters:
      x - the x position of the element
      y - the y position of the element
    • Position

      public Position(@Nullable StyleValue x, @Nullable StyleValue y)
      Creates an instance of a Position record class.
      Parameters:
      x - the value for the x record component
      y - the value for the y record component
  • 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

      public Position mergeWith(@Nullable Position otherProperty)
      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 interface MergeableProperty<Position>
      Parameters:
      otherProperty - the other property object to merge values on top of this one
      Returns:
      a new instance with the merged properties
    • 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 Objects::equals(Object,Object).
      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 @Nullable StyleValue x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public @Nullable StyleValue y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component