java.lang.Object
technology.sola.engine.graphics.gui.style.property.StyleValue

@NullMarked public class StyleValue extends Object
StyleValue holds a numeric value that can be represented as an absolute value or a relative percentage value.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final StyleValue
    StyleValue constant for the value of 100%.
    static final StyleValue
    StyleValue constant for the value of 0.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StyleValue(int pixelValue)
    Creates a StyleValue that is an absolute pixel value.
    Creates a StyleValue from a string that can be a pixel value or percentage.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    int
    getValue(int parentValue)
    Gets the resolved value based on a parent's dimension.
    int
     
    boolean
     
    static @Nullable StyleValue
    of(@Nullable String value)
    Creates a StyleValue from the parsed String.

    Methods inherited from class java.lang.Object

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

    • ZERO

      public static final StyleValue ZERO
      StyleValue constant for the value of 0.
    • FULL

      public static final StyleValue FULL
      StyleValue constant for the value of 100%.
  • Constructor Details

    • StyleValue

      public StyleValue(int pixelValue)
      Creates a StyleValue that is an absolute pixel value.
      Parameters:
      pixelValue - the pixel value
    • StyleValue

      public StyleValue(String value)
      Creates a StyleValue from a string that can be a pixel value or percentage.
      • ends with '%' - percentage
      • ends with 'px' - pixel
      • default - pixel
      Parameters:
      value - the value to parse into a StyleValue
  • Method Details

    • of

      public static @Nullable StyleValue of(@Nullable String value)
      Creates a StyleValue from the parsed String. Returns null if value is null.
      Parameters:
      value - the String to parse
      Returns:
      the StyleValue or null
    • getValue

      public int getValue(int parentValue)
      Gets the resolved value based on a parent's dimension.
      Parameters:
      parentValue - the parent's value to be relative to if percentage
      Returns:
      the resolved value
    • isPercentage

      public boolean isPercentage()
      Returns:
      true if this StyleValue is a relative percentage value
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object