Package limn.scene

Record Class Constraints

java.lang.Object
java.lang.Record
limn.scene.Constraints

public record Constraints(float minWidth, float maxWidth, float minHeight, float maxHeight) extends Record
Layout constraints handed down the tree (Flutter/Compose style): a widget's measured size must fall inside [minWidth..maxWidth] x [minHeight..maxHeight]. UNBOUNDED_LIMIT marks an unbounded axis.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final float
    Sentinel for "no upper bound" (scrollables measure children with it).
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constraints(float minWidth, float maxWidth, float minHeight, float maxHeight)
    Creates an instance of a Constraints record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    constrain(float width, float height)
    Clamps both axes, which is what onMeasure normally returns.
    float
    constrainHeight(float height)
    Clamps a height into [minHeight, maxHeight].
    float
    constrainWidth(float width)
    Clamps a width into [minWidth, maxWidth].
    deflate(Insets insets)
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    boolean
    Whether the maximum height is finite.
    boolean
    Whether the maximum width is finite; unbounded means "take your intrinsic width".
    final int
    Returns a hash code value for this object.
    loose(float width, float height)
    Anything from zero up to width x height.
     
    float
    Returns the value of the maxHeight record component.
    float
    Returns the value of the maxWidth record component.
    float
    Returns the value of the minHeight record component.
    float
    Returns the value of the minWidth record component.
    tight(float width, float height)
    Exactly width x height.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

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

    • UNBOUNDED_LIMIT

      public static final float UNBOUNDED_LIMIT
      Sentinel for "no upper bound" (scrollables measure children with it).
      See Also:
  • Constructor Details

    • Constraints

      public Constraints(float minWidth, float maxWidth, float minHeight, float maxHeight)
      Creates an instance of a Constraints record class.
      Parameters:
      minWidth - the value for the minWidth record component
      maxWidth - the value for the maxWidth record component
      minHeight - the value for the minHeight record component
      maxHeight - the value for the maxHeight record component
  • Method Details

    • tight

      public static Constraints tight(float width, float height)
      Exactly width x height.
    • loose

      public static Constraints loose(float width, float height)
      Anything from zero up to width x height.
    • hasBoundedWidth

      public boolean hasBoundedWidth()
      Whether the maximum width is finite; unbounded means "take your intrinsic width".
    • hasBoundedHeight

      public boolean hasBoundedHeight()
      Whether the maximum height is finite.
    • loosened

      public Constraints loosened()
      Returns:
      these constraints with minimums dropped to zero
    • deflate

      public Constraints deflate(Insets insets)
      Returns:
      constraints shrunk by the given insets (never below zero)
    • constrainWidth

      public float constrainWidth(float width)
      Clamps a width into [minWidth, maxWidth].
    • constrainHeight

      public float constrainHeight(float height)
      Clamps a height into [minHeight, maxHeight].
    • constrain

      public Size constrain(float width, float height)
      Clamps both axes, which is what onMeasure normally returns.
    • 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 '=='.
      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.
    • minWidth

      public float minWidth()
      Returns the value of the minWidth record component.
      Returns:
      the value of the minWidth record component
    • maxWidth

      public float maxWidth()
      Returns the value of the maxWidth record component.
      Returns:
      the value of the maxWidth record component
    • minHeight

      public float minHeight()
      Returns the value of the minHeight record component.
      Returns:
      the value of the minHeight record component
    • maxHeight

      public float maxHeight()
      Returns the value of the maxHeight record component.
      Returns:
      the value of the maxHeight record component