Class Constraint


  • public final class Constraint
    extends java.lang.Object
    An immutable sizing rule for one child of a Split, created via the static factory methods.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Constraint.Kind
      The category of a constraint.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      static Constraint fill()  
      static Constraint fill​(int weight)
      Creates a constraint taking a weighted share of the remaining space.
      static Constraint fixed​(int cells)
      Creates a fixed-size constraint of exactly cells along the main axis.
      int hashCode()  
      Constraint.Kind kind()  
      static Constraint max​(int cells)
      Creates a constraint of at most cells, growing into remaining space up to that cap.
      static Constraint min​(int cells)
      Creates a constraint of at least cells, growing into remaining space.
      static Constraint percent​(int pct)
      Creates a constraint sized as a percentage of the original available extent.
      java.lang.String toString()  
      int value()  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • fixed

        public static Constraint fixed​(int cells)
        Creates a fixed-size constraint of exactly cells along the main axis.
        Parameters:
        cells - the size in cells, clamped to non-negative
        Returns:
        the constraint
      • percent

        public static Constraint percent​(int pct)
        Creates a constraint sized as a percentage of the original available extent.
        Parameters:
        pct - the percentage, clamped to non-negative
        Returns:
        the constraint
      • fill

        public static Constraint fill()
        Returns:
        a constraint taking an equal share of the remaining space
      • fill

        public static Constraint fill​(int weight)
        Creates a constraint taking a weighted share of the remaining space.
        Parameters:
        weight - the relative weight, clamped to at least 1
        Returns:
        the constraint
      • min

        public static Constraint min​(int cells)
        Creates a constraint of at least cells, growing into remaining space.
        Parameters:
        cells - the minimum size in cells, clamped to non-negative
        Returns:
        the constraint
      • max

        public static Constraint max​(int cells)
        Creates a constraint of at most cells, growing into remaining space up to that cap.
        Parameters:
        cells - the maximum size in cells, clamped to non-negative
        Returns:
        the constraint
      • value

        public int value()
        Returns:
        the constraint value in cells, percent, or weight depending on the kind
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object