Class StyleUtilities

java.lang.Object
com.spinyowl.legui.style.util.StyleUtilities

public final class StyleUtilities extends Object
  • Method Details

    • getPadding

      public static org.joml.Vector4f getPadding(Component component, Style style)
      Used to get component padding represented with Vector4f.
      Parameters:
      component - component for which padding is calculated.
      style - style with paddings.
      Returns:
      padding represented with Vector4f where x - left, y - top, z - right, w - bottom.
    • getFloatLengthNullSafe

      public static float getFloatLengthNullSafe(Unit length, float baseWidth)
      Used to extract float value of length from Length value.
      Parameters:
      length - length
      baseWidth - base width to calculate length using percentage.
      Returns:
      float(pixels) representation of length.
    • getFloatLength

      public static Float getFloatLength(Unit length, float baseWidth)
      Used to extract float value of length from Length value.
      Parameters:
      length - length
      baseWidth - base width to calculate length using percentage.
      Returns:
      float(pixels) representation of length.
    • getInnerContentRectangle

      public static org.joml.Vector4f getInnerContentRectangle(org.joml.Vector2f componentPosition, org.joml.Vector2f componentSize, org.joml.Vector4f componentPadding)
      Used to calculate inner content rectangle (box-sizing: border-box)
      Parameters:
      componentPosition - component position.
      componentSize - component size.
      componentPadding - component padding.
      Returns:
      inner content rectangle represented with Vector4f where x,y - position, z,w - width and height.
    • getBorderRadius

      public static org.joml.Vector4f getBorderRadius(Component component, Style style)
      Returns vector of four border radius elements where: x = top left, y = top right, z = bottom right, w = bottom left.

      NOTE. IF radius specified in percents - radius will be calculated using only width of component - will be represented with segment of circle (not ellipse).

      Returns:
      vector of four border radius.
    • getStyle

      public static <T> T getStyle(Component component, Function<Style,T> getter)
    • getStyle

      public static <T> T getStyle(Component component, Function<Style,T> getter, T defaultValue)